Skip to main content
QUICK REVIEW

[Paper Review] Interprocedural Type Specialization of JavaScript Programs Without Type Analysis

Maxime Chevalier-Boisvert, Marc Feeley|arXiv (Cornell University)|Nov 3, 2014
Logic, programming, and type systemsComputer Science24 references1 citations
TL;DR

This paper introduces lazy basic block versioning, a JIT compilation technique that eliminates redundant JavaScript type checks by lazily generating type-specialized versions of basic blocks during code generation, using context-dependent type information without static type analysis. It achieves up to 71% type check removal and 50% performance speedups, outperforming traditional flow-based type analysis and competing favorably with tracing JITs like TraceMonkey.

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.

Motivation & Objective

  • To address the high cost and precision limitations of traditional type inference in dynamic language JIT compilers.
  • To eliminate redundant dynamic type checks in JavaScript without relying on expensive whole-program type analyses.
  • To develop a lightweight, practical JIT optimization technique suitable for baseline compilers with minimal implementation complexity.
  • To evaluate whether on-the-fly type specialization via basic block versioning can outperform static type analysis and existing tracing JITs.

Proposed method

  • Lazily clones and specializes basic blocks at runtime based on accumulated type information from execution context.
  • Maintains a typing context (type map) that tracks variable types at each program point during code generation.
  • When a type test is encountered and the argument type is known, the test is eliminated and a specialized block version is generated.
  • Each basic block may have multiple versions, one per distinct typing context, enabling type-specialized code generation.
  • Type information propagates across control flow edges, with separate typing contexts created for conditional branches based on type test outcomes.
  • The technique avoids static overapproximation by generating code only along actual execution paths, reducing code bloat.

Experimental results

Research questions

  • RQ1Can type check removal be effectively achieved without static type analysis in a JIT compiler?
  • RQ2How does lazy basic block versioning compare in performance and type check elimination to classical flow-based type analysis?
  • RQ3To what extent does basic block versioning reduce code size and avoid pathological bloat?
  • RQ4Can this technique outperform established tracing JITs like TraceMonkey on complex benchmarks?
  • RQ5How effective is the approach in eliminating type checks across diverse JavaScript workloads?

Key findings

  • On average, lazy basic block versioning eliminated 71% of type checks, compared to only 16% with the tested flow-based type analysis.
  • The technique achieved performance speedups of up to 50% on the benchmark suite, with consistent improvements across all workloads.
  • With a limit of 5 versions per block, the average code size increase was only 0.19%, indicating minimal bloat.
  • Higgs, the implementation, outperformed V8's baseline compiler on most benchmarks and matched or exceeded TraceMonkey on complex workloads.
  • The method effectively handles control flow with multiple numerical types by detangling code paths and enabling efficient type specialization.
  • The approach is robust to dynamic language features like eval and dynamic module loading, which commonly break traditional type analyses.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.