Simple and Effective Type Check Removal through Lazy Basic Block Versioning

Authors Maxime Chevalier-Boisvert, Marc Feeley



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2015.101.pdf
  • Filesize: 0.86 MB
  • 23 pages

Document Identifiers

Author Details

Maxime Chevalier-Boisvert
Marc Feeley

Cite AsGet BibTex

Maxime Chevalier-Boisvert and Marc Feeley. Simple and Effective Type Check Removal through Lazy Basic Block Versioning. In 29th European Conference on Object-Oriented Programming (ECOOP 2015). Leibniz International Proceedings in Informatics (LIPIcs), Volume 37, pp. 101-123, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2015)
https://doi.org/10.4230/LIPIcs.ECOOP.2015.101

Abstract

Dynamically typed programming languages such as JavaScript and Python defer type checking to run time. In order to maximize performance, dynamic language VM implementations must attempt to eliminate redundant dynamic type checks. However, type inference analyses are often costly and involve tradeoffs between compilation time and resulting precision. This has lead to the creation of increasingly complex multi-tiered VM architectures. This paper introduces lazy basic block versioning, a simple JIT compilation technique which effectively removes redundant type checks from critical code paths. This novel approach lazily generates type-specialized versions of basic blocks on-the-fly while propagating context-dependent type information. This does not require the use of costly program analyses, is not restricted by the precision limitations of traditional type analyses and avoids the implementation complexity of speculative optimization techniques. We have implemented intraprocedural lazy basic block versioning in a JavaScript JIT compiler. This approach is compared with a classical flow-based type analysis. Lazy basic block versioning performs as well or better on all benchmarks. On average, 71% of type tests are eliminated, yielding speedups of up to 50%. We also show that our implementation generates more efficient machine code than TraceMonkey, a tracing JIT compiler for JavaScript, on several benchmarks. The combination of implementation simplicity, low algorithmic complexity and good run time performance makes basic block versioning attractive for baseline JIT compilers.
Keywords
  • Just-In-Time Compilation
  • Dynamic Optimization
  • Type Checking
  • Code Generation
  • JavaScript

Metrics

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

