Formally verified speculation and deoptimization in a JIT compiler

Just-in-time compilers for dynamic languages routinely generate code under assumptions that may be invalidated at run-time, this allows for specialization of program code to the common case in order to avoid unnecessary overheads due to uncommon cases. This form of software speculation requires support for deoptimization when some of the assumptions fail to hold. This paper presents a model just-in-time compiler with an intermediate representation that explicits the synchronization points used for deoptimization and the assumptions made by the compiler's speculation. We also present several common compiler optimizations that can leverage speculation to generate improved code. The optimizations are proved correct with the help of a proof assistant. While our work stops short of proving native code generation, we demonstrate how one could use the verified optimization to obtain significant speed ups in an end-to-end setting.

[1]  Jan Vitek,et al.  R melts brains: an IR for first-class environments and lazy effectful arguments , 2019, DLS.

[2]  Alon Zakai,et al.  Bringing the web up to speed with WebAssembly , 2017, PLDI.

[3]  Jan Vitek,et al.  Correctness of speculative optimizations with dynamic deoptimization , 2017, Proc. ACM Program. Lang..

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

[5]  Xavier Leroy,et al.  A Formally Verified Compiler Back-end , 2009, Journal of Automated Reasoning.

[6]  Stéphane Ducasse,et al.  Practical Validation of Bytecode to Bytecode JIT Compiler Dynamic Deoptimization , 2016, J. Object Technol..

[7]  Camil Demetrescu,et al.  Flexible on-stack replacement in LLVM , 2016, 2016 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

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

[9]  Suresh Jagannathan,et al.  CompCertTSO: A Verified Compiler for Relaxed-Memory Concurrency , 2013, JACM.

[10]  Magnus O. Myreen Verified just-in-time compiler on x86 , 2010, POPL '10.

[11]  Minki Cho,et al.  CompCertM: CompCert with C-assembly linking and lightweight modular verification , 2019, Proc. ACM Program. Lang..

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

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

[14]  Laurie J. Hendren,et al.  A modular approach to on-stack replacement in LLVM , 2013, VEE '13.

[15]  Jens Palsberg,et al.  The essence of compiling with traces , 2011, POPL '11.

[16]  John Aycock,et al.  A brief history of just-in-time , 2003, CSUR.

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

[18]  Xavier Leroy,et al.  Formal certification of a compiler back-end or: programming a compiler with a proof assistant , 2006, POPL '06.