pub fn compile_function_regalloc_precise(
ops: &[MicroOp],
shared_status: Option<Arc<AtomicI64>>,
depth_addr: i64,
deopt_codes: &[i64],
) -> Option<CompiledChain>Expand description
Compile a LIST-PARAMETER (mode-B) recursive FUNCTION — one that mutates a
SHARED pinned array in place and may self-call — into ONE contiguous
register-allocated x86-64 function with PRECISE deopt. Returns None
(caller falls back to the per-piece stencil tier) on any unsupported op.
Where compile_function_regalloc uses CLASSIC deopt (a side exit replays
the whole function from its boundary args — sound only when every effect is
confined to the private frame, the scalar mode-A case), a list-param
function’s in-place array writes land in SHARED state, so a replay would
DOUBLE-APPLY them. This entry instead emits PRECISE deopt: every checked op
and the self-call’s guards side-exit through the shared status cell with the
op’s ENCODED resume value ((bytecode_pc << 2) | 3 | (depth << 32)), exactly
as logos_stencil_deopt_at / logos_stencil_call_precise do, so the VM
materializes the native call chain and resumes interpreting AT the faulting
op — every prior in-place mutation intact, never re-applied.
deopt_codes is the per-op resume table the function adapter built (parallel
to ops): a plain 1 keeps the op on the ordinary deopt terminal; any other
value is the precise tag emitted on that op’s side exit.
SOUNDNESS: the precise contract requires that on a side exit the native
frame mirror the tree-walker’s full register state. The backend therefore
keeps every mode-B machinery slot (the plant window/resume/dst, the pin
triples, the disjoint callee window) FRAME-RESIDENT, every ListTriple
HANDLE slot frame-resident (the helper reads/writes the frame), and FLUSHES
every resident-written VM register to its frame slot at every precise side
exit (so materialize reads the correct value). All slots at or above the
function’s register count rc are mode-B machinery and stay frame-resident.