Practical partial evaluation for high-performance dynamic language runtimes

Most 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 interpreter. The interpreter performs specializations, e.g., augments the interpreted program with type information and profiling information. Compiled code is derived automatically using partial evaluation while incorporating these specializations. This makes partial evaluation practical in the context of dynamic languages: It reduces the size of the compiled code while still compiling all parts of an operation that are relevant for a particular program. When a speculation fails, execution transfers back to the interpreter, the program re-specializes in the interpreter, and later partial evaluation again transforms the new state of the interpreter to compiled code. We evaluate our approach by comparing our implementations of JavaScript, Ruby, and R with best-in-class specialized production implementations. Our general-purpose compilation system is competitive with production systems even when they have been heavily optimized for the one language they support. For our set of benchmarks, our speedup relative to the V8 JavaScript VM is 0.83x, relative to JRuby is 3.8x, and relative to GNU R is 5x.

[1]  Hanspeter Mössenböck,et al.  Graal IR : An Extensible Declarative Intermediate Representation , 2013 .

[2]  Michael Leuschel,et al.  Towards Just-In-Time Partial Evaluation of Prolog , 2009, LOPSTR.

[3]  Ole Agesen,et al.  Mixed-mode Bytecode Execution , 2000 .

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

[5]  Carl Friedrich Bolz,et al.  How to not write Virtual Machines for Dynamic Languages , 2007 .

[6]  Hanspeter Mössenböck,et al.  An object storage model for the truffle language implementation framework , 2014, PPPJ '14.

[7]  Hanspeter Mössenböck,et al.  Run-Time Support for Optimizations Based on Escape Analysis , 2007, International Symposium on Code Generation and Optimization (CGO'07).

[8]  Matthew Arnold,et al.  Adaptive optimization in the Jalapeño JVM , 2000, OOPSLA '00.

[9]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

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

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

[12]  Vojin Jovanovic,et al.  One compiler: deoptimization to optimized code , 2017, CC.

[13]  Akinori Yonezawa,et al.  Supporting objects in run-time bytecode specialization , 2002, ASIA-PEPM '02.

[14]  Michael L. Van de Vanter Building debuggers and other tools: we can "have it all" , 2015, ICOOOLPS@ECOOP.

[15]  Ulrik Pagh Schultz,et al.  Automatic program specialization for Java , 2000, TOPL.

[16]  Michael Leuschel,et al.  Runtime feedback in a meta-tracing JIT for efficient dynamic languages , 2011, ICOOOLPS@ECOOP.

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

[18]  Ian Rogers,et al.  Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems , 2009, ECOOP 2009.

[19]  William R. Cook,et al.  Hybrid partial evaluation , 2011, OOPSLA '11.

[20]  Vivek Sarkar,et al.  The Jikes Research Virtual Machine project: Building an open-source research community , 2005, IBM Syst. J..

[21]  Julia L. Lawall,et al.  VMKit: a substrate for managed runtime environments , 2010, VEE '10.

[22]  David Gregg,et al.  Virtual machine showdown: stack versus registers , 2005, VEE '05.

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

[24]  Cliff Click,et al.  The Java HotSpot Server Compiler , 2001, Java Virtual Machine Research and Technology Symposium.

[25]  Hanspeter Mössenböck,et al.  Partial Escape Analysis and Scalar Replacement for Java , 2014, CGO '14.

[26]  Hanspeter Mössenböck,et al.  High-performance cross-language interoperability in a multi-language runtime , 2015, DLS.

[27]  Hanspeter Mössenböck,et al.  Efficient and thread-safe objects for dynamically-typed languages , 2016, OOPSLA.

[28]  Hanspeter Mössenböck,et al.  An intermediate representation for speculative optimizations in a dynamic compiler , 2013, VMIL '13.

[29]  Chris Seaton AST Specialisation and Partial Evaluation for Easy High-Performance Metaprogramming , 2016 .

[30]  Ulrik Pagh Schultz,et al.  Towards Automatic Specialization of Java Programs , 1999, ECOOP.

[31]  Hanspeter Mössenböck,et al.  Memory-safe Execution of C on a Java VM , 2015, PLAS@ECOOP.

[32]  Hanspeter Mössenböck,et al.  Dynamically composing languages in a modular way: supporting C extensions for dynamic languages , 2015, MODULARITY.

[33]  Akinori Yonezawa,et al.  A portable approach to dynamic optimization in run-time specialization , 2009, New Generation Computing.

[34]  Laurie J. Hendren,et al.  Optimizing Matlab through Just-In-Time Specialization , 2010, CC.

[35]  Hanspeter Mössenböck,et al.  Lazy continuations for Java virtual machines , 2009, PPPJ '09.

[36]  Laurence Tratt,et al.  The impact of meta-tracing on VM design and implementation , 2015, Sci. Comput. Program..

[37]  Hanspeter Mössenböck,et al.  Bringing low-level languages to the JVM: efficient execution of LLVM IR on Truffle , 2016, VMIL@SPLASH.

[38]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

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

[40]  Craig Chambers,et al.  Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches , 1991, ECOOP.

[41]  Craig Chambers,et al.  Debugging optimized code with dynamic deoptimization , 1992, PLDI '92.

[42]  Per Larsen,et al.  An Efficient and Generic Event-based Profiler Framework for Dynamic Languages , 2015, PPPJ.

[43]  Christian Wimmer,et al.  Efficient coroutines for the Java platform , 2010, PPPJ.

[44]  Michael Haupt,et al.  Maxine: An approachable virtual machine for, and in, java , 2013, TACO.

[45]  Adam Welc,et al.  Optimizing R language execution via aggressive speculation , 2016, DLS.

[46]  Urs Hölzle,et al.  A third-generation SELF implementation: reconciling responsiveness with performance , 1994, OOPSLA '94.

[47]  Hanspeter Mössenböck,et al.  TruffleC: dynamic execution of C on a Java virtual machine , 2014, PPPJ.

[48]  Jan Vitek,et al.  Evaluating the Design of the R Language - Objects and Functions for Data Analysis , 2012, ECOOP.

[49]  Kunle Olukotun,et al.  Surgical precision JIT compilers , 2014, PLDI.

[50]  Cliff Click,et al.  The java hotspot TM server compiler , 2001 .

[51]  Christian Wimmer,et al.  Snippets: Taking the High Road to a Low Level , 2015, TACO.

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