Abstract
Increased focus on JavaScript performance has resulted in vast performance improvements for many benchmarks. However, for actual code used in websites, the attained improvements often lag far behind those for popular benchmarks.
This paper shows that the main reason behind this short-fall is how the compiler understands types. JavaScript has no concept of types, but the compiler assigns types to objects anyway for ease of code generation. We examine the way that the Chrome V8 compiler defines types, and identify two design decisions that are the main reasons for the lack of improvement: (1) the inherited prototype object is part of the current object's type definition, and (2) method bindings are also part of the type definition. These requirements make types very unpredictable, which hinders type specialization by the compiler. Hence, we modify V8 to remove these requirements, and use it to compile the JavaScript code assembled by JSBench from real websites. On average, we reduce the execution time of JSBench by 36%, and the dynamic instruction count by 49%.
- Chakra. http://blogs.msdn.com/b/ie/archive/2010/03/18/the-new-javascript-engine-in-internet-explorer-9.aspx.Google Scholar
- ECMAScript. http://www.ecmascript.org/.Google Scholar
- JavaScriptCore. http://trac.webkit.org/wiki/JavaScriptCore.Google Scholar
- Kraken Benchmarks. http://krakenbenchmark.mozilla.org/.Google Scholar
- Octane Benchmarks. https://developers.google.com/octane.Google Scholar
- SpiderMonkey Project. https://developer.mozilla.org/en-US/docs/SpiderMonkey.Google Scholar
- SunSpider Benchmarks. http://www.webkit.org/perf/sunspider/sunspider.html.Google Scholar
- V8 JavaScript Engine. https://developers.google.com/v8/.Google Scholar
- O. Anderson, E. Fortuna, L. Ceze, and S. Eggers. Checked load: Architectural support for JavaScript type-checking on mobile processors. In HPCA, 2011. Google Scholar
Digital Library
- J. Castanos, D. Edelsohn, K. Ishizaki, P. Nagpurkar, T. Nakatani, T. Ogasawara, and P. Wu. On the benefits and pitfalls of extending a statically typed language JIT compiler for dynamic scripting languages. In OOPSLA, 2012. Google Scholar
Digital Library
- C. Chambers, D. Ungar, and E. Lee. An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes. In OOPSLA, 1989. Google Scholar
Digital Library
- D. Clifford. Breaking the JavaScript limit with V8. http://v8-io12.appspot.com.Google Scholar
- L. P. Deutsch and A. M. Schiffman. Efficient implementation of the Smalltalk-80 system. In POPL, 1984. Google Scholar
Digital Library
- B. Hackett and S.-Y. Guo. Fast and precise hybrid type inference for JavaScript. In PLDI, 2012. Google Scholar
Digital Library
- U. Hölzle, C. Chambers, and D. Ungar. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In ECOOP, 1991. Google Scholar
Digital Library
- S. Li, B. Cheng, and X.-F. Li. TypeCastor: Demystify dynamic typing of JavaScript applications. In HiPEAC, 2011. Google Scholar
Digital Library
- C.-K. Luk, R. Cohn, R. Muth, H. Patil, A. Klauser, G. Lowney, S. Wallace, V. J. Reddi, and K. Hazelwood. Pin: Building customized program analysis tools with dynamic instrumentation. In PLDI, 2005. Google Scholar
Digital Library
- M. Mehrara, P.-C. Hsu, M. Samadi, and S. Mahlke. Dynamic parallelization of JavaScript applications using an ultra-lightweight speculation mechanism. In HPCA, 2011. Google Scholar
Digital Library
- M. Mehrara and S. Mahlke. Dynamically accelerating client-side web applications through decoupled execution. In CGO, 2011. Google Scholar
Digital Library
- P. Ratanaworabhan, B. Livshits, and B. G. Zorn. JSMeter: Comparing the behavior of JavaScript benchmarks with real Web applications. In the USENIX Conference on Web Application Development, 2010. Google Scholar
Digital Library
- G. Richards, A. Gal, B. Eich, and J. Vitek. Automated construction of JavaScript benchmarks. In OOPSLA, 2011. Google Scholar
Digital Library
- G. Richards, C. Hammer, B. Burg, and J. Vitek. The Eval that men do: A large-scale study of the use of Eval in JavaScript applications. In ECOOP, 2011. Google Scholar
Digital Library
- G. Richards, S. Lebresne, B. Burg, and J. Vitek. An analysis of the dynamic behavior of JavaScript programs. In PLDI, 2010. Google Scholar
Digital Library
Index Terms
Improving JavaScript performance by deconstructing the type system
Recommendations
Improving JavaScript performance by deconstructing the type system
PLDI '14: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and ImplementationIncreased focus on JavaScript performance has resulted in vast performance improvements for many benchmarks. However, for actual code used in websites, the attained improvements often lag far behind those for popular benchmarks.
This paper shows that ...
The Design of Monty: a Programming/Scripting Language
This paper describes the design of Monty, a language intended to be equally suitable for both scripting and conventional programming. Monty features an unusually flexible type system in which all values are viewed as objects in a single-inheritance ...
TypeCastor: demystify dynamic typing of JavaScript applications
HiPEAC '11: Proceedings of the 6th International Conference on High Performance and Embedded Architectures and CompilersDynamic typing is a barrier for JavaScript applications to achieve high performance. Compared with statically typed languages, the major overhead of dynamic typing comes from runtime type resolution and runtime property lookup. Common folks' belief is ...









Comments