The Runtime Theory

JIT Compilation Pipeline

How JIT compilers go from bytecode to machine code: interpretation, profiling thresholds, baseline and optimizing tiers, guards, and deoptimization.

The Runtime Theory Team08 stages

trace / request.md

BYTECODEGENERATEDINTERPRETAND PROFILEHOT THRESHOLDCROSSEDBASELINE COMPILEOPTIMIZINGCOMPILEGUARDS INSTALLEDDEOPTIMIZATIONON-STACKREPLACEMENT

readySource compiles to compact bytecode — V8's Ignition, HotSpot's template interpreter — before any execution happens. The bytecode is the input every tier works from.

A JIT compiler is a pipeline that trades warm-up time for steady-state speed. This diagram follows a function from bytecode to optimized machine code: interpretation with counters, a threshold that flags the function as hot, baseline compilation with inline caches, an optimizing pass that trusts recorded type feedback, and guards that enforce those assumptions. The ordering matters because each tier exists to buy information for the next — the interpreter profiles, the baseline tier validates, and the optimizing tier exploits. When a guard fails, the diagram shows deoptimization bailing back to a lower tier at a safe point, and on-stack replacement switching a hot loop mid-execution. The end state is a tiered function: cold paths interpreted, hot paths running as optimized native code.