Specializing a meta-interpreter: JIT compilation of dynsem specifications on the graal VM

DynSem is a domain-specific language for concise specification of the dynamic semantics of programming languages, aimed at rapid experimentation and evolution of language designs. DynSem specifications can be executed to interpret programs in the language under development. To enable fast turnaround during language development, we have developed a meta-interpreter for DynSem specifications, which requires minimal processing of the specification. In addition to fast development time, we also aim to achieve fast run times for interpreted programs. In this paper we present the design of a meta-interpreter for DynSem and report on experiments with JIT compiling the application of the meta-interpreter on the Graal VM. By interpreting specifications directly, we have minimal compilation overhead. By specializing pattern matches, maintaining call-site dispatch chains and using native control-flow constructs we gain significant run-time performance. We evaluate the performance of the meta-interpreter when applied to the Tiger language specification running a set of common benchmark programs. Specialization enables the Graal VM to JIT compile the meta-interpreter giving speedups of up to factor 15 over running on the standard Oracle Java VM.

[1]  Gordon D. Plotkin,et al.  A structural approach to operational semantics , 2004, J. Log. Algebraic Methods Program..

[2]  Peter D. Mosses,et al.  Implicit Propagation in Structural Operational Semantics , 2009, SOS@ICALP.

[3]  Andrew W. Appel,et al.  Modern Compiler Implementation in Java , 1997 .

[4]  Matthias Felleisen,et al.  Semantics Engineering with PLT Redex , 2009 .

[5]  Grigore Rosu,et al.  K-Java , 2015, POPL.

[6]  Christian Wimmer,et al.  Practical partial evaluation for high-performance dynamic language runtimes , 2017, PLDI.

[7]  Eelco Visser,et al.  DynSem: A DSL for Dynamic Semantics Specification , 2015, RTA.

[8]  Yoshihiko Futamura Partial Evaluation of Computation Process, Revisited , 1999, High. Order Symb. Comput..

[9]  Peter D. Mosses,et al.  Modular structural operational semantics , 2004, J. Log. Algebraic Methods Program..

[10]  Sam Tobin-Hochstadt,et al.  Run your research: on the effectiveness of lightweight mechanization , 2012, POPL '12.

[11]  Sam Tobin-Hochstadt,et al.  Pycket: a tracing JIT for a functional language , 2015, ICFP.

[12]  Hanspeter Mössenböck,et al.  Cross-language compiler benchmarking: are we fast yet? , 2016, DLS.

[13]  Samuele Pedroni,et al.  PyPy's approach to virtual machine construction , 2006, OOPSLA '06.

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

[15]  Eelco Visser,et al.  A Language Designer's Workbench: A One-Stop-Shop for Implementation and Verification of Language Designs , 2014, Onward!.

[16]  Yoshihiko Futamura,et al.  Partial Evaluation of Computation Process--An Approach to a Compiler-Compiler , 1999, High. Order Symb. Comput..

[17]  Peter D. Mosses,et al.  Reusable Components of Semantic Specifications , 2015, LNCS Trans. Aspect Oriented Softw. Dev..

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

[19]  Peter D. Mosses,et al.  Generating Specialized Interpreters for Modular Structural Operational Semantics , 2013, LOPSTR.

[20]  Eelco Visser,et al.  Scopes Describe Frames: A Uniform Model for Memory Layout in Dynamic Semantics , 2016, ECOOP.

[21]  Narciso Martí-Oliet,et al.  The Maude System , 1999, RTA.

[22]  Davide Ancona,et al.  RPython: a step towards reconciling dynamically and statically typed OO languages , 2007, DLS '07.

[23]  Sam Tobin-Hochstadt,et al.  The Racket Manifesto , 2015, SNAPL.

[24]  Nada Amin,et al.  Collapsing towers of interpreters , 2017, Proc. ACM Program. Lang..

[25]  Stefan Marr,et al.  Are We There Yet?: Simple Language Implementation Techniques for the 21st Century , 2014, IEEE Software.

[26]  Chucky Ellison,et al.  An executable formal semantics of C with applications , 2011, POPL '12.

[27]  Grigore Rosu,et al.  An overview of the K semantic framework , 2010, J. Log. Algebraic Methods Program..

[28]  Eelco Visser,et al.  A Theory of Name Resolution , 2015, ESOP.

[29]  Christian Wimmer,et al.  A domain-specific language for building self-optimizing AST interpreters , 2014, GPCE.

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

[31]  Guido Wachsmuth,et al.  A constraint language for static semantic analysis based on scope graphs , 2015, PEPM.

[32]  Peter Sestoft,et al.  Partial evaluation and automatic program generation , 1993, Prentice Hall international series in computer science.

[33]  Carl Friedrich Bolz,et al.  Meta-Tracing Just-in-Time Compilation for RPython , 2014 .

[34]  Mikael Pettersson A Compiler for Natural Semantics , 1996, CC.

[35]  Gilles Kahn,et al.  Natural Semantics , 1987, STACS.

[36]  Andrew W. Appel,et al.  Modern Compiler Implementation in ML , 1997 .

[37]  Stéphane Ducasse,et al.  Zero-overhead metaprogramming: reflection and metaobject protocols fast and without compromises , 2015, PLDI.