Fast and precise hybrid type inference for JavaScript
Brian Hackett, Shuyu Guo · ACM SIGPLAN Notices · 2012
JavaScript performance is often bound by its dynamically typed nature. Compilers do not have access to static type information, making generation of efficient, type-specialized machine code difficult. We seek to solve this problem by inferring types. In this paper we present a hybrid type inference algorithm for JavaScript based on points-to analysis. Our algorithm is fast , in that it pays for itself in the optimizations it enables. Our algorithm is also precise , generating information that closely reflects the program's actual behavior even when analyzing polymorphic code, by augmenting static analysis with run-time type barriers. We showcase an implementation for Mozilla Firefox's JavaScript engine, demonstrating both performance gains and viability. Through integration with the just-in-time (JIT) compiler in Firefox, we have improved performance on major benchmarks and JavaScript-heavy websites by up to 50%. Inference-enabled compilation is the default compilation mode as of Firefox 9.
Cited by 25 works. doi:10.1145/2345156.2254094
Authors
References
- Self: The power of simplicity
- Customization: optimizing compiler technology for SELF, a dynamically-typed object-oriented programming language
- Object-oriented type inference
- Soft typing
- Type inclusion constraints and type inference
- An analysis of the dynamic behavior of JavaScript programs
- Trace-based just-in-time type specialization for dynamic languages
- Type Analysis for JavaScript
- A practical soft type system for scheme
- Towards Type Inference for JavaScript