pub struct JitChain { /* private fields */ }Expand description
A finished, executable chain.
Implementations§
Source§impl JitChain
impl JitChain
Sourcepub fn from_code(code: &[u8], pieces: usize) -> Result<JitChain, JitError>
pub fn from_code(code: &[u8], pieces: usize) -> Result<JitChain, JitError>
Wrap a finished, self-contained block of machine code (no stencil
pieces, no post-seal patch slots) as a runnable chain. The contiguous
register-allocated region backend (compile_region_regalloc) emits its
whole function as one such block, then runs it through the SAME
run_with_frame ABI as a stencil chain.
pieces is the logical op count (diagnostics only); the executable is
one contiguous function regardless.
Sourcepub fn patch_marked(&self, value: u64) -> Result<(), JitError>
pub fn patch_marked(&self, value: u64) -> Result<(), JitError>
Write value into every marked literal-pool slot (the self-call
entry address, known only after layout). Errs on targets without
post-seal patching (Apple Silicon MAP_JIT) — callers fall back to
the table-indirect call.
Sourcepub fn has_patch_marks(&self) -> bool
pub fn has_patch_marks(&self) -> bool
Whether any slots await the self-entry patch.
Sourcepub unsafe fn entry(
&self,
) -> unsafe extern "C" fn(*mut i64, *mut i64, i64, i64, i64, i64, f64, f64, f64, f64, f64, f64) -> i64
pub unsafe fn entry( &self, ) -> unsafe extern "C" fn(*mut i64, *mut i64, i64, i64, i64, i64, f64, f64, f64, f64, f64, f64) -> i64
The CPS entry point: fn(base, sp) -> i64 — base is the frame (the
compiled function’s register slots), sp the operand-stack top.
§Safety
base must point at a frame at least as large as every patched slot
index; sp must point into an operand stack with capacity for the
chain’s pushes; the page must outlive every call.
Sourcepub fn run_with_frame(&self, frame: &mut [i64]) -> i64
pub fn run_with_frame(&self, frame: &mut [i64]) -> i64
Run the chain over the given frame (slot 0 = VM register 0, …), with a fresh operand stack. The frame is read AND written by slot stencils.
LOGOS_JIT_CANARY=1 guards the operand stack with a sentinel canary
past its end: any stencil that pushes beyond the 256-slot stack (a
pc/sp miscompile) trips it loudly at the source instead of silently
corrupting adjacent memory. It is env-gated rather than always-on
because this runs per chain — millions of times for hot recursion —
so the default (and every release build) pays nothing.
Sourcepub fn piece_count(&self) -> usize
pub fn piece_count(&self) -> usize
How many stencil pieces were glued (diagnostics/tests — the tail-jump economics of a lowering).