Function: Maintain the cache of optimized code and IR on the target, deduplicated and partitioned by granularity (instruction, block, method, trace) and "ways" (runtime configurations). Provides the basis for "image mode" where all code is preloaded.
Inputs
- Interpreter (i).
- Profiler output
- IR fragments and residual programs
- Compiled code objects (baseline and optimized)
- hashes/binding-time signatures
- "ways" / Runtime configuration or system options (JIT allowed, profiling enabled, image mode)
- State per entry: empty, profiling, compiled, invalidated.
Processing
- Partition by granularity and ways
- Granularity: instruction, block, method, trace.
- Ways: runtime configurations (profiling, heap layout, etc.).
- Tier 0: interpret cold/unprofiled code.
- Tier 1: when hot, emit quickly compiled code via template-based copy-and-patch JIT.
- Maintain simple but stable cache mapping IR fragments to compiled code object.
- Associate IR fragments with code objects via stable enough mappings for debugging/deopt (not necessarily 1–1 after aggressive transforms).
- Handle deopt back to interpreter in simple cases.
- Check whether precompiled entries are valid for current program version and ways.
- Evict/demote cache objects based on usage/memory
Outputs
- Active code pointers for hot functions.
- Baseline compiled code cache.
- Cache hits/misses statistics
- Canonical IR/code reuse across runs and configurations
- Preloaded executable image with optional reduced capabilities (no dynamic code execution, no profiling, tree-shaken).
Key references
- JIT compilation basics and tiering patterns (e.g., JVM/JS engines). en.wikipedia
Function: Maintain the cache of optimized code and IR on the target, deduplicated and partitioned by granularity (instruction, block, method, trace) and "ways" (runtime configurations). Provides the basis for "image mode" where all code is preloaded.
Inputs
Processing
Outputs
Key references