Abstract
High-performance dynamic language implementations make heavy use of speculative optimizations to achieve speeds close to statically compiled languages. These optimizations are typically performed by a just-in-time compiler that generates code under a set of assumptions about the state of the program and its environment. In certain cases, a program may execute code compiled under assumptions that are no longer valid. The implementation must then deoptimize the program on-the-fly; this entails finding semantically equivalent code that does not rely on invalid assumptions, translating program state to that expected by the target code, and transferring control. This paper looks at the interaction between optimization and deoptimization, and shows that reasoning about speculation is surprisingly easy when assumptions are made explicit in the program representation. This insight is demonstrated on a compiler intermediate representation, named sourir, modeled after the high-level representation for a dynamic language. Traditional compiler optimizations such as constant folding, unreachable code elimination, and function inlining are shown to be correct in the presence of assumptions. Furthermore, the paper establishes the correctness of compiler transformations specific to deoptimization: namely unrestricted deoptimization, predicate hoisting, and assume composition.
Supplemental Material
- Vasanth Bala, Evelyn Duesterwald, and Sanjeev Banerjia. 2000. Dynamo: A Transparent Dynamic Optimization System. In Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Michael Bebenita, Florian Brandner, Manuel Fahndrich, Francesco Logozzo, Wolfram Schulte, Nikolai Tillmann, and Herman Venter. 2010. SP UR: A Trace-based JIT Compiler for CIL. In Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA). Google Scholar
Digital Library
- Clément Béra, Eliot Miranda, Marcus Denker, and Stéphane Ducasse. 2016. Practical validation of bytecode to bytecode JIT compiler dynamic deoptimization. Journal of Object Technology (JOT) 15, 2 (2016). Google Scholar
Cross Ref
- Project Chromium. 2017. V8 JavaScript Engine. https://chromium.googlesource.com/v8/v8.git .Google Scholar
- Daniele Cono D’Elia and Camil Demetrescu. 2016. Flexible on-stack replacement in LLVM. In Code Generation and Optimization (CGO). Google Scholar
Digital Library
- Stefano Dissegna, Francesco Logozzo, and Francesco Ranzato. 2014. Tracing Compilation by Abstract Interpretation. In Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Gilles Duboscq, Thomas Würthinger, and Hanspeter Mössenböck. 2014. Speculation without regret: reducing deoptimization meta-data in the Graal compiler. In Principles and Practices of Programming on the Java Platform (PPPJ). Google Scholar
Digital Library
- Gilles Duboscq, Thomas Würthinger, Lukas Stadler, Christian Wimmer, Doug Simon, and Hanspeter Mössenböck. 2013. An Intermediate Representation for Speculative Optimizations in a Dynamic Compiler. In Virtual Machines and Intermediate Languages (VMIL). Google Scholar
Digital Library
- Stephen J. Fink and Feng Qian. 2003. Design, Implementation and Evaluation of Adaptive Recompilation with On-stack Replacement. In Code Generation and Optimization (CGO). Google Scholar
Cross Ref
- Andreas Gal, Brendan Eich, Mike Shaver, David Anderson, David Mandelin, Mohammad R. Haghighat, Blake Kaplan, Graydon Hoare, Boris Zbarsky, Jason Orendorff, Jesse Ruderman, Edwin W. Smith, Rick Reitmaier, Michael Bebenita, Mason Chang, and Michael Franz. 2009. Trace-based Just-in-time Type Specialization for Dynamic Languages. In Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Shu-yu Guo and Jens Palsberg. 2011. The Essence of Compiling with Traces. In Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Urs Hölzle, Craig Chambers, and David Ungar. 1992. Debugging Optimized Code with Dynamic Deoptimization. In Programming Language Design and Implementation (PLDI). Google Scholar
Digital Library
- Kazuaki Ishizaki, Motohiro Kawahito, Toshiaki Yasue, Hideaki Komatsu, and Toshio Nakatani. 2000. A Study of Devirtualization Techniques for a Java Just-In-Time Compiler. In Object-oriented Programming Systems, Language, and Applications (OOPSLA). Google Scholar
Digital Library
- Gary A. Kildall. 1973. A Unified Approach to Global Program Optimization. In Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Xavier Leroy and Sandrine Blazy. 2008. Formal verification of a C-like memory model and its uses for verifying program transformations. Journal of Automated Reasoning 41, 1 (2008). Google Scholar
Digital Library
- Magnus O. Myreen. 2010. Verified Just-in-time Compiler on x86. In Principles of Programming Languages (POPL). Google Scholar
Digital Library
- Rei Odaira and Kei Hiraki. 2005. Sentinel PRE: Hoisting Beyond Exception Dependency with Dynamic Deoptimization. In Code Generation and Optimization (CGO). Google Scholar
Digital Library
- Michael Paleczny, Christopher Vick, and Cliff Click. 2001. The Java Hotspot Server Compiler. In Java Virtual Machine Research and Technology (JVM). http://www.usenix.org/events/jvm01/full_papers/paleczny/paleczny.pdfGoogle Scholar
- Amr Sabry and Matthias Felleisen. 1992. Reasoning About Programs in Continuation-passing Style. In LISP and Functional Programming (LFP). Google Scholar
Digital Library
- David Schneider and Carl Friedrich Bolz. 2012. The efficient handling of guards in the design of RPython’s tracing JIT. In Workshop on Virtual Machines and Intermediate Languages (VMIL). Google Scholar
Digital Library
- Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, and Rok Strniša. 2007. Ott: Effective Tool Support for the Working Semanticist. In International Conference on Functional Programming (ICFP). Google Scholar
Digital Library
- Sunil Soman and Chandra Krintz. 2006. Efficient and General On-Stack Replacement for Aggressive Program Specialization. In Software Engineering Research and Practice (SERP).Google Scholar
- Kunshan Wang, Yi Lin, Stephen M. Blackburn, Michael Norrish, and Antony L. Hosking. 2015. Draining the Swamp: Micro Virtual Machines as Solid Foundation for Language Development. In Summit on Advances in Programming Languages (SNAPL), Vol. 32. Google Scholar
Cross Ref
- Yudi Zheng, Lubomír Bulej, and Walter Binder. 2017. An Empirical Study on Deoptimization in the Graal Compiler. In European Conference on Object-Oriented Programming (ECOOP). Google Scholar
Cross Ref
Index Terms
Correctness of speculative optimizations with dynamic deoptimization
Recommendations
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. ...
An approach to compiler correctness
International Conference on Reliable SoftwareThis paper is a preliminary report on an experiment in applying Floyd's method of inductive assertions to the compiler correctness problem. Practical postfix translators are considered, and the semantics of source and object languages are characterized ...
An approach to compiler correctness
Proceedings of the international conference on Reliable softwareThis paper is a preliminary report on an experiment in applying Floyd's method of inductive assertions to the compiler correctness problem. Practical postfix translators are considered, and the semantics of source and object languages are characterized ...






Comments