skip to main content
research-article
Free Access

An Abstract Interpretation-Based Model of Tracing Just-in-Time Compilation

Published:04 January 2016Publication History
Skip Abstract Section

Abstract

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 to detect so-called hot paths, that is, the most frequently executed program paths. Then, hot paths are optimized by exploiting some information on program stores that is available and therefore gathered at runtime. The result is a residual program where the optimized hot paths are guarded by sufficient conditions ensuring some form of equivalence with the original program. The residual program is persistently mutated during its execution, for example, to add new optimized hot paths or to merge existing paths. Tracing compilation is thus fundamentally different from traditional static compilation. Nevertheless, despite the practical success of tracing compilation, very little is known about its theoretical foundations. We provide a formal model of tracing compilation of programs using abstract interpretation. The monitoring phase (viz., hot path detection) corresponds to an abstraction of the trace semantics of the program that captures the most frequent occurrences of sequences of program points together with an abstraction of their corresponding stores, for example, a type environment. The optimization phase (viz., residual program generation) 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 along hot paths and to prove them correct. We instantiate it to prove the correctness of dynamic type specialization and constant variable folding. We show that our framework is more general than the model of tracing compilation introduced by Guo and Palsberg [2011], which is 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.

References

  1. K. Adams, J. Evans, B. Maher, G. Ottoni, A. Paroski, B. Simmers, E. Smith, and O. Yamauchi. 2014. The Hiphop virtual machine. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages (OOPSLA’14). ACM, New York, NY, 777--790. DOI:http://dx.doi.org/10.1145/2660193.2660199 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. V. Bala, E. Duesterwald, and S. Banerjia. 2000. Dynamo: A transparent dynamic optimization system. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI’00). ACM, New York, NY, 1--12. DOI:http://dx.doi.org/10.1145/349299.349303 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. R. Barbuti, N. De Francesco, A. Santone, and G. Vaglini. 1999. Abstract interpretation of trace semantics for concurrent calculi. Inform. Process. Lett. 70, 2 (1999), 69--78. DOI:http://dx.doi.org/10.1016/S0020-0190(99)00042-3 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. S. Bauman, R. Bolz, C. F. Hirschfeld, V. Krilichev, T. Pape, J. G. Siek, and S. Tobin-Hochstadt. 2015. Pycket: A tracing JIT for a functional language. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP’15). ACM, New York, NY, 22--34. DOI:http://dx.doi.org/10.1145/2784731.2784740 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. M. Bebenita, F. Brandner, M. Fahndrich, F. Logozzo, W. Schulte, N. Tillmann, and H. Venter. 2010. SPUR: A trace-based JIT compiler for CIL. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA’10). ACM, New York, NY, 708--725. DOI:http://dx.doi.org/10.1145/1869459.1869517 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. I. Böhm, T. J. K. Edler von Koch, S. C. Kyle, B. Franke, and N. Topham. 2011. 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’11). ACM, New York, NY, 74--85. DOI:http://dx.doi.org/10.1145/1993498.1993508 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. C. F. Bolz, A. Cuni, M. Fijałkowski, M. Leuschel, S. Pedroni, and A. Rigo. 2011. Allocation removal by partial evaluation in a tracing JIT. In Proceedings of the 20th ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation (PEPM’11). ACM, ACM, New York, NY, 43--52. DOI:http://dx.doi.org/10.1145/1929501.1929508 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. C. F. Bolz, A. Cuni, M. Fijalkowski, and A. Rigo. 2009. Tracing the meta-level: PyPy’s tracing JIT compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS’09). ACM, New York, NY, 18--25. DOI:http://dx.doi.org/10.1145/1565824.1565827 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. C. Colby and P. Lee. 1996. Trace-based program analysis. In Proceedings of the 23rd ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL’96). ACM, New York, NY, 195--207. DOI:http://dx.doi.org/10.1145/237721.237776 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. P. Cousot. 1997. Constructive design of a hierarchy of semantics of a transition system by abstract interpretation (Extended Abstract). Electron. Notes Theor. Comput. Sci. 6, 0 (1997), 77--102. DOI:http://dx.doi.org/10.1016/S1571-0661(05)80168-9. Proceedings of the 13th Annual Conference on Mathematical Foundations of Progamming Semantics (MFPS XIII).Google ScholarGoogle ScholarCross RefCross Ref
  11. P. Cousot. 2002. Constructive design of a hierarchy of semantics of a transition system by abstract interpretation. Theor. Comput. Sci. 277, 1--2 (2002), 47--103. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. Cousot and R. Cousot. 1977. 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’77). ACM, New York, NY, 238--252. DOI:http://dx.doi.org/10.1145/512950.512973 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. P. Cousot and R. Cousot. 1979. Systematic design of program analysis frameworks. In Proceedings of the 6th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL’79). ACM, New York, NY, 269--282. DOI:http://dx.doi.org/10.1145/567752.567778 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. Cousot and R. Cousot. 2002. Systematic design of program transformation frameworks by abstract interpretation. In Proceedings of the 29th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL’02). ACM, New York, NY, 178--190. DOI:http://dx.doi.org/10.1145/503272.503290 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Dissegna, F. Logozzo, and F. Ranzato. 2014. Tracing compilation by abstract interpretation. In Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’14). ACM, New York, NY, 47--59. DOI:http://dx.doi.org/10.1145/2535838.2535866 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Ecma International. 2015. Standard ECMA-262, ECMAScript 2015 Language Specification (6th ed.). Retrieved from http://www.ecma-international.org/ecma-262/6.0.Google ScholarGoogle Scholar
  17. Facebook Inc. 2013. The HipHop Virtual Machine. (Oct. 2013). https://www.facebook.com/hhvm.Google ScholarGoogle Scholar
  18. 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. 2009. 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’09). ACM, New York, NY, 465--478. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. A. Gal, C. W. Probst, and M. Franz. 2006. HotPathVM: An effective JIT compiler for resource-constrained devices. In Proceedings of the 2nd International Conference on Virtual Execution Environments (VEE’06). ACM, New York, NY, 144--153. DOI:http://dx.doi.org/10.1145/1542476.1542528 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Google Inc. 2010. A New Crankshaft for V8. (Dec. 2010). The Chromium Blog. http://blog.chromium.org/2010/12/new-crankshaft-for-v8.html.Google ScholarGoogle Scholar
  21. S. Guo and J. Palsberg. 2011. The essence of compiling with traces. In Proceedings of the 38th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL 2011). ACM, New York, NY, 563--574. DOI:http://dx.doi.org/10.1145/1926385.1926450 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. M. Handjieva and S. Tzolovski. 1998. Refining static analyses by trace-based partitioning using control flow. In Proceedings of the 5th International Static Analysis Symposium (SAS’98), Lecture Notes in Computer Science, Vol. 1503. Springer, Berlin, 200--214. DOI:http://dx.doi.org/10.1007/3-540-49727-7_12Google ScholarGoogle Scholar
  23. C. Häubl and H. Mössenböck. 2011. Trace-based compilation for the Java HotSpot virtual machine. In Proceedings of the 9th International Conference on Principles and Practice of Programming in Java (PPPJ’11). ACM, New York, NY, 129--138. DOI:http://dx.doi.org/10.1145/2093157.2093176 Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. C. Häubl, C. Wimmer, and H. Mössenböck. 2014. Trace transitioning and exception handling in a trace-based JIT compiler for Java. ACM Trans. Archit. Code Optim. 11, 1, Article 6 (Feb. 2014), 26 pages. DOI:http://dx.doi.org/10.1145/2579673 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. H. Inoue, H. Hayashizaki, Peng Wu, and T. Nakatani. 2011. A trace-based Java JIT compiler retrofitted from a method-based compiler. In Proceedings of the 9th Annual IEEE/ACM International Symposium on Code Generation and Optimization (CGO’11). IEEE Computer Society, Washington, DC, 246--256. DOI:http://dx.doi.org/10.1109/CGO.2011.5764692 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. F. Logozzo. 2009. Class invariants as abstract interpretation of trace semantics. Comput. Lang., Syst. Struct. 35, 2 (2009), 100--142. DOI:http://dx.doi.org/10.1016/j.cl.2005.01.001 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. R. Milner. 1995. Communication and Concurrency. Prentice Hall, Englewood Cliffs, NJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Mozilla Foundation. 2010. TraceMonkey. (Oct. 2010). MozillaWiki. https://wiki.mozilla.org/JavaScript:TraceMonkey.Google ScholarGoogle Scholar
  29. Mozilla Foundation. 2013. IonMonkey. (May 2013). MozillaWiki. https://wiki.mozilla.org/IonMonkey.Google ScholarGoogle Scholar
  30. M. Pall. 2005. The LuaJIT Project. (2005). http://luajit.org.Google ScholarGoogle Scholar
  31. X. Rival. 2004. Symbolic transfer function-based approaches to certified compilation. In Proceedings of the 31st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages(POPL’04). ACM, New York, NY, 1--13. DOI:http://dx.doi.org/10.1145/964001.964002 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. X. Rival and L. Mauborgne. 2007. The trace partitioning abstract domain. ACM Trans. Program. Lang. Syst. 29, 5, Article 26 (2007), 51 pages. DOI:http://dx.doi.org/10.1145/1275497.1275501 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. T. Schilling. 2013. Trace-Based Just-In-Time Compilation for Lazy Functional Programming Languages. Ph.D. dissertation. University of Kent, UK.Google ScholarGoogle Scholar
  34. D. A. Schmidt. 1998. Trace-based abstract interpretation of operational semantics. Lisp Symb. Comput. 10, 3 (1998), 237--271. DOI:http://dx.doi.org/10.1023/A:1007734417713 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. F. Spoto and T. Jensen. 2003. Class analyses as abstract interpretations of trace semantics. ACM Trans. Program. Lang. Syst. 25, 5 (2003), 578--630. DOI:http://dx.doi.org/10.1145/937563.937565 Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. M. N. Wegman and F. K. Zadeck. 1991. Constant propagation with conditional branches. ACM Trans. Program. Lang. Syst. 13, 2 (1991), 181--210. DOI:http://dx.doi.org/10.1145/103135.103136 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. An Abstract Interpretation-Based Model of Tracing Just-in-Time Compilation

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM Transactions on Programming Languages and Systems
          ACM Transactions on Programming Languages and Systems  Volume 38, Issue 2
          January 2016
          212 pages
          ISSN:0164-0925
          EISSN:1558-4593
          DOI:10.1145/2866613
          Issue’s Table of Contents

          Copyright © 2016 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 4 January 2016
          • Accepted: 1 October 2015
          • Revised: 1 July 2015
          • Received: 1 November 2014
          Published in toplas Volume 38, Issue 2

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article
          • Research
          • Refereed
        • Article Metrics

          • Downloads (Last 12 months)31
          • Downloads (Last 6 weeks)6

          Other Metrics

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!