Skip to content

1.1 Tiered IR & Code Cache #14

Description

@Mathnerd314

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions