Abstract
Self-optimizing AST interpreters dynamically adapt to the provided input for faster execution. This adaptation includes initial tests of the input, changes to AST nodes, and insertion of guards that ensure assumptions still hold. Such specialization and speculation is essential for the performance of dynamic programming languages such as JavaScript. In traditional procedural and objectoriented programming languages it can be tedious to write selfoptimizing AST interpreters, as those languages fail to provide constructs that would specifically support that. This paper introduces a declarative domain-specific language (DSL) that greatly simplifies writing self-optimizing AST interpreters. The DSL supports specialization of operations based on types of the input and other properties. It can then use these specializations directly or chain them to represent the operation with the minimum amount of code possible. The DSL significantly reduces the complexity of expressing specializations for those interpreters. We use it in our high-performance implementation of JavaScript, where 274 language operations have an average of about 4 and a maximum of 190 specializations. In addition, the DSL is used in implementations of Ruby, Python, R, and Smalltalk.
- Project Lombok. URL http://projectlombok.org/.Google Scholar
- Meta programming system. URL http://www.jetbrains.com/mps.Google Scholar
- Xtext. URL http://www.eclipse.org/Xtext/.Google Scholar
- TruffleSOM: A file-based Smalltalk implementation built with truffle., 2014. URL https://github.com/smarr/TruffleSOM.Google Scholar
- L. Bettini. A DSL for writing type systems for Xtext languages. In Proceedings of the International Conference on the Principles and Practice of Programming in Java, pages 31–40. ACM Press, 2011. Google Scholar
Digital Library
- L. Bettini. Implementing Java-like languages in Xtext with Xsemantics. In Proceedings of the ACM Symposium on Applied Computing, pages 1559–1564. ACM Press, 2013. Google Scholar
Digital Library
- E. Bruneton, R. Lenglet, and T. Coupaye. ASM: A code manipulation tool to implement adaptable systems. In Adaptable and Extensible Component Systems, 2002.Google Scholar
- S. Brunthaler. Efficient interpretation using quickening. In Proceedings of the Dynamic Languages Symposium, pages 1–14. ACM Press, 2010. Google Scholar
Digital Library
- M. L. V. D. V. C. Seaton and M. Haupt. Debugging at full speed. In Proceedings of the 8th Workshop on Dynamic Languages and Applications (DYLA), 2014. Google Scholar
Digital Library
- H. Chafi, Z. DeVito, A. Moors, T. Rompf, A. K. Sujeeth, P. Hanrahan, M. Odersky, and K. Olukotun. Language virtualization for heterogeneous parallel computing. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 835–847. ACM Press, 2010. 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. Google Scholar
Digital Library
- W. Dietl, S. Dietzel, M. D. Ernst, K. Mus¸lu, and T. W. Schiller. Building and using pluggable type-checkers. In Proceedings of the International Conference on Software Engineering, pages 681–690. ACM Press, 2011. Google Scholar
Digital Library
- S. Efftinge, M. Eysholdt, J. Köhnlein, S. Zarnekow, R. von Massow, W. Hasselbring, and M. Hanus. Xbase: implementing domain-specific languages for Java. In Proceedings of the International Conference on Generative Programming and Component Engineering, pages 112– 121. ACM Press, 2012. Google Scholar
Digital Library
- M. Ernst, C. Kaplan, and C. Chambers. Predicate dispatching: A unified theory of dispatch. In Proceedings of the 12th European Conference on Object-Oriented Programming, ECCOP ’98, pages 186–211, London, UK, UK, 1998. Springer-Verlag. ISBN 3-540- 64737-6. URL http://dl.acm.org/citation.cfm?id=646155.679688. Google Scholar
Digital Library
- FastR. FastR is an implementation of the R language in Java atop Truffle and Graal., 2014. URL https://bitbucket.org/allr/fastr.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
- D. Ghosh. DSLs in Action. Manning Publications Co., Greenwich, CT, USA, 1st edition, 2010. ISBN 9781935182450. 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
- JSR 269. JSR 269: Pluggable Annotation Processing API, 2011. URL http://www.jcp.org/en/jsr/detail?id=269.Google Scholar
- L. C. Kats and E. Visser. The Spoofax language workbench: rules for declarative specification of languages and IDEs. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 444–463. ACM Press, 2010. Google Scholar
Digital Library
- A. Klepinin and A. Melentyev. Integration of semantic verifiers into Java language compilers. Automatic Control and Computer Sciences, 45(7):408–412, 2011..Google Scholar
Cross Ref
- D. H. Lorenz and B. Rosenan. Cedalion: a language for language oriented programming. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pages 733–752. ACM Press, 2011. Google Scholar
Digital Library
- D. McNamee, J. Walpole, C. Pu, C. Cowan, C. Krasic, A. Goel, P. Wagle, C. Consel, G. Muller, and R. Marlet. Specialization tools and techniques for systematic optimization of system software. ACM Trans. Comput. Syst., 19(2):217–251, May 2001. ISSN 0734-2071. Google Scholar
Digital Library
- R. Nuccitelli, E. Guerra, and C. Fernandes. Parsing XML documents in Java using annotations. In XML, Associated Technologies and Applications, 2010.Google Scholar
- OpenJDK. Graal project, 2013. URL http://openjdk.java.net/projects/ graal.Google Scholar
- M. M. Papi, M. Ali, T. L. Correa, Jr., J. H. Perkins, and M. D. Ernst. Practical pluggable types for Java. In Proceedings of the International Symposium on Software Testing and Analysis, pages 201–212. ACM Press, 2008. Google Scholar
Digital Library
- T. Rompf and M. Odersky. Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs. In Proceedings of the International Conference on Generative Programming and Component Engineering, pages 127–136. ACM Press, 2010. Google Scholar
Digital Library
- E. N. Volanschi, C. Consel, G. Muller, and C. Cowan. Declarative specialization of object-oriented programs. SIGPLAN Not., 32(10): 286–300, Oct. 1997. ISSN 0362-1340. Google Scholar
Digital Library
- M. P. Ward. Language oriented programming. Software-Concepts and Tools, 15:147–161, 1995.Google Scholar
- T. Würthinger, A. Wöß, L. Stadler, G. Duboscq, D. Simon, and C. Wimmer. Self-optimizing AST interpreters. In Proceedings of the 8th symposium on Dynamic languages, DLS ’12, pages 73–82. ACM Press, 2012. Google Scholar
Digital Library
- T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward! ACM Press, 2013. Google Scholar
Digital Library
- W. Zhang, P. Larsen, S. Brunthaler, and M. Franz. Accelerating iterators in optimizing ast interpreters. In Submitted to OOPSLA, 2014. Introduction System Structure Node Rewriting Expressing Specializations Truffle DSL Specializations Example Conditional Child Execution Optimization Type Check Elimination Specialization Reduction Guard Reduction DSL Implementation Annotation Processor Evaluation Initial Conversion to Truffle DSL Current use of Truffle DSL Related Work ConclusionsGoogle Scholar
Index Terms
A domain-specific language for building 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