What compilation technique does the V8 engine use for frequently executed code?

The story behind the answer

V8 uses just-in-time compilation for frequently executed JavaScript code. It can observe running code, identify performance-critical sections, and compile those sections into native machine instructions while the program is running.

V8 first parses JavaScript into an abstract syntax tree, then Ignition converts it into bytecode. As functions and loops execute repeatedly, V8’s profiling systems gather information about their behavior. Hot code can then be passed through compilers such as Sparkplug, Maglev, or TurboFan, with higher tiers applying more sophisticated optimizations.

This approach combines the quick startup of interpretation with much of the speed of compiled machine code. V8 may also deoptimize code if its assumptions stop being true—for example, if a value changes from an integer-like type to a string—and later optimize it again.

A common mix-up is thinking that V8 uses only interpretation or only ahead-of-time compilation. Interpretation remains part of its execution pipeline, but the defining technique for optimizing frequently executed code is runtime, or just-in-time, compilation.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: