Extending Basic Block Versioning with Typed Object Shapes

Typical JavaScript (JS) programs feature a large number of object property accesses. Hence, fast property reads and writes are crucial for good performance. Unfortunately, many (often redundant) dynamic checks are implied in each property access and the semantic complexity of JS makes it difficult to optimize away these tests through program analysis. We introduce two techniques to effectively eliminate a large proportion of dynamic checks related to object property accesses. Typed shapes enable code specialization based on object property types without potentially complex and expensive analyses. Shape propagation allows the elimination of redundant shape checks in inline caches. These two techniques combine particularly well with Basic Block Versioning (BBV), but should be easily adaptable to tracing Just-In-Time (JIT) compilers and method JITs with type feedback. To assess the effectiveness of the techniques presented, we have implemented them in Higgs, a type-specializing JIT compiler for JS. The techniques are compared to a baseline using polymorphic Inline Caches (PICs), as well as commercial JS implementations. Empirical results show that across the 26 benchmarks tested, these techniques eliminate on average 48% of type tests, reduce code size by 17% and reduce execution time by 25%. On several benchmarks, Higgs performs better than current production JS virtual machines

[1]  Fernando Magno Quintão Pereira,et al.  Dynamic Elimination of Overflow Tests in a Trace Compiler , 2011, CC.

[2]  Craig Chambers,et al.  An efficient implementation of SELF a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA 1989.

[3]  Jeremy G. Siek,et al.  Meta-tracing makes a fast Racket , 2014 .

[4]  Carl Friedrich Bolz,et al.  Tracing the meta-level: PyPy's tracing JIT compiler , 2009, ICOOOLPS@ECOOP.

[5]  Brian Hackett,et al.  Fast and precise hybrid type inference for JavaScript , 2012, PLDI '12.

[6]  Hanspeter Mössenböck,et al.  An efficient approach for accessing C data structures from JavaScript , 2014, ICOOOLPS@ECOOP.

[7]  Christian Wimmer,et al.  Self-optimizing AST interpreters , 2012, DLS.

[8]  David Herman,et al.  Typed objects in JavaScript , 2014, DLS.

[9]  Vasanth Bala,et al.  Dynamo: a transparent dynamic optimization system , 2000, SIGP.

[10]  Michael Franz,et al.  HotpathVM: an effective JIT compiler for resource-constrained devices , 2006, VEE '06.

[11]  Péricles Rafael Oliveira Alves,et al.  Just-in-time value specialization , 2013, Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO).

[12]  Ben Hardekopf,et al.  Type refinement for static analysis of JavaScript , 2013, DLS '13.

[13]  Marc Feeley,et al.  Simple and Effective Type Check Removal through Lazy Basic Block Versioning , 2015, ECOOP.

[14]  Yanhong A. Liu,et al.  Alias analysis for optimization of dynamic languages , 2010, DLS '10.

[15]  Peter Thiemann,et al.  Interprocedural Analysis with Lazy Propagation , 2010, SAS.

[16]  Christian Wimmer,et al.  One VM to rule them all , 2013, Onward!.

[17]  David A. Gudeman,et al.  Representing Type Information in Dynamically Typed Languages , 1993 .

[18]  Mason Chang,et al.  Trace-based just-in-time type specialization for dynamic languages , 2009, PLDI '09.

[19]  Jared Roesch,et al.  Improved type specialization for dynamic scripting languages , 2013, DLS '13.

[20]  Michael Leuschel,et al.  Allocation removal by partial evaluation in a tracing JIT , 2011, PEPM '11.

[21]  Peter Thiemann,et al.  Type Analysis for JavaScript , 2009, SAS.

[22]  Hanspeter Mössenböck,et al.  An object storage model for the truffle language implementation framework , 2014, PPPJ '14.

[23]  Craig Chambers,et al.  Optimizing Dynamically-Typed Object-Oriented Languages With Polymorphic Inline Caches , 1991, ECOOP.

[25]  Craig Chambers,et al.  An efficient implementation of SELF, a dynamically-typed object-oriented language based on prototypes , 1989, OOPSLA '89.

[26]  Guilherme Ottoni,et al.  The hiphop virtual machine , 2014, OOPSLA.