Step 01 · Why JIT?
Ahead-of-time (AOT) compilation produces a binary at build time. Just-in-time (JIT) compilation defers code generation to run time:
| AOT | JIT | |
|---|---|---|
| Compile cost paid | once, off-line | every invocation (cached after first run) |
| Knows actual inputs | no | yes — can specialise on profile data |
| Patching live code | hard | first-class (tiering, deopt) |
| Cold-start latency | tiny | non-trivial |
| Deploy artefact | .exe | the JIT + bytecode/IR |
Real-world JITs: HotSpot (Java), V8 (JS), LuaJIT, Julia, Numba, PyPy, Pharo. They share three ingredients:
- An IR low enough to lower to machine code (LLVM IR, Sea-of-Nodes, etc.).
- A code generator that emits into executable memory.
- A symbol table that lets fresh code call previously-jitted code and runtime helpers.
LLVM gives us all three through ORC.