References

  1. Keith Adams, Jason Evans, Bertrand Maher, Guilherme Ottoni, Andrew Paroski, Brett Simmers, Edwin Smith, and Owen Yamauchi. The hiphop virtual machine. In Proceedings of the 2014 conference on Object Oriented Programming Systems Languages & Applications (OOPSLA), pages 777-790. ACM New York, 2014. Google Scholar
  2. George Almási and David Padua. MaJIC: compiling MATLAB for speed and responsiveness. In Proceedings of the 2002 conference on Programming Language Design and Implementation (PLDI), pages 294-303. ACM New York, May 2002. Google Scholar
  3. Davide Ancona, Massimo Ancona, Antonio Cuni, and Nicholas D. Matsakis. RPython: a step towards reconciling dynamically and statically typed OO languages. In Proceedings of the 2007 Dynamic Languages Symposium (DLS), pages 53-64. ACM New York, 2007. Google Scholar
  4. Christopher Anderson, Paola Giannini, and Sophia Drossopoulou. Towards type inference for JavaScript. In Proceedings of ECOOP 2005, pages 428-452. Springer Berlin Heidelberg, 2005. Google Scholar
  5. V. Bala, E. Duesterwald, and S. Banerjia. Dynamo: a transparent dynamic optimization system. In Proceedings of the 2000 conference on Programming, pages 1-12. ACM New York, 2000. Google Scholar
  6. R. Bodík, R. Gupta, and M. L. Soffa. Complete removal of redundant expressions. In Proceedings of the 1998 conference on Programming Language Design and Implementation (PLDI), pages 1-14. ACM New York, 1998. Google Scholar
  7. Carl Friedrich Bolz, Antonio Cuni, Maciej FijaBkowski, Michael Leuschel, Samuele Pedroni, and Armin 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), pages 43-52. ACM New York, 2011. Google Scholar
  8. Craig Chambers and David Ungar. Customization: optimizing compiler technology for Self, a dynamically-typed object-oriented programming language. In Proceedings of the 1989 conference on Programming Language Design and Implementation (PLDI), pages 146-160. ACM New York, June 1989. Google Scholar
  9. Craig Chambers and David Ungar. Iterative type analysis and extended message splitting: Optimizing dynamically-typed object-oriented programs. In Proceedings of the 1990 conference on Programming Language Design and Implementation (PLDI), pages 150-164. ACM New York, 1990. Google Scholar
  10. Maxime Chevalier-Boisvert, Laurie Hendren, and Clark Verbrugge. Optimizing MATLAB through just-in-time specialization. In Proceedings of the 2010 international conference on Compiler Construction (CC), pages 46-65. Springer Berlin Heidelberg, 2010. Google Scholar
  11. Jack W Davidson and Sanjay Jinturkar. Aggressive loop unrolling in a retargetable, optimizing compiler. In Proceedings of the 1996 international conference on Compiler Construction (CC), pages 59-73. Springer Berlin Heidelberg, 1996. Google Scholar
  12. Michael Furr, Jong-hoon (David) An, Jeffrey S. Foster, and Michael Hicks. Static type inference for ruby. In Proceedings of the 2009 ACM Symposium on Applied Computing (SAC), pages 1859-1866. ACM New York, 2009. Google Scholar
  13. 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. Trace-based just-in-time type specialization for dynamic languages. In Proceedings of the 2009 conference on Programming Language Design and Implementation (PLDI), pages 465-478. ACM New York, 2009. Google Scholar
  14. Andreas Gal, Christian W. Probst, and Michael Franz. HotpathVM: an effective jit compiler for resource-constrained devices. In Proceedings of the 2nd international conference on Virtual Execution Environments (VEE), pages 144-153. ACM New York, 2006. Google Scholar
  15. David Gudeman. Representing type information in dynamically typed languages, 1993. Google Scholar
  16. Brian Hackett and Shu-yu Guo. Fast and precise hybrid type inference for JavaScript. In Proceedings of the 33rd ACM SIGPLAN conference on Programming Language Design and Implementation (PLDI), pages 239-250. ACM New York, June 2012. Google Scholar
  17. Urs Hölzle and David Ungar. Optimizing dynamically-dispatched calls with run-time type feedback. In Proceedings of the 1994 conference on Programming Language Design and Implementation (PLDI), pages 326-336. ACM New York, 1994. Google Scholar
  18. ECMA International. ECMA-262: ECMAScript Language Specification. European Association for Standardizing Information and Communication Systems (ECMA), Geneva, Switzerland, fifth edition, 2009. Google Scholar
  19. Simon Holm Jensen, Anders Møller, and Peter Thiemann. Type analysis for JavaScript. In Proceedings of the 16th International Symposium on Static Analysis (SAS), pages 238-255. Springer Berlin Heidelberg, 2009. Google Scholar
  20. Simon Holm Jensen, Anders Møller, and Peter Thiemann. Interprocedural analysis with lazy propagation. In Proceedings 17th International Static Analysis Symposium (SAS). Springer Berlin Heidelberg, September 2010. Google Scholar
  21. Vineeth Kashyap, John Sarracino, John Wagner, Ben Wiedermann, and Ben Hardekopf. Type refinement for static analysis of JavaScript. In Proceedings of the 2013 Dynamic Languages Symposium (DLS). ACM New York, 2013. Google Scholar
  22. Francesco Logozzo and Herman Venter. RATA: rapid atomic type analysis by abstract interpretation; application to JavaScript optimization. In Proceedings of the 2010 international conference on Compiler Construction (CC), pages 66-83. Springer Berlin Heidelberg, 2010. Google Scholar
  23. E. Morel and C. Renvoise. Global optimization by suppression of partial redundancies. Commun. ACM, 22(2):96-103, February 1979. Google Scholar
  24. Frank Mueller and David B. Whalley. Avoiding unconditional jumps by code replication. In Proceedings of the 1992 conference on Programming Language Design and Implementation (PLDI), pages 322-330. ACM New York, 1992. Google Scholar
  25. Frank Mueller and David B. Whalley. Avoiding conditional branches by code replication. In Proceedings of the 1995 conference on Programming Language Design and Implementation (PLDI), pages 56-66. ACM New York, 1995. Google Scholar
  26. John Plevyak and Andrew A. Chien. Type directed cloning for object-oriented programs. In Proceedings of the Workshop for Languages and Compilers for Parallel Computing (LCPC), pages 566-580, 1995. Google Scholar
  27. Massimiliano Antonio Poletto. Path splitting: a technique for improving data flow analysis. PhD thesis, MIT Laboratory for Computer Science, 1995. Google Scholar
  28. Rodrigo Sol, Christophe Guillon, FernandoMagno Quintão Pereira, and Mariza A.S. Bigonha. Dynamic elimination of overflow tests in a trace compiler. In Jens Knoop, editor, Proceedings of the 2011 international conference on Compiler Construction (CC), pages 2-21. Springer Berlin Heidelberg, 2011. Google Scholar
  29. Litong Song and Krishna M Kavi. A technique for variable dependence driven loop peeling. In Algorithms and Architectures for Parallel Processing, 2002. Proceedings. Fifth International Conference on, pages 390-395. IEEE, 2002. Google Scholar
  30. Sebastian Unger and Frank Mueller. Handling irreducible loops: optimized node splitting versus dj-graphs. ACM Transactions on Programming Languages and Systems (TOPLAS), 24(4):299-333, July 2002. Google Scholar
  31. Mark N. Wegman and F. Kenneth Zadeck. Constant propagation with conditional branches. ACM Transactions on Programming Languages and Systems (TOPLAS), 13(2):181-210, April 1991. Google Scholar
  32. Thomas Würthinger, Christian Wimmer, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Christian Humer, Gregor Richards, Doug Simon, and Mario Wolczko. One VM to rule them all. In Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software, Onward! 2013, pages 187-204. ACM New York, 2013. Google Scholar
  33. Thomas Würthinger, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Doug Simon, and Christian Wimmer. Self-optimizing ast interpreters. In Proceedings of the 2012 Dynamic Language Symposium (DLS), pages 73-82. ACM New York, 2012. Google Scholar
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