Abstract
An 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 define bytecodes to speed up interpretation, at the cost of introducing inflexible and hard to maintain bytecode formats. We present a novel approach to implementing AST interpreters in which the AST is modified during interpretation to incorporate type feedback. This tree rewriting is a general and powerful mechanism to optimize many constructs common in dynamic programming languages. Our system is implemented in Java and uses the static typing and primitive data types of Java elegantly to avoid the cost of boxed representations of primitive values in dynamic programming languages.
- J. R. Bell. Threaded code. Communications ACM, 16 (6): 370--372, 1973. Google Scholar
Digital Library
- wski, and Rigo}Bolz09C. F. Bolz, A. Cuni, M. Fijałkowski, and A. Rigo. Tracing the meta-level: PyPy's tracing JIT compiler. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 18--25. ACM Press, 2009. 10.1145/1565824.1565827. Google Scholar
Digital Library
- C. F. Bolz, A. Cuni, M. Fijałkowski, M. Leuschel, S. Pedroni, and A. Rigo. Runtime feedback in a meta-tracing JIT for efficient dynamic languages. In Proceedings of the Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, pages 9:1--9:8. ACM Press, 2011. 10.1145/2069172.2069181. Google Scholar
Digital Library
- }Brunthaler10aS. Brunthaler. Efficient interpretation using quickening. In Proceedings of the Dynamic Languages Symposium, pages 1--14. ACM Press, 2010. 10.1145/1869631.1869633. Google Scholar
Digital Library
- }Brunthaler10bS. Brunthaler. Inline caching meets quickening. In Proceedings of the European Conference on Object-Oriented Programming, pages 429--451. Springer-Verlag, 2010. 10.1007/978--3--642--14107--2_21. 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 Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 49--70. ACM Press, 1989. 10.1145/74877.74884. Google Scholar
Digital Library
- C. Click. Fixing the inlining problem, 2011. URL http://www.azulsystems.com/blog/cliff/2011-04-04-fixing-the-inlining-pr%oblem.Google Scholar
- ECMA. Standard ECMA-335: Common language infrastructure (CLI), 2012. URL http://www.ecma-international.org/publications/standards/Ecma-335.htm.Google Scholar
- M. A. Ertl and D. Gregg. The structure and performance of efficient interpreters. Journal of Instruction-Level Parallelism, 5, 2003.Google Scholar
- A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M. R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E. W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based Just-in-Time Type Specialization for Dynamic Languages. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 465--478. ACM Press, 2009. Google Scholar
Digital Library
- Google. V8 JavaScript engine, 2012. URL http://code.google.com/p/v8/.Google Scholar
- Google. V8 benchmark suite, 2012. URL http://v8.googlecode.com/svn/data/benchmarks/current/run.html.Google Scholar
- B. Hackett and S. Guo. Fast and precise hybrid type inference for JavaScript. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 239--250. ACM Press, 2012. 10.1145/2254064.2254094. Google Scholar
Digital Library
- C. Haubl, C. Wimmer, and H. Mössenböck. Evaluation of trace inlining heuristics for Java. In Proceedings of the ACM Symposium on Applied Computing, pages 1871--1876. ACM Press, 2012. 10.1145/2245276.2232084. 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, pages 21--38. Springer-Verlag, 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 Conference on Programming Language Design and Implementation, pages 32--43. ACM Press, 1992. 10.1145/143095.143114. Google Scholar
Digital Library
- T. Lindholm, F. Yellin, G. Bracha, and A. Buckley. The Java Virtual Machine Specification, Java SE 7 Edition, 2012. URL http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf.Google Scholar
- Mozilla. Rhino JavaScript VM, 2012. URL http://www.mozilla.org/rhino/.Google Scholar
- T. A. Proebsting. Optimizing an ANSI C interpreter with superoperators. In Proceedings of the ACM SIGPLAN Symposium on Principles of Programming Languages, pages 322--332. ACM Press, 1995. 10.1145/199448.199526. 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 Proceedings of the European Conference on Object-Oriented Programming, pages 52--78. Springer-Verlag, 2011. 10.1007/978--3--642--22655--7_4. Google Scholar
Digital Library
- A. Rigo and S. Pedroni. PyPy's approach to virtual machine construction. In Companion to the ACM SIGPLAN Conference on Object Oriented Programming Systems, Languages, and Applications, pages 944--953. ACM Press, 2006. 10.1145/1176617.1176753. Google Scholar
Digital Library
- Y. Shi, K. Casey, M. A. Ertl, and D. Gregg. Virtual machine showdown: Stack versus registers. ACM Transactions on Architecture and Code Optimization, 4 (4): 2:1--2:36, Jan. 2008. 10.1145/1328195.1328197. Google Scholar
Digital Library
- K. Williams, J. McCandless, and D. Gregg. Dynamic interpretation for dynamic scripting languages. In Proceedings of the International Symposium on Code Generation and Optimization, pages 278--287. ACM Press, 2010. 10.1145/1772954.1772993. Google Scholar
Digital Library
Index Terms
Self-optimizing AST interpreters
Recommendations
An object storage model for the truffle language implementation framework
PPPJ '14: Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and ToolsTruffle is a Java-based framework for developing high-performance language runtimes. Language implementers aiming at developing new runtimes have to design all the runtime mechanisms for managing dynamically typed objects from scratch. This not only ...
Practical partial evaluation for high-performance dynamic language runtimes
PLDI 2017: Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and ImplementationMost high-performance dynamic language virtual machines duplicate language semantics in the interpreter, compiler, and runtime system. This violates the principle to not repeat yourself. In contrast, we define languages solely by writing an ...
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