Skip to main content

Vm

Struct Vm 

Source
pub struct Vm<'p> { /* private fields */ }

Implementations§

Source§

impl<'p> Vm<'p>

Source

pub fn new(program: &'p CompiledProgram) -> Self

Source

pub fn install_warm_bytecode(&mut self, fi: usize, fnbc: &FnBytecode) -> bool

Install a re-optimized body as function fi’s warm tier (HOTSWAP §7 / P11): append it to warm_code after program.code, rebasing its 0-relative jumps into that unified pc space, and point warm_entry[fi] at it. Subsequent calls to fi run this body. The body shares the program’s constant pool (a FnBytecode preserves constant indices), so only jumps are relocated.

Source

pub fn with_native_tier(self, tier: &'p dyn NativeTier) -> Self

Install a native tier: hot functions in the integer subset run as JIT-compiled machine code, guarded per call (non-Int args deopt to the bytecode path).

Source

pub fn install_aot_native(&mut self, fi: usize, nf: Box<dyn NativeFn>)

Pre-install an AOT-native function for fi (HOTSWAP §Axis-3): the VM dispatches to it via the existing NativeSlot::Ready path from the first call (it is not Untried, so it skips the hotness threshold and the forge compile). Requires a native tier to be installed (the dispatch is gated on self.tier); on desktop the forge tier is always present alongside. Absent ⇒ the function stays on VM+JIT — the AOT artifact is strictly optional, no gap at the seam.

Source

pub fn with_bg_native_tier(self, tier: &'static dyn NativeTier) -> Self

Install the process tier AND a background compiler (HOTSWAP §6): hot functions are compiled on a worker thread instead of stalling the interpreter. The tier must be &'static (the process-installed forge backend) so it can cross to the worker — &'static dyn NativeTier is Send because NativeTier: Sync. The interpreter still runs the chains and is the sole FnTable writer; the worker only compiles. Falls back to Vm::with_native_tier (synchronous) for a borrowed &'p tier, which cannot be shared with a thread.

Source

pub fn drain_pending_compiles(&mut self)

Block until every outstanding background compile has come back and been published — the determinism hook the differential tests use so the native tier engages predictably regardless of thread scheduling. No-op without a background compiler.

Source

pub fn with_program_args(self, args: Vec<String>) -> Self

Supply the program arguments read by the args() system native. The vector is the full argv (index 0 is the program name), matching the compiled binary’s env::args().

Source

pub fn with_policy_ctx( self, registry: &'p PolicyRegistry, interner: &'p Interner, ) -> Self

Provide the policy registry (and the interner its symbols live in) for Check statements.

Source

pub fn lines(&self) -> &[String]

The output lines, one per Show.

Source

pub fn output(&self) -> String

The output as one string (one trailing newline per Show).

Source

pub fn into_lines(self) -> Vec<String>

Consume the VM, returning its output lines.

Source

pub fn run(&mut self) -> Result<(), String>

Run the whole program to completion (the non-concurrent entry). A concurrent program never reaches here — it is driven through Vm::run_until_block by the scheduler.

Auto Trait Implementations§

§

impl<'p> Freeze for Vm<'p>

§

impl<'p> !RefUnwindSafe for Vm<'p>

§

impl<'p> !Send for Vm<'p>

§

impl<'p> !Sync for Vm<'p>

§

impl<'p> Unpin for Vm<'p>

§

impl<'p> UnsafeUnpin for Vm<'p>

§

impl<'p> !UnwindSafe for Vm<'p>

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,