A modular approach to on-stack replacement in LLVM

On-stack replacement (OSR) is a technique that allows a virtual machine to interrupt running code during the execution of a function/method, to re-optimize the function on-the-fly using an optimizing JIT compiler, and then to resume the interrupted function at the point and state at which it was interrupted. OSR is particularly useful for programs with potentially long-running loops, as it allows dynamic optimization of those loops as soon as they become hot. This paper presents a modular approach to implementing OSR for the LLVM compiler infrastructure. This is an important step forward because LLVM is gaining popular support, and adding the OSR capability allows compiler developers to develop new dynamic techniques. In particular, it will enable more sophisticated LLVM-based JIT compiler approaches. Indeed, other compiler/VM developers can use our approach because it is a clean modular addition to the standard LLVM distribution. Further, our approach is defined completely at the LLVM-IR level and thus does not require any modifications to the target code generation. The OSR implementation can be used by different compilers to support a variety of dynamic optimizations. As a demonstration of our OSR approach, we have used it to support dynamic inlining in McVM. McVM is a virtual machine for MATLAB which uses a LLVM-based JIT compiler. MATLAB is a popular dynamic language for scientific and engineering applications that typically manipulate large matrices and often contain long-running loops, and is thus an ideal target for dynamic JIT compilation and OSRs. Using our McVM example, we demonstrate reasonable overheads for our benchmark set, and performance improvements when using it to perform dynamic inlining.

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

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

[3]  Craig Chambers,et al.  Making pure object-oriented languages practical , 1991, OOPSLA '91.

[4]  David Grove,et al.  Adaptive online context-sensitive inlining , 2003, International Symposium on Code Generation and Optimization, 2003. CGO 2003..

[5]  David A. Padua,et al.  FALCON: A MATLAB Interactive Restructuring Compiler , 1995, LCPC.

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

[7]  James M. Stichnoth,et al.  Practicing JUDO: Java under dynamic optimizations , 2000, PLDI '00.

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

[9]  Christof Fetzer,et al.  Prospect: a compiler framework for speculative parallelization , 2010, CGO '10.

[10]  Urs Hijlzle A Third-Generation SELF Implementation: Reconciling Responsiveness with Performance , 1998 .

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

[12]  J. E. Glynn,et al.  Numerical Recipes: The Art of Scientific Computing , 1989 .

[13]  Toshiaki Yasue,et al.  An Empirical Study of Method In-lining for a Java Just-in-Time Compiler , 2002, Java Virtual Machine Research and Technology Symposium.

[14]  Stephen J. Fink,et al.  Design, implementation and evaluation of adaptive recompilation with on-stack replacement , 2003, International Symposium on Code Generation and Optimization, 2003. CGO 2003..

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

[16]  Jim Euchner Design , 2014, Catalysis from A to Z.

[17]  Cleve B. Moler,et al.  Numerical computing with MATLAB , 2004 .

[18]  Matthew Arnold,et al.  Online feedback-directed optimization of Java , 2002, OOPSLA '02.

[19]  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..

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

[21]  Mauricio J. Serrano,et al.  The starjit compiler: a dynamic compiler for managed runtime environments , 2003 .

[22]  Chandra Krintz,et al.  Efficient and General On-Stack Replacement for Aggressive Program Specialization , 2006, Software Engineering Research and Practice.