A domain-specific language for building self-optimizing AST interpreters

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.

[1]  Per Larsen,et al.  Accelerating iterators in optimizing AST interpreters , 2014, OOPSLA 2014.

[2]  Craig S. Kaplan,et al.  Predicate Dispatching: A Unified Theory of Dispatch , 1998, ECOOP.

[3]  Michael Haupt,et al.  Debugging at Full Speed , 2014, Dyla'14.

[4]  Michael D. Ernst,et al.  Practical pluggable types for java , 2008, ISSTA '08.

[5]  Wilhelm Hasselbring,et al.  Xbase: implementing domain-specific languages for Java , 2012, GPCE '12.

[6]  Martin P. Ward Language-Oriented Programming , 1994, Softw. Concepts Tools.

[7]  Eelco Visser,et al.  The spoofax language workbench: rules for declarative specification of languages and IDEs , 2010, OOPSLA.

[8]  Craig Chambers,et al.  An efficient implementation of SELF a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA 1989.

[9]  Martin Odersky,et al.  Lightweight modular staging: a pragmatic approach to runtime code generation and compiled DSLs , 2010, GPCE '10.

[10]  Christian Wimmer,et al.  Self-optimizing AST interpreters , 2012, DLS.

[11]  Calton Pu,et al.  Specialization tools and techniques for systematic optimization of system software , 2001, TOCS.

[12]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[13]  Debasish Ghosh,et al.  DSLs in Action , 2010 .

[14]  Lorenzo Bettini,et al.  A DSL for writing type systems for Xtext languages , 2011, PPPJ.

[15]  Christian Wimmer,et al.  One VM to rule them all , 2013, Onward!.

[16]  Kunle Olukotun,et al.  Language virtualization for heterogeneous parallel computing , 2010, OOPSLA.

[17]  Lorenzo Bettini Implementing Java-like languages in Xtext with Xsemantics , 2013, SAC '13.

[18]  A. V. Klepinin,et al.  Integration of semantic verifiers into Java language compilers , 2011, Automatic Control and Computer Sciences.

[19]  Michael D. Ernst,et al.  Building and using pluggable type-checkers , 2011, 2011 33rd International Conference on Software Engineering (ICSE).

[20]  David H. Lorenz,et al.  Cedalion: a language for language oriented programming , 2011, OOPSLA '11.

[21]  Stefan Brunthaler,et al.  Efficient interpretation using quickening , 2010, DLS '10.

[22]  Crispin Cowan,et al.  Declarative specialization of object-oriented programs , 1997, OOPSLA '97.