Editorial Notes
A corrigendum was issued for this paper on October 26, 2021. You can download the corrigendum from the supplemental material section of this citation page.
Abstract
The fastest JavaScript production implementations use just-in-time (JIT) compilation and the vast majority of academic publications about implementations of dynamic languages published during the last two decades focus on JIT compilation. This does not imply that static compilers (AoT) cannot be competitive; as comparatively little effort has been spent creating fast AoT JavaScript compilers, a scientific comparison is lacking. This paper presents the design and implementation of an AoT JavaScript compiler, focusing on a performance analysis. The paper reports on two experiments, one based on standard JavaScript benchmark suites and one based on new benchmarks chosen for their diversity of styles, authors, sizes, provenance, and coverage of the language. The first experiment shows an advantage to JIT compilers, which is expected after the decades of effort that these compilers have paid to these very tests. The second shows more balanced results, as the AoT compiler generates programs that reach competitive speeds and that consume significantly less memory. The paper presents and evaluates techniques that we have either invented or adapted from other systems, to improve AoT JavaScript compilation.
Supplemental Material
Available for Download
Corrigendum to "Of JavaScript AOT compilation performance" by Serrano, Proceedings of the ACM on Programming Languages, Volume 5, Issue ICFP (PACMPL 5:ICFP).
- W. Ahn. 2014. Improving javascript performance by deconstructing the type system. In PLDI 2014 - Proceedings of the 2014 ACM SIGPLAN Conference on Programming Language Design and Implementation (Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI)). Association for Computing Machinery, Edinburgh, UK. 496–507. isbn:9781450327848 https://doi.org/10.1145/2594291.2594332 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2014 ; Conference date: 09-06-2014 Through 11-06-2014. Google Scholar
Digital Library
- C. Anderson, P. Giannini, and S. Drossopoulou. 2005. Towards Type Inference for Javascript. In Proceedings of the 19th European Conference on Object-Oriented Programming (ECOOP’05). Springer-Verlag, Heidelberg. https://doi.org/10.1007/11531142_19 Google Scholar
Digital Library
- Apple. 2018. WebKit. https://webkit.org/.Google Scholar
- Vincenzo Arceri, Isabella Mastroeni, and Sunyi Xu. 2020. Static Analysis for ECMAScript String Manipulation Programs. Applied Sciences, 10, 10 (2020), May, 3525. issn:2076-3417 https://doi.org/10.3390/app10103525 Google Scholar
Cross Ref
- R. Artoul. 2015. Javascript Hidden Classes and Inline Caching in V8. http://richardartoul.github.io/jekyll/update/2015/04/26/hidden-classes.htmlGoogle Scholar
- Thomas Ball, Peli de Halleux, and Michał Moskal. 2019. Static TypeScript: An Implementation of a Static Compiler for the TypeScript Language. In Proceedings of the 16th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes (MPLR 2019). Association for Computing Machinery, New York, NY, USA. 105–116. isbn:9781450369770 https://doi.org/10.1145/3357390.3361032 Google Scholar
Digital Library
- Spenser Bauman, Carl Friedrich Bolz, Robert Hirschfeld, Vasily Kirilichev, Tobias Pape, Jeremy G. Siek, and Sam Tobin-Hochstadt. 2015. Pycket: A Tracing JIT for a Functional Language. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). Association for Computing Machinery, New York, NY, USA. 22–34. isbn:9781450336697 https://doi.org/10.1145/2784731.2784740 Google Scholar
Digital Library
- H.J. Boehm and M. Weiser. 1988. Garbage Collection in an Uncooperative Environment. Software — Practice and Experience, 18, 9 (1988), Sept., 807–820. https://doi.org/10.1002/spe.4380180902 Google Scholar
Digital Library
- Fraser Brown, John Renner, Andres Nötzli, Sorin Lerner, Hovav Shacham, and Deian Stefan. 2020. Towards a Verified Range Analysis for JavaScript JITs. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2020). Association for Computing Machinery, New York, NY, USA. 135–150. isbn:9781450376136 https://doi.org/10.1145/3385412.3385968 Google Scholar
Digital Library
- C. Chambers and D. Ungar. 1989. Customization: Optimizing Compiler Technology for SELF, A Dynamically-Typed Object-Oriented Programming Language. In Conference Proceedings on Programming Language Design and Implementation (PLDI ’89). ACM, New York, NY, USA. https://doi.org/10.1145/73141.74831 Google Scholar
Digital Library
- C. Chambers, D. Ungar, and E. Lee. 1989. An Efficient Implementation of SELF a Dynamically-typed Object-oriented Language Based on Prototypes. In Conference Proceedings on Object-oriented Programming Systems, Languages and Applications (OOPSLA ’89). ACM, USA. 49–70. isbn:0-89791-333-7 https://doi.org/10.1145/74878.74884 Google Scholar
Digital Library
- S. Chandra. 2016. Type Inference for Static Compilation of JavaScript. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2016). ACM, New York, NY, USA. isbn:978-1-4503-4444-9 https://doi.org/10.1145/3022671.2984017 Google Scholar
Digital Library
- M. Chevalier-Boisvert and M. Feeley. 2015. Simple and Effective Type Check Removal through Lazy Basic Block Versioning. In 29th European Conference on Object-Oriented Programming, ECOOP 2015. https://doi.org/10.4230/LIPIcs.ECOOP.2015.101 Google Scholar
Cross Ref
- M. Chevalier-Boisvert and M. Feeley. 2016. Interprocedural Type Specialization of JavaScript Programs Without Type Analysis. In 30th European Conference on Object-Oriented Programming. https://doi.org/10.4230/LIPIcs.ECOOP.2016.7 Google Scholar
Cross Ref
- Jiho Choi, Thomas Shull, and Josep Torrellas. 2019. Reusable Inline Caching for JavaScript Performance. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019). Association for Computing Machinery, New York, NY, USA. 889–901. isbn:9781450367127 https://doi.org/10.1145/3314221.3314587 Google Scholar
Digital Library
- W. Choi, S. Chandra, G. Necula, and L. Sen. 2015. SJS: A Type System for JavaScript with Fixed Object Layout. In Static Analysis - 22nd International Symposium, SAS’15. Saint-Malo, France. 181–198. https://doi.org/10.1007/978-3-662-48288-9_11 Google Scholar
Cross Ref
- D. Clifford, H. Payer, M. Stanton, and B. Titzer. 2015. Memento Mori: Dynamic Allocation-site-based Optimizations. In Proceedings of the 2015 ACM SIGPLAN International Symposium on Memory Management. New York, NY, USA. https://doi.org/10.1145/2887746.2754181 Google Scholar
Digital Library
- G. Dot. 2017. Removing Checks in Dynamically Typed Languages through Efficient Profiling. In Proceedings of the 2017 International Symposium on Code Generation and Optimization (CGO ’17). IEEE Press, 257–268. isbn:9781509049318 https://doi.org/10.5555/3049832.3049860Google Scholar
Digital Library
- ECMA International. 2015. Standard ECMA-262 - ECMAScript Language Specification (6.0 ed.).Google Scholar
- ECMA International. 2018. ECMAScript 2018 Language Specification (9.0 ed.). https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdfGoogle Scholar
- David Eder. 2020. a simple BASIC interpreter. http://eder.us/projects/jbasic/Google Scholar
- D. Flanagan. 2002. JavaScript – The definitive guide (fourth edition). O’Reilly & Associates, USA.Google Scholar
- A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. 2009. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2009, Dublin, Ireland, June 15-21, 2009. https://doi.org/10.1145/1542476.1542528 Google Scholar
Digital Library
- Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff, Jesse Ruderman, Edwin W. Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, and Michael Franz. 2009. Trace-Based Just-in-Time Type Specialization for Dynamic Languages. In Proceedings of the 30th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’09). Association for Computing Machinery, New York, NY, USA. 465–478. isbn:9781605583921 https://doi.org/10.1145/1542476.1542528 Google Scholar
Digital Library
- Google. 2018. V8 JavaScript Engine. http://developers.google.com/v8Google Scholar
- Google. 2019. JIT-less V8. https://v8.dev/blog/jitlessGoogle Scholar
- A. Guha, C. Saftoiu, and S. Krishnamurthi. 2010. The essence of JavaScript. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’10). https://doi.org/10.5555/1883978.1883988Google Scholar
- Andreas Haas. 2017. Bringing the Web up to Speed with WebAssembly. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). Association for Computing Machinery, New York, NY, USA. 185–200. isbn:9781450349888 https://doi.org/10.1145/3062341.3062363 Google Scholar
Digital Library
- B. Hackett and S-Y. Guo. 2012. Fast and Precise Hybrid Type Inference for JavaScript. In Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation. New York, NY, USA. isbn:978-1-4503-1205-9 https://doi.org/10.1145/2345156.2254094 Google Scholar
Digital Library
- James Halliday. 2020. Minimist: parse argument options. https://github.com/substack/minimistGoogle Scholar
- Zoltan Herczeg. 2015. Performance comparison of regular expression engines. https://zherczeg.github.io/sljit/regex_perf.htmlGoogle Scholar
- U. Hölzle, C. Chambers, and D. Ungar. 1991. Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP ’91). UK. 21–38. isbn:3-540-54262-0 https://doi.org/10.1.1.126.7745Google Scholar
- Adobe Systems Incorporated. 2020. jpeg.js, A pure javascript JPEG encoder and decoder for node.js. https://github.com/eugeneware/jpeg-jsGoogle Scholar
- Isaacs. 2016. https://github.com/isaacs/minimatchGoogle Scholar
- Christopher Jeffrey. 2020. Marked. https://github.com/markedjs/markedGoogle Scholar
- S. Jensen, A. Møller, and P. Thiemann. 2009. Type Analysis for JavaScript. In Proceedings of the 16th International Symposium on Static Analysis (SAS). Springer-Verlag, Berlin, Heidelberg. 238–255. isbn:978-3-642-03236-3 https://doi.org/10.1007/978-3-642-03237-0_17 Google Scholar
Digital Library
- Simon Holm Jensen, Anders Møller, and Peter Thiemann. 2009. Type Analysis for JavaScript. In Proc. 16th International Static Analysis Symposium (SAS) (LNCS, Vol. 5673). Springer-Verlag. https://doi.org/10.1007/978-3-642-03237-0_17 Google Scholar
Digital Library
- S H. Jensen, A. Møller, and P. Thiemann. 2009. Type Analysis for JavaScript. In Proceedings of the 16th International Symposium on Static Analysis (SAS ’09). Springer-Verlag, Berlin, Heidelberg. isbn:978-3-642-03236-3 https://doi.org/10.1007/978-3-642-03237-0_17 Google Scholar
Digital Library
- Vineeth Kashyap, Kyle Dewey, Ethan A. Kuefner, John Wagner, Kevin Gibbons, John Sarracino, Ben Wiedermann, and Ben Hardekopf. 2014. JSAI: A Static Analysis Platform for JavaScript. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering (FSE 2014). Association for Computing Machinery, New York, NY, USA. 121–132. isbn:9781450330565 https://doi.org/10.1145/2635868.2635904 Google Scholar
Digital Library
- Arase Kazuhiko. 2009. QRcode.js. http://www.d-project.com/Google Scholar
- R. Kelsey, W. Clinger, and J. Rees. 1998. The Revised(5) Report on the Algorithmic Language Scheme. Higher-Order and Symbolic Computation, 11, 1 (1998), Sept..Google Scholar
- Y. Ko, H. Lee, J. Dolby, and S. Ryu. 2015. Practically Tunable Static Analysis Framework for Large-Scale JavaScript Applications. In 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE). 541–551. https://doi.org/10.1109/ASE.2015.28 Google Scholar
Digital Library
- B. S. Lerner, J. Politz, J.G., A. Guha, and S. Krishnamurthi. 2013. TeJaS: Retrofitting Type Systems for JavaScript. In Proceedings of the 9th Symposium on Dynamic Languages (DLS ’13). ACM, NY, USA. isbn:978-1-4503-2433-5 https://doi.org/10.1145/2578856.2508170 Google Scholar
Digital Library
- F. Logozzo and H. Venter. 2010. RATA: Rapid Atomic Type Analysis by Abstract Interpretation - Application to JavaScript Optimization. In Compiler Construction, 19th International Conference, CC 2010, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2010, Paphos, Cyprus, March 20-28, 2010. Proceedings. https://doi.org/10.1007/978-3-642-11970-5_5 Google Scholar
Digital Library
- Florian Loitsch. 2005. Javascript to Scheme Compilation. In Proceedings of the Sixth Workshop on Scheme and Functional Programming. 101–116.Google Scholar
- F. Loitsch and M. Serrano. 2008. Trends in Functional Programming. 8, Seton Hall University, Intellect Bristol, UK/Chicago, USA. 141–158. isbn:978-1-84150-196-3Google Scholar
- MDN. 2019. SpiderMonkey Internals. https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/InternalsGoogle Scholar
- B. Meurer. 2016. The truth about traditional JavaScript benchmarks. https://benediktmeurer.de/2016/12/16/the-truth-about-traditional-javascript-benchmarksGoogle Scholar
- Moment.com. 2020. Moment.js. https://momentjs.com/Google Scholar
- Raphaël Monat, Abdelraouf Ouadjaout, and Antoine Miné. 2020. Value and Allocation Sensitivity in Static Python Analyses. In Proceedings of the 9th ACM SIGPLAN International Workshop on the State Of the Art in Program Analysis (SOAP 2020). Association for Computing Machinery, New York, NY, USA. 8–13. isbn:9781450379977 https://doi.org/10.1145/3394451.3397205 Google Scholar
Digital Library
- Mozilla. 2020. SpiderMonkey: The Mozilla JavaScript runtime. https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkeyGoogle Scholar
- Todd Mytkowicz, Amer Diwan, Matthias Hauswirth, and Peter F. Sweeney. 2009. Producing wrong data without doing anything obviously wrong!. In Proceeding of the 14th international conference on Architectural support for programming languages and operating systems (ASPLOS ’09). ACM, New York, NY, USA. 265–276. isbn:978-1-60558-406-5 https://doi.org/10.1145/1508244.1508275 Google Scholar
Digital Library
- Benjamin Barslev Nielsen and Anders Møller. 2020. Value Partitioning: A Lightweight Approach to Relational Static Analysis for JavaScript. In Proc. 34th European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.4230/LIPIcs.ECOOP.2020.16 Google Scholar
Cross Ref
- C. Park and S. Ryu. 2015. Scalable and Precise Static Analysis of JavaScript Applications via Loop-Sensitivity. In 29th European Conference on Object-Oriented Programming, ECOOP 2015, Prague, Czech Republic. https://doi.org/10.1145/3093334.2989228 Google Scholar
Digital Library
- Aleksandar Prokopec, Gilles Duboscq, David Leopoldseder, and Thomas Würthinger. 2019. An Optimization-Driven Incremental Inline Substitution Algorithm for Just-in-Time Compilers. In Proceedings of the 2019 International Symposium on Code Generation and Optimization (CGO 2019). IEEE Press, 164–179. isbn:9781728114361 https://doi.org/10.5555/3314872.3314893Google Scholar
Cross Ref
- M. Qunaibit. 2018. Accelerating Dynamically-Typed Languages on Heterogeneous Platforms Using Guards Optimization. In Proceedings of 32th the European Conference on Object-Oriented Programming (ECOOP’18). https://doi.org/10.4230/LIPIcs.ECOOP.2018.16 Google Scholar
Cross Ref
- Brianna M. Ren and Jeffrey S. Foster. 2016. Just-in-Time Static Type Checking for Dynamic Languages. In Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’16). Association for Computing Machinery, New York, NY, USA. 462–476. isbn:9781450342612 https://doi.org/10.1145/2908080.2908127 Google Scholar
Digital Library
- V. Saint-Amour and S-Y Guo. 2015. Optimization Coaching for JavaScript. In 29th European Conference on Object-Oriented Programming, ECOOP 2015. https://doi.org/10.4230/LIPIcs.ECOOP.2015.271 Google Scholar
Cross Ref
- Manuel Serrano. 1992. Bigloo, a Practical Scheme Compiler. http://www-sop.inria.fr/indes/fp/Bigloo/Google Scholar
- M. Serrano. 2018. JavaScript AOT Compilation. In 14th Dynamic Language Symposium (DLS). Boston, USA. https://doi.org/10.1145/3276945.3276950 Google Scholar
Digital Library
- M. Serrano and M. Feeley. 2019. Property Caches Revisited. In Proceedings of the 28th Compiler Construction Conference (CC’19). Washington, USA. https://doi.org/10.1145/3302516.3307344 Google Scholar
Digital Library
- M. Serrano and R. Findler. 2020. Dynamic Property Caches, a Step towards Faster JavaScripts Proxy Objects. In Proceedings of the 29th Compiler Construction Conference (CC’20). San Dieo, USA. https://doi.org/10.1145/3377555.3377888 Google Scholar
Digital Library
- O. Shivers. 1988. Control Flow Analysis in Scheme. In Proceedings of the SIGPLAN ’88 ACM Sigplan Int’l Conference on Programming Language Design and Implementation (PLDI). Atlanta, Georgia. https://doi.org/10.1145/960116.54007 Google Scholar
Digital Library
- S. Strickland. 2012. Chaperones and Impersonators: Run-time Support for Reasonable Interposition. In Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’12). Arizona, USA. 943–962. https://doi.org/10.1145/2384616.2384685 Google Scholar
Digital Library
- 2020. uuid.js, For the creation of RFC4122 UUIDs. https://www.npmjs.com/package/uuidGoogle Scholar
- V8 Team. 2017. Retiring Octane. https://v8.dev/blog/retiring-octaneGoogle Scholar
- Jérôme Vouillon. 2020. Js_of_ocaml. https://ocsigen.org/js_of_ocamlGoogle Scholar
- April W. Wade, Prasad A. Kulkarni, and Michael R. Jantz. 2017. AOT vs. JIT: Impact of Profile Data on Code Quality. In Proceedings of the 18th ACM SIGPLAN/SIGBED Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2017). Association for Computing Machinery, New York, NY, USA. 1–10. isbn:9781450350303 https://doi.org/10.1145/3078633.3081037 Google Scholar
Digital Library
- Wikipedia. 2021. Włand X. https://en.wikipedia.org/wiki/W%5EXGoogle Scholar
- Christian Wimmer. 2019. Initialize Once, Start Fast: Application Initialization at Build Time. Proc. ACM Program. Lang., 3, OOPSLA (2019), Article 184, Oct., 29 pages. https://doi.org/10.1145/3360610 Google Scholar
Digital Library
- T. Würthinger. 2017. Practical Partial Evaluation for High-Performance Dynamic Language Runtimes. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2017). Association for Computing Machinery, New York, NY, USA. 662–676. isbn:9781450349888 https://doi.org/10.1145/3062341.3062381 Google Scholar
Digital Library
Index Terms
Of JavaScript AOT compilation performance
Recommendations
JavaScript AOT compilation
DLS 2018: Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic LanguagesStatic compilation, a.k.a., ahead-of-time (AOT) compilation, is an alternative approach to JIT compilation that can combine good speed and lightweight memory footprint, and that can accommodate read-only memory constraints that are imposed by some ...
JavaScript AOT compilation
DLS '18Static compilation, a.k.a., ahead-of-time (AOT) compilation, is an alternative approach to JIT compilation that can combine good speed and lightweight memory footprint, and that can accommodate read-only memory constraints that are imposed by some ...
From bytecode to JavaScript: the Js_of_ocaml compiler
We present the design and implementation of a compiler from OCaml bytecode to JavaScript. The compiler first translates the bytecode into a static single-assignment intermediate representation on which optimizations are performed, before generating ...






Comments