Fast and precise hybrid type inference for JavaScript

Fast and precise hybrid type inference for JavaScript
复制标题

JavaScript 的快速、精确的混合类型推理

DOI:
10.1145/2254064.2254094
复制
发表时间:
2012
期刊:
Proceedings of the 33rd ACM SIGPLAN Conference on Programming Language Design and Implementation
影响因子:
--
通讯作者:
Shu
Shu
中科院分区:
--
文献类型:
--
作者:
Brian Hackett;Shu

文献摘要

被引文献

相似文献

JavaScript的性能通常受到其动态类型特性的限制。编译器无法访问静态类型信息,这使得生成高效的、类型专用的机器代码变得困难。我们试图通过推断类型来解决这个问题。本文提出了一种基于指向分析的JavaScript混合类型推理算法。我们的算法是快速的,因为它在优化中为自己付出了代价。我们的算法也很精确,通过使用运行时类型障碍增强静态分析,即使在分析多态代码时也能生成密切反映程序实际行为的信息。我们展示了Mozilla Firefox的JavaScript引擎的实现,展示了性能的提高和可行性。通过与Firefox中的即时(JIT)编译器集成,我们将主要基准测试和JavaScript密集型网站的性能提高了50%。自Firefox 9起,启用推理的编译是默认编译模式。
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.