Abstract
Modern JavaScript engines optimize hot functions using a JIT compiler along with type information gathered by an online profiler. However, the profiler's information can be unsound and when unexpected types are encountered the engine must recover using an expensive mechanism called deoptimization. In this paper we describe a method to significantly reduce the number of deoptimizations observed by client-side JavaScript engines by using ahead-of-time profiling on the server-side. Unlike previous work on ahead-of-time profiling for statically-typed languages such as Java, our technique must operate on a dynamically-typed language, which significantly changes the required insights and methods to make the technique effective. We implement our proposed technique using the SpiderMonkey JavaScript engine, and we evaluate our implementation using three different kinds of benchmarks: the industry-standard Octane benchmark suite, a set of JavaScript physics engines, and a set of real-world websites from the Membench50 benchmark suite. We show that using ahead-of-time profiling provides significant performance benefits over the baseline vanilla SpiderMonkey engine.
- Spidermonkey baseline compiler. https://wiki.mozilla.org/ Javascript:SpiderMonkey:BaselineCompiler, 2015.Google Scholar
- Common language runtime. http://msdn.microsoft.com/ en-us/library/8bs2ecf4(v=vs.110).aspx, 2015.Google Scholar
- Java virtual machine. http://docs.oracle.com/javase/specs/ jvms/se7/html/, 2015.Google Scholar
- Matter.js - a 2d rigid body javascript physics engine. http://brm. io/matter-js/, 2015.Google Scholar
- Membench50. http://gregor-wagner.com/tmp/mem50, 2015.Google Scholar
- Mozilla central repository. https://hg.mozilla.org/ mozilla-central, 2015.Google Scholar
- Octane benchmark suite. https://developers.google.com/ octane/, 2015.Google Scholar
- Physics.js physics engine. http://wellcaffeinated.net/ PhysicsJS/, 2015.Google Scholar
- pixi.js 3d rendering engine. http://www.pixijs.com, 2015.Google Scholar
- Selenium ide. http://docs.seleniumhq.org/docs/02_ selenium_ide.jsp, 2015.Google Scholar
- three.js physics engine. http://threejs.org, 2015.Google Scholar
- M. Arnold, S. Fink, D. Grove, M. Hind, and P. F. Sweeney. Adaptive optimization in the jalapeno jvm. In Proceedings of the 15th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications, 2000. Google Scholar
Digital Library
- M. Arnold, A. Welc, and V. T. Rajan. Improving virtual machine performance using a cross-run profile repository. In Proceedings of the 20th Annual ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications, 2005. Google Scholar
Digital Library
- asm.js specification. asm.js specification. http://asmjs.org/spec/ latest/, 2015.Google Scholar
- C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the metalevel: Pypy’s tracing jit compiler. In Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, 2009. Google Scholar
Digital Library
- Closure Compiler. Google Inc. closure compiler. https:// developers.google.com/closure/compiler/, 2015.Google Scholar
- Crankshaft compiler. V8 engine. http://www.jayconrod.com/posts/54/ a-tour-of-v8-crankshaft-the-optimizing-compiler, 2015.Google Scholar
- Flow. Flow static type checker. http://flowtype.org, 2015.Google Scholar
- L. Guckert, M. OConnor, S. Kumar Ravindranath, Z. Zhao, and V. Janapa Reddi. A case for persistent caching of compiled javascript code in mobile web browsers. In In Workshop on Architectural and Microarchitectural Support for Binary Translation, 2013.Google Scholar
- U. Hölzle and D. Ungar. A third-generation self implementation: reconciling responsiveness with performance. In Proceedings of the ninth annual conference on Object-oriented programming systems, language, and applications, 1994. Google Scholar
Digital Library
- U. Hölzle, C. Chambers, and D. Ungar. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proceedings of the European Conference on Object-Oriented Programming, 1991. Google Scholar
Digital Library
- U. Hölzle, C. Chambers, and D. Ungar. Debugging optimized code with dynamic deoptimization. In Proceedings of the ACM SIGPLAN 1992 conference on Programming language design and implementation, 1992. Google Scholar
Digital Library
- JavaScriptCore. Webkit JavaScriptCore virtual machine. http: //trac.webkit.org/wiki/JavaScriptCore, 2015.Google Scholar
- C. Krintz. Coupling on-line and off-line profile information to improve program performance. In Proceedings of the International Symposium on Code Generation and Optimization: Feedback-directed and Runtime Optimization, 2003. Google Scholar
Digital Library
- C. Krintz and B. Calder. Using annotations to reduce dynamic optimization time. In Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, 2001. Google Scholar
Digital Library
- J. Oh and S.-M. Moon. Snapshot-based loading-time acceleration for web applications. In Proceedings of the 13th Annual IEEE/ACM International Symposium on Code Generation and Optimization, 2015. Google Scholar
Digital Library
- M. Paleczny, C. Vick, and C. Click. The java hotspot server compiler. In Proceedings of the 2001 Symposium on JavaTM Virtual Machine Research and Technology Symposium - Volume 1, 2001. Google Scholar
Digital Library
- SpiderMonkey. SpiderMonkey JavaScript Engine. http://www. mozilla.org/js/spidermonkey/, 2015.Google Scholar
- TypeScript. Typescript. http://www.typescriptlang.org, 2015.Google Scholar
- V8. Google Inc. V8 JavaScript virtual machine. https://code. google.com/p/v8, 2015.Google Scholar
Index Terms
Server-side type profiling for optimizing client-side JavaScript engines
Recommendations
Server-side type profiling for optimizing client-side JavaScript engines
DLS 2015: Proceedings of the 11th Symposium on Dynamic LanguagesModern JavaScript engines optimize hot functions using a JIT compiler along with type information gathered by an online profiler. However, the profiler's information can be unsound and when unexpected types are encountered the engine must recover using ...
Deoptimization for dynamic language JITs on typed, stack-based virtual machines
VEE '14: Proceedings of the 10th ACM SIGPLAN/SIGOPS international conference on Virtual execution environmentsWe are interested in implementing dynamic language runtimes on top of language-level virtual machines. Type specialization is a critical optimization for dynamic language runtimes: generic code that handles any type of data is replaced with specialized ...
Self-optimizing AST interpreters
DLS '12: Proceedings of the 8th symposium on Dynamic languagesAn abstract syntax tree (AST) interpreter is a simple and natural way to implement a programming language. However, it is also considered the slowest approach because of the high overhead of virtual method dispatch. Language implementers therefore ...






Comments