skip to main content
research-article

Self-optimizing AST interpreters

Published:22 October 2012Publication History
Skip Abstract Section

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.

References

  1. J. R. Bell. Threaded code. Communications ACM, 16 (6): 370--372, 1973. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. }Brunthaler10aS. Brunthaler. Efficient interpretation using quickening. In Proceedings of the Dynamic Languages Symposium, pages 1--14. ACM Press, 2010. 10.1145/1869631.1869633. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. Click. Fixing the inlining problem, 2011. URL http://www.azulsystems.com/blog/cliff/2011-04-04-fixing-the-inlining-pr%oblem.Google ScholarGoogle Scholar
  8. ECMA. Standard ECMA-335: Common language infrastructure (CLI), 2012. URL http://www.ecma-international.org/publications/standards/Ecma-335.htm.Google ScholarGoogle Scholar
  9. M. A. Ertl and D. Gregg. The structure and performance of efficient interpreters. Journal of Instruction-Level Parallelism, 5, 2003.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. Google. V8 JavaScript engine, 2012. URL http://code.google.com/p/v8/.Google ScholarGoogle Scholar
  12. Google. V8 benchmark suite, 2012. URL http://v8.googlecode.com/svn/data/benchmarks/current/run.html.Google ScholarGoogle Scholar
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle Scholar
  18. Mozilla. Rhino JavaScript VM, 2012. URL http://www.mozilla.org/rhino/.Google ScholarGoogle Scholar
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Self-optimizing AST interpreters

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!