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.
Highlights
Efficient traditional static compilation of popular dynamic languages like JavaScript, Python and PHP is very hard if not impossible
Since optimizations rely on that information, the hot path is augmented with guards that check the profiled conditions, such as, for example, variable types
– We provide the first model of tracing compilation based on abstract interpretation of trace semantics of programs
Summary
Efficient traditional static compilation of popular dynamic languages like JavaScript, Python and PHP is very hard if not impossible. Those languages present so many dynamic features which make all traditional static analyses used for program optimization very imprecise. Tracing just-in-time compilation (TJITC) [1, 3,4,5,6, 15, 16, 24] has emerged as a valuable implementation and optimization technique for dynamic languages. The Mozilla Firefox JavaScript engine used to have a tracing engine, TraceMonkey, which has been later substituted by whole-method just-in-time compilation engines (initially JagerMonkey and IonMonkey) [13, 14]
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.