Skip to main content

JitChain

Struct JitChain 

Source
pub struct JitChain { /* private fields */ }
Expand description

A finished, executable chain.

Implementations§

Source§

impl JitChain

Source

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.

Source

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.

Source

pub fn has_patch_marks(&self) -> bool

Whether any slots await the self-entry patch.

Source

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) -> i64base 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.

Source

pub fn run(&self) -> i64

Run the chain with an empty frame and a fresh operand stack.

Source

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.

Source

pub fn bytes(&self) -> &[u8]

The mapped code+pool bytes (diagnostics/tests).

Source

pub fn base(&self) -> u64

The runtime base address (diagnostics/tests).

Source

pub fn piece_count(&self) -> usize

How many stencil pieces were glued (diagnostics/tests — the tail-jump economics of a lowering).

Trait Implementations§

Source§

impl Debug for JitChain

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.