ABSTRACT
Type feedback and type inference are two common methods used to optimize dynamic languages such as JavaScript. Each of these methods has its own strengths and weaknesses, and we propose that each can benefit from the other if combined in the right way. We explore the interdependency between these two methods and propose two novel ways to combine them in order to significantly increase their aggregate benefit and decrease their aggregate overhead. In our proposed strategy, an initial type inference pass is applied that can reduce type feedback overhead by enabling more intelligent placement of profiling hooks. This initial type inference pass is novel in the literature. After profiling, a final type inference pass uses the type information from profiling to generate efficient code. While this second pass is not novel, we significantly improve its effectiveness in a novel way by feeding the type inference pass information about the function signature, i.e., the types of the function's arguments for aspecific function invocation. Our results show significant speedups when using these low-overhead strategies, ranging from 1.2x to 4x over an implementation that does not perform type feedback or type inference based optimizations. Our experiments are carried out across a wide range of traditional benchmarks and realistic web applications. The results also show an average reduction of 23.5% in the size of the profiled data for these benchmarks.
- Google closure compiler. https://developers.google.com/closure/compiler.Google Scholar
- Js1k. http://js1k.com.Google Scholar
- Jscrush minifier. http://www.iteral.com/jscrush.Google Scholar
- Kraken benchmark suite. http://krakenbenchmark.mozilla.org.Google Scholar
- Sunspider benchmark suite. http://www.webkit.org/perf/sunspider/sunspider.html.Google Scholar
- V8 benchmark suite. http://v8.googlecode.com/svn/data/benchmarks/v7/README.txt.Google Scholar
- O. Agesen. Concrete type inference: delivering object-oriented applications. PhD thesis, Stanford, CA, USA, 1996. UMI Order No. GAX96-20452. Google ScholarDigital Library
- O. Agesen and U. Hölzle. Type feedback vs. concrete type inference: A comparison of optimization techniques for object-oriented languages. In ACM SIGPLAN Notices, volume 30, pages 91--107. ACM, 1995. Google ScholarDigital Library
- M. Arnold and B. G. Ryder. A framework for reducing the cost of instrumented code. In Proceedings of the ACM SIGPLAN 2001 conference on Programming language design and implementation, PLDI '01, pages 168--179, New York, NY, USA, 2001. ACM. ISBN 1-58113-414-2. URL http://doi.acm.org/10. 1145/378795.378832. Google ScholarDigital Library
- M. Arnold, S. J. Fink, D. Grove, M. Hind, and P. F. Sweeney. A survey of adaptive optimization in virtual machines. In Proceedings of the IEEE, 93(2), 2005. special issue on program generatation, optimization, and adaptations, 2004.Google Scholar
- D. G. Bobrow, L. G. DeMichiel, R. P. Gabriel, S. E. Keene, G. Kiczales, and D. A. Moon. Common lisp object system specification. ACM Sigplan Notices, 23(SI):1--142, 1988. Google ScholarDigital Library
- C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the meta-level: Pypy's tracing jit compiler. In Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 18--25. ACM, 2009. Google ScholarDigital Library
- C. F. Bolz, A. Cuni, M. Fijalkowski, M. Leuschel, S. Pedroni, and A. Rigo. Runtime feedback in a meta-tracing jit for efficient dynamic languages. In Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems, page 9. ACM, 2011. Google ScholarDigital Library
- C. Cascaval, S. Fowler, P. Montesinos-Ortego, W. Piekarski, M. Reshadi, B. Robatmili, M. Weber, and V. Bhavsar. Zoomm: a parallel web browser engine for multicore mobile devices. In Proceedings of the 18th ACM SIGPLAN symposium on Principles and practice of parallel programming, PPoPP '13, pages 271--280, New York, NY, USA, 2013. ACM. ISBN 978-1-4503-1922-5. URL http://doi.acm.org/10.1145/2442516.2442543. Google ScholarDigital Library
- C. Chambers. The design and implementation of the self compiler, an optimizing compiler for object-oriented programming languages. PhD thesis, Stanford University, 1992. Google ScholarDigital Library
- C. Chambers and G. T. Leavens. Typechecking and modules for multimethods. ACM Transactions on Programming Languages and Systems (TOPLAS), 17(6): 805--843, 1995. Google ScholarDigital Library
- Crankshaft compiler. V8 engine. http://www.jayconrod.com/posts/54/a-tour-of-v8-crankshaft-the-optimizing-compiler, 2013.Google Scholar
- B. Hackett and S.-y. Guo. Fast and precise hybrid type inference for javascript. In Proceedings of the 33rd ACM SIGPLAN conference on Programming Language Design and Implementation, pages 239--250. ACM, 2012. Google ScholarDigital Library
- U. Hölzle. Adaptive optimization for SELF: reconciling high performance with exploratory programming. PhD thesis, Stanford University, 1995.Google ScholarDigital Library
- U. Hölzle and D. Ungar. Optimizing dynamically-dispatched calls with run-time type feedback. ACM SIGPLAN Notices, 29(6):326--336, 1994. Google ScholarDigital Library
- U. Hölzle and D. Ungar. Reconciling responsiveness with performance in pure object-oriented languages. ACM Trans. Program. Lang. Syst., 18(4):355--400, July 1996. ISSN 0164-0925. . URL http://doi.acm.org/10.1145/233561.233562. Google ScholarDigital Library
- Mono. Xamarian Inc. Mono. http://www.mono-project.com/Main_Page, 2013.Google Scholar
- PyPy. PyPy Status Blog. http://morepypy.blogspot.com,2013.Google Scholar
- Rubinius. Rubinius Blog. http://rubini.us/blog, 2013.Google Scholar
- v8. Google Inc. V8 JavaScript virtual machine. https://code.google.com/p/v8, 2013.Google Scholar
Index Terms
- Improved type specialization for dynamic scripting languages
Recommendations
Improved type specialization for dynamic scripting languages
DLS '13Type feedback and type inference are two common methods used to optimize dynamic languages such as JavaScript. Each of these methods has its own strengths and weaknesses, and we propose that each can benefit from the other if combined in the right way. ...
Polymorphic type inference for scripting languages with object extensions
DLS '11: Proceedings of the 7th symposium on Dynamic languagesThis paper presents a polymorphic type inference algorithm for a small subset of JavaScript. The goal is to prevent accessing undefined members of objects. We define a type system that allows explicit extension of objects through add operation and ...
Principal Type Schemes for Gradual Programs
POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesGradual typing is a discipline for integrating dynamic checking into a static type system. Since its introduction in functional languages, it has been adapted to a variety of type systems, including object-oriented, security, and substructural. This ...
Comments