Abstract
Tracing just-in-time compilation is a popular compilation schema for the efficient implementation of dynamic languages, which is commonly used for JavaScript, Python, and PHP. It relies on two key ideas. First, it monitors the execution of the program to detect so-called hot paths, i.e., the most frequently executed paths. Then, it uses some store information available at runtime to optimize hot paths. The result is a residual program where the optimized hot paths are guarded by sufficient conditions ensuring the equivalence of the optimized path and the original program. The residual program is persistently mutated during its execution, e.g., to add new optimized paths or to merge existing paths. Tracing compilation is thus fundamentally different than traditional static compilation. Nevertheless, despite the remarkable practical success of tracing compilation, very little is known about its theoretical foundations.
We formalize tracing compilation of programs using abstract interpretation. The monitoring (viz., hot path detection) phase corresponds to an abstraction of the trace semantics that captures the most frequent occurrences of sequences of program points together with an abstraction of their corresponding stores, e.g., a type environment. The optimization (viz., residual program generation) phase corresponds to a transform of the original program that preserves its trace semantics up to a given observation as modeled by some abstraction. We provide a generic framework to express dynamic optimizations and to prove them correct. We instantiate it to prove the correctness of dynamic type specialization. We show that our framework is more general than a recent model of tracing compilation introduced in POPL~2011 by Guo and Palsberg (based on operational bisimulations). In our model we can naturally express hot path reentrance and common optimizations like dead-store elimination, which are either excluded or unsound in Guo and Palsberg's framework.
Supplemental Material
- V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent dynamic optimization system. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2000), pages 1--12, New York, NY, USA, 2000. ACM. Google Scholar
Digital Library
- R. Barbuti, N. De Francesco, A. Santone, and G. Vaglini. Abstract interpretation of trace semantics for concurrent calculi. Information Processing Letters, 70(2):69--78, 1999. Google Scholar
Digital Library
- M. Bebenita, F. Brandner, M. Fahndrich, F. Logozzo, W. Schulte, N. Tillmann, and H. Venter. SPUR: a trace-based JIT compiler for CIL. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA 2010), pages 708--725, New York, NY, USA, 2010. ACM. Google Scholar
Digital Library
- I. Böhm, T.J.K. Edler von Koch, S.C. Kyle, B. Franke, and N. Topham. Generalized just-in-time trace compilation using a parallel task farm in a dynamic binary translator. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2011), pages 74--85, New York, NY, USA, 2011. ACM. Google Scholar
Digital Library
- C.F. Bolz, A. Cuni, M. Fijałkowski, M. Leuschel, S. Pedroni, and A. Rigo. Allocation removal by partial evaluation in a tracing JIT. In Proceedings of the 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM 2011), pages 43--52. ACM, 2011. Google Scholar
Digital Library
- C.F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. Tracing the metalevel: PyPy's tracing JIT compiler. In Proceedings of the 4thWorkshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS 2009), pages 18--25, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- C. Colby and P. Lee. Trace-based program analysis. In Proceedings of the 23rd ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1996), pages 195--207, New York, NY, USA, 1996. ACM. Google Scholar
Digital Library
- P. Cousot. Constructive design of a hierarchy of semantics of a transition system by abstract interpretation (extended abstract). Electronic Notes in Theoretical Computer Science, 6(0):77--102, 1997. Proceedings of the 13th Annual Conference on Mathematical Foundations of Progamming Semantics (MFPS XIII).Google Scholar
Cross Ref
- P. Cousot. Constructive design of a hierarchy of semantics of a transition system by abstract interpretation. Theoretical Computer Science, 277(1-2):47--103, 2002. Google Scholar
Digital Library
- P. Cousot and R. Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1977), pages 238--252, New York, NY, USA, 1977. ACM. Google Scholar
Digital Library
- P. Cousot and R. Cousot. Systematic design of program analysis frameworks. In Proceedings of the 6th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 1979), pages 269--282, New York, NY, USA, 1979. ACM. Google Scholar
Digital Library
- P. Cousot and R. Cousot. Systematic design of program transformation frameworks by abstract interpretation. In Proceedings of the 29th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2002), pages 178--190, New York, NY, USA, 2002. ACM. Google Scholar
Digital Library
- Mozilla Foundation. TraceMonkey. wiki.mozilla.org, October 2010.Google Scholar
- Mozilla Foundation. IonMonkey. wiki.mozilla.org, May 2013.Google Scholar
- A. Gal, B. Eich, M. Shaver, D. Anderson, D. Mandelin, M.R. Haghighat, B. Kaplan, G. Hoare, B. Zbarsky, J. Orendorff, J. Ruderman, E.W. Smith, R. Reitmaier, M. Bebenita, M. Chang, and M. Franz. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the 2009 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2009), pages 465--478, New York, NY, USA, 2009. ACM. Google Scholar
Digital Library
- A. Gal, C.W. Probst, and M. Franz. HotPathVM: an effective JIT compiler for resource-constrained devices. In Proceedings of the 2nd International Conference on Virtual Execution Environments (VEE 2006), pages 144--153. ACM, 2006. Google Scholar
Digital Library
- S. Guo and J. Palsberg. The essence of compiling with traces. In Proceedings of the 38th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2011), pages 563--574, New York, NY, USA, 2011. ACM. Google Scholar
Digital Library
- M. Handjieva and S. Tzolovski. Refining static analyses by tracebased partitioning using control flow. In Proceedings of the 5th International Static Analysis Symposium (SAS 1998), volume 1503 of LNCS, pages 200--214. Springer, 1998.Google Scholar
- Facebook Inc. The HipHop Virtual Machine, Facebook Engineering, December 2011.Google Scholar
- Google Inc. A new crankshaft for V8, The Chromium Blog, December 2010.Google Scholar
- Ecma International. ECMAScript Language Specification. Standard ECMA-262, Edition 5.1, June 2011.Google Scholar
- F. Logozzo. Class invariants as abstract interpretation of trace semantics. Computer Languages, Systems and Structures, 35(2):100--142, 2009. Google Scholar
Digital Library
- R. Milner. Communication and Concurrency. Prentice Hall, 1995. Google Scholar
Digital Library
- M. Pall. The LuaJIT Project. luajit.org, 2005.Google Scholar
- X. Rival. Symbolic transfer function-based approaches to certified compilation. In Proceedings of the 31st ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2004), New York, NY, USA, 2004. ACM. Google Scholar
Digital Library
- X. Rival and L. Mauborgne. The trace partitioning abstract domain. ACM Trans. Program. Lang. Syst., 29(5), 2007. Google Scholar
Digital Library
- D.A. Schmidt. Trace-based abstract interpretation of operational semantics. Lisp Symb. Comput., 10(3):237--271, 1998. Google Scholar
Digital Library
- F. Spoto and T. Jensen. Class analyses as abstract interpretations of trace semantics. ACM Trans. Program. Lang. Syst., 25(5):578--630, 2003. Google Scholar
Digital Library
Index Terms
Tracing compilation by abstract interpretation
Recommendations
Tracing compilation by abstract interpretation
POPL '14: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesTracing just-in-time compilation is a popular compilation schema for the efficient implementation of dynamic languages, which is commonly used for JavaScript, Python, and PHP. It relies on two key ideas. First, it monitors the execution of the program ...
An Abstract Interpretation-Based Model of Tracing Just-in-Time Compilation
Tracing just-in-time compilation is a popular compilation technique for the efficient implementation of dynamic languages, which is commonly used for JavaScript, Python, and PHP. It relies on two key ideas. First, it monitors program execution in order ...
Using Template Haskell for Abstract Interpretation
Metaprogramming consists of writing programs that generate or manipulate other programs. Template Haskell is a recent extension of Haskell, currently implemented in the Glasgow Haskell Compiler, giving support to metaprogramming at compile time. Our aim ...







Comments