Expand description
OSR (On-Stack Replacement) Loop Compilation
Compiles hot loop bodies to native code via Cranelift IR for mid-execution transfer from the bytecode interpreter to JIT-compiled code.
§OSR ABI
extern "C" fn(ctx_ptr: *mut u8, _unused: *const u8) -> u64
- Returns 0 on normal loop exit (locals written back to ctx).
- Returns
u64::MAXon deoptimization (locals partially written back).
§Escape Analysis / Scalar Replacement
The escape analysis pass (Phase 5) identifies small non-escaping arrays
for scalar replacement in the whole-function JIT compiler. OSR compilation
does NOT support NewArray/GetProp/SetLocalIndex opcodes (they fail the
preflight check in is_osr_supported_opcode), so scalar replacement does
not apply to OSR-compiled loop bodies. If OSR support for array opcodes is
added in the future, deopt materialization must reconstruct scalar-replaced
arrays from their SSA variable elements before writing locals back to ctx.
Structs§
- OsrCompilation
Result - Result of compiling a loop body for OSR entry.
Functions§
- compile_
osr_ loop - Compile a loop body for OSR (On-Stack Replacement) entry.