Static Basic Block Versioning

Authors Olivier Melançon , Marc Feeley , Manuel Serrano



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2024.28.pdf
  • Filesize: 2.54 MB
  • 27 pages

Document Identifiers

Author Details

Olivier Melançon
  • Université de Montréal, Canada
Marc Feeley
  • Université de Montréal, Canada
Manuel Serrano
  • Inria/UCA, Inria Sophia Méditerranée, Sophia Antipolis, France

Cite AsGet BibTex

Olivier Melançon, Marc Feeley, and Manuel Serrano. Static Basic Block Versioning. In 38th European Conference on Object-Oriented Programming (ECOOP 2024). Leibniz International Proceedings in Informatics (LIPIcs), Volume 313, pp. 28:1-28:27, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2024)
https://doi.org/10.4230/LIPIcs.ECOOP.2024.28

Abstract

Basic Block Versioning (BBV) is a compilation technique for optimizing program execution. It consists in duplicating and specializing basic blocks of code according to the execution contexts of the blocks, up to a version limit. BBV has been used in Just-In-Time (JIT) compilers for reducing the dynamic type checks of dynamic languages. Our work revisits the BBV technique to adapt it to Ahead-of-Time (AOT) compilation. This Static BBV (SBBV) raises new challenges, most importantly how to ensure the convergence of the algorithm when the specializations of the basic blocks are not based on profiled variable values and how to select the good specialization contexts. SBBV opens new opportunities for more precise optimizations as the compiler can explore multiple versions and only keep those within the version limit that yield better generated code. In this paper, we present the main SBBV algorithm and its use to optimize the dynamic type checks, array bound checks, and mixed-type arithmetic operators often found in dynamic languages. We have implemented SBBV in two AOT compilers for the Scheme programming language that we have used to evaluate the technique’s effectiveness. On a suite of benchmarks, we have observed that even with a low limit of 2 versions, SBBV greatly reduces the number of dynamic type tests (by 54% and 62% on average) and accelerates the execution time (by about 10% on average). Previous work has needed a higher version limit to achieve a similar level of optimization. We also observe a small impact on compilation time and code size (a decrease in some cases).

Subject Classification

ACM Subject Classification
  • Software and its engineering → Just-in-time compilers
  • Software and its engineering → Source code generation
  • Software and its engineering → Object oriented languages
  • Software and its engineering → Functional languages
