Just-In-Time Compilation
Subject: Computer and Technology noun /ˌdʒʌst.ɪnˈtaɪm ˌkɑːm.pəˈleɪ.ʃən/ 1 definition
- compiler-design
- runtime-systems
- virtual-machines
- code-optimization
-
Definition (noun)
Entry #82 · UpdatedJust-In-Time Compilation (JIT) is a runtime execution technique that translates intermediate bytecode or source code into native machine instructions while a program is running, rather than before execution begins. Bridging the gap between pure interpretation and ahead-of-time (AOT) compilation, a JIT compiler monitors live execution behavior—such as frequently executed "hot" loops and observed runtime types—to optimize critical paths on the fly and cache the compiled machine code in memory for direct CPU execution. Although profiling and dynamic code generation introduce modest startup latency and memory overhead, JIT compilation enables managed runtimes and dynamic languages to preserve cross-platform portability while achieving high sustained throughput.
Common Forms
Method-Based JIT: Compiles an entire function or method into native machine code once its invocation count exceeds a hotness threshold, enabling broad optimizations such as inlining and register allocation across the whole routine.
Tracing JIT: Profiles control flow at runtime and compiles linear sequences of frequently executed instructions—known as hot traces—across loops and branch boundaries rather than full methods, an approach used in runtimes like LuaJIT and PyPy.
Tiered JIT: Progressively compiles code through multiple optimization tiers—starting with an interpreter or lightweight compiler for fast startup before promoting hot paths to an aggressive optimizing compiler, as implemented in the Java HotSpot JVM and V8.
Baseline (Template) JIT: Emits native instructions rapidly by mapping each bytecode operation to pre-built machine-code templates with minimal analysis, removing interpreter dispatch overhead while keeping compile-time latency negligible.
Example
When a Node.js microservice parses thousands of incoming JSON payloads in a tight JavaScript loop, the V8 runtime begins executing the function in its bytecode interpreter while profiling call frequency and variable types. Once the loop becomes hot, V8's JIT compiler emits native x86-64 or ARM64 machine code specialized for the observed object shapes, allowing subsequent iterations to run directly on the CPU at near-native speed.