Keywords
  • Compiler
  • Ahead-of-Time Compilation
  • Optimization
  • Dynamic Languages

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. R7RS benchmarks. https://github.com/ecraven/r7rs-benchmarks, April 2024.
  2. David F. Bacon, Susan L. Graham, and Oliver J. Sharp. Compiler transformations for high-performance computing. ACM Comput. Surv., 26(4):345-420, 1994. URL: https://doi.org/10.1145/197405.197406.
  3. Jeff Bezanson, Jiahao Chen, Benjamin Chung, Stefan Karpinski, Viral B. Shah, Jan Vitek, and Lionel Zoubritzky. Julia: dynamism and performance reconciled by design. Proc. ACM Program. Lang., 2(OOPSLA):120:1-120:23, 2018. URL: https://doi.org/10.1145/3276490.
  4. Craig Chambers and David M. Ungar. Customization: optimizing compiler technology for SELF, a dynamically-typed object-oriented programming language. In Richard L. Wexelblat, editor, Proceedings of the ACM SIGPLAN'89 Conference on Programming Language Design and Implementation (PLDI), Portland, Oregon, USA, June 21-23, 1989, pages 146-160. ACM, 1989. URL: https://doi.org/10.1145/73141.74831.
  5. Maxime Chevalier-Boisvert and Marc Feeley. Simple and effective type check removal through lazy basic block versioning. In John Tang Boyland, editor, 29th European Conference on Object-Oriented Programming, ECOOP 2015, July 5-10, 2015, Prague, Czech Republic, volume 37 of LIPIcs, pages 101-123. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2015. URL: https://doi.org/10.4230/LIPICS.ECOOP.2015.101.
  6. Maxime Chevalier-Boisvert and Marc Feeley. Interprocedural type specialization of JavaScript programs without type analysis. In Shriram Krishnamurthi and Benjamin S. Lerner, editors, 30th European Conference on Object-Oriented Programming, ECOOP 2016, July 18-22, 2016, Rome, Italy, volume 56 of LIPIcs, pages 7:1-7:24. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2016. URL: https://doi.org/10.4230/LIPICS.ECOOP.2016.7.
  7. Maxime Chevalier-Boisvert, Noah Gibbs, Jean Boussier, Si Xing (Alan) Wu, Aaron Patterson, Kevin Newton, and John Hawthorn. YJIT: a basic block versioning JIT compiler for CRuby, pages 25-32. ACM, 2021. URL: https://doi.org/10.1145/3486606.3486781.
  8. Maxime Chevalier-Boisvert, Takashi Kokubun, Noah Gibbs, Si Xing (Alan) Wu, Aaron Patterson, and Jemma Issroff. Evaluating YJIT’s performance in a production context: a pragmatic approach. In Rodrigo Bruno and Eliot Moss, editors, Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes, MPLR 2023, Cascais, Portugal, 22 October 2023, pages 20-33. ACM, 2023. URL: https://doi.org/10.1145/3617651.3622982.
  9. Keith D. Cooper, Mary W. Hall, and Ken Kennedy. A methodology for procedure cloning. Comput. Lang., 19(2):105-117, 1993. URL: https://doi.org/10.1016/0096-0551(93)90005-L.
  10. Patrick Cousot and Radhia Cousot. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Robert M. Graham, Michael A. Harrison, and Ravi Sethi, editors, Conference Record of the Fourth ACM Symposium on Principles of Programming Languages, Los Angeles, California, USA, January 1977, pages 238-252. ACM, 1977. URL: https://doi.org/10.1145/512950.512973.
  11. Patrick Cousot and Radhia Cousot. Static determination of dynamic properties of generalized type unions. In David B. Wortman, editor, Proceedings of an ACM Conference on Language Design for Reliable Software (LDRS), Raleigh, North Carolina, USA, March 28-30, 1977, pages 77-94. ACM, 1977. URL: https://doi.org/10.1145/800022.808314.
  12. Iulian Dragos and Martin Odersky. Compiling generics through user-directed type specialization. In Ian Rogers, editor, Proceedings of the 4th workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems, ICOOOLPS 2009, Genova, Italy, July 6, 2009, pages 42-47. ACM, 2009. URL: https://doi.org/10.1145/1565824.1565830.
  13. Matt D'Souza, James You, Ondrej Lhoták, and Aleksandar Prokopec. TASTyTruffle: Just-in-time specialization of parametric polymorphism. Proc. ACM Program. Lang., 7(OOPSLA2):1561-1588, 2023. URL: https://doi.org/10.1145/3622853.
  14. Shimon Even and Yossi Shiloach. An on-line edge-deletion problem. J. ACM, 28(1):1-4, 1981. URL: https://doi.org/10.1145/322234.322235.
  15. Olivier Flückiger, Guido Chari, Ming-Ho Yee, Jan Jecmen, Jakob Hain, and Jan Vitek. Contextual dispatch for function specialization. Proc. ACM Program. Lang., 4(OOPSLA):220:1-220:24, 2020. URL: https://doi.org/10.1145/3428288.
  16. ECMA International. Standard ECMA-262 - ECMAScript language specification, June 2015. 6th edition. URL: http://www.ecma-international.org/ecma-262/6.0/.
  17. Richard Kelsey, William D. Clinger, and Jonathan Rees. Revised^5 report on the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9):26-76, 1998. URL: https://doi.org/10.1145/290229.290234.
  18. David Leopoldseder, Lukas Stadler, Thomas Würthinger, Josef Eisl, Doug Simon, and Hanspeter Mössenböck. Dominance-based duplication simulation (DBDS): code duplication to enable compiler optimizations. In Jens Knoop, Markus Schordan, Teresa Johnson, and Michael F. P. O'Boyle, editors, Proceedings of the 2018 International Symposium on Code Generation and Optimization, CGO 2018, Vösendorf / Vienna, Austria, February 24-28, 2018, pages 126-137. ACM, 2018. URL: https://doi.org/10.1145/3168811.
  19. Manuel Serrano. Bigloo. http://www-sop.inria.fr/indes/fp/Bigloo/, 2024.
  20. Marc Feeley. Gambit. https://gambitscheme.org, 2024.
  21. Meetesh Kalpesh Mehta, Sebastián Krynski, Hugo Musso Gualandi, Manas Thakur, and Jan Vitek. Reusing just-in-time compiled code. Proc. ACM Program. Lang., 7(OOPSLA2):1176-1197, 2023. URL: https://doi.org/10.1145/3622839.
  22. Olivier Melançon, Marc Feeley, and Manuel Serrano. An executable semantics for faster development of optimizing Python compilers. In João Saraiva, Thomas Degueule, and Elizabeth Scott, editors, Proceedings of the 16th ACM SIGPLAN International Conference on Software Language Engineering, SLE 2023, Cascais, Portugal, October 23-24, 2023, pages 15-28. ACM, 2023. URL: https://doi.org/10.1145/3623476.3623529.
  23. Ramon E. Moore, R. Baker Kearfott, and Michael J. Cloud. Introduction to Interval Analysis. SIAM, 2009. URL: https://doi.org/10.1137/1.9780898717716.
  24. Frank Mueller and David B. Whalley. Avoiding conditional branches by code replication. In David W. Wall, editor, Proceedings of the ACM SIGPLAN'95 Conference on Programming Language Design and Implementation (PLDI), La Jolla, California, USA, June 18-21, 1995, pages 56-66. ACM, 1995. URL: https://doi.org/10.1145/207110.207116.
  25. PLT Inc. Racket. https://racket-lang.org/, 2024.
  26. R. Kent Dybvig. Chez Scheme. https://www.scheme.com/, 2024.
  27. Baptiste Saleil and Marc Feeley. Interprocedural specialization of higher-order dynamic languages without static analysis. In Peter Müller, editor, 31st European Conference on Object-Oriented Programming, ECOOP 2017, June 19-23, 2017, Barcelona, Spain, volume 74 of LIPIcs, pages 23:1-23:23. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2017. URL: https://doi.org/10.4230/LIPICS.ECOOP.2017.23.
  28. Baptiste Saleil and Marc Feeley. Building JIT compilers for dynamic languages with low development effort. In Stephen Kell and Stefan Marr, editors, Proceedings of the 10th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages, VMIL@SPLASH 2018, Boston, MA, USA, November 4, 2018, pages 36-46. ACM, 2018. URL: https://doi.org/10.1145/3281287.3281294.
  29. Manuel Serrano. JavaScript AOT compilation. In Tim Felgentreff, editor, Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic Languages, DLS 2018, Boston, MA, USA, November 6, 2018, pages 50-63. ACM, 2018. URL: https://doi.org/10.1145/3276945.3276950.
  30. Manuel Serrano. Of JavaScript AOT compilation performance. Proc. ACM Program. Lang., 5(ICFP):1-30, 2021. URL: https://doi.org/10.1145/3473575.
  31. Manuel Serrano and Marc Feeley. Property caches revisited. In José Nelson Amaral and Milind Kulkarni, editors, Proceedings of the 28th International Conference on Compiler Construction, CC 2019, Washington, DC, USA, February 16-17, 2019, pages 99-110. ACM, 2019. URL: https://doi.org/10.1145/3302516.3307344.
  32. Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In George C. Necula and Philip Wadler, editors, Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, San Francisco, California, USA, January 7-12, 2008, pages 395-406. ACM, 2008. URL: https://doi.org/10.1145/1328438.1328486.
  33. Sam Tobin-Hochstadt and Matthias Felleisen. Logical types for untyped languages. In Paul Hudak and Stephanie Weirich, editors, Proceeding of the 15th ACM SIGPLAN international conference on Functional programming, ICFP 2010, Baltimore, Maryland, USA, September 27-29, 2010, pages 117-128. ACM, 2010. URL: https://doi.org/10.1145/1863543.1863561.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail