pub struct Vm<'p> { /* private fields */ }Implementations§
Source§impl<'p> Vm<'p>
impl<'p> Vm<'p>
pub fn new(program: &'p CompiledProgram) -> Self
Sourcepub fn record_field_copy_work(&self) -> (usize, usize)
pub fn record_field_copy_work(&self) -> (usize, usize)
Actual record-field copy work during this VM instance’s lifetime: (copies, elements copied), saturating at usize::MAX.
Sourcepub fn install_warm_bytecode(&mut self, fi: usize, fnbc: &FnBytecode) -> bool
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.
Sourcepub fn with_native_tier(self, tier: &'p dyn NativeTier) -> Self
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).
Sourcepub fn install_aot_native(&mut self, fi: usize, nf: Box<dyn NativeFn>)
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.
Sourcepub fn with_bg_native_tier(self, tier: &'static dyn NativeTier) -> Self
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.
Sourcepub fn drain_pending_compiles(&mut self)
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.
Sourcepub fn with_program_args(self, args: Vec<String>) -> Self
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().
Sourcepub fn reinstantiate(&self) -> Vm<'p>
pub fn reinstantiate(&self) -> Vm<'p>
A new instance of the same program, configured as this one was (native tier, policy context, argument vector), with nothing run and no global set — what a browser has after a page reload re-instantiates the module.
Sourcepub fn with_policy_ctx(
self,
registry: &'p PolicyRegistry,
interner: &'p Interner,
) -> Self
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.
Sourcepub fn program(&self) -> &'p CompiledProgram
pub fn program(&self) -> &'p CompiledProgram
The program this machine runs.
Sourcepub fn into_lines(self) -> Vec<String>
pub fn into_lines(self) -> Vec<String>
Consume the VM, returning its output lines.
Sourcepub fn run(&mut self) -> Result<(), String>
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.
Sourcepub fn failing_site(&self) -> Option<u32>
pub fn failing_site(&self) -> Option<u32>
The Stmt::Site id in force at the pc a failed run’s Err propagated from (Wave 3:
“runtime failures carry a location”) — None outside any component’s action/handler
(## Main/## Test own top-level statements, which have no marker), or when the failing pc
lies in a hot-swapped warm body site_at was never built to cover. Reads sched_pc, which
run_until_block_impl’s dispatch loop saves before every op — the last write it sees before
an Err from that op propagates via ? straight out of the loop, so this is only meaningful
to call once the caller already has that Err in hand; a successful run’s sched_pc is
simply wherever the loop happened to stop.
Sourcepub fn invoke_function(
&mut self,
fi: u16,
args: Vec<RuntimeValue>,
) -> Result<RuntimeValue, String>
pub fn invoke_function( &mut self, fi: u16, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
Call function fi from the host, after the program has run: what a browser does when it
calls one of a module’s exports. The call enters through the same path Op::Call takes
(native tier, warm body, baseline) and runs against the globals the program left behind.
An Err is the callee’s failure, and it leaves the machine idle and callable with every
global exactly as the failure found it — a wasm trap unwinds to the host the same way.
Sourcepub fn call_closure(
&mut self,
callee: &RuntimeValue,
args: Vec<RuntimeValue>,
) -> Result<RuntimeValue, String>
pub fn call_closure( &mut self, callee: &RuntimeValue, args: Vec<RuntimeValue>, ) -> Result<RuntimeValue, String>
Call a closure value from the host: what a browser does when it fires a handler the module
handed it earlier (a fetch completion, a listener, a route handler). Same failure contract
as Vm::invoke_function.
Sourcepub fn run_recording(&mut self) -> Result<(), String>
pub fn run_recording(&mut self) -> Result<(), String>
Run forward to completion WITH reversibility recording, capturing the history tape (retrieve
it with Vm::take_journal, then reconstruct the pre-run state with Vm::run_reverse).
A cold path (verification / adiabatic reverse execution): the production Vm::run
monomorph (RECORDING = false) dead-strips every recording block, so the 2.5×-C hot loop is
byte-for-byte unchanged — this method merely instantiates a separate RECORDING = true
copy of the loop that prod never calls. Declines with a clear error (never a silent
mis-reverse) if the program uses an op outside the currently-reversible subset
(crate::vm::reverse::is_reversible_supported).
Sourcepub fn run_recording_mode(&mut self, mode: ReverseMode) -> Result<(), String>
pub fn run_recording_mode(&mut self, mode: ReverseMode) -> Result<(), String>
Like Vm::run_recording but at an explicit ReverseMode —
the pebbling fidelity ⇄ space ⇄ time point. FullState journals every destroyed value;
Observable/Adiabatic compute a per-pc plan and skip journaling
scratch the reverse never reads, shrinking the tape toward the Landauer floor.
Sourcepub fn run_recording_budgeted(
&mut self,
mode: ReverseMode,
budget: usize,
) -> Result<(), String>
pub fn run_recording_budgeted( &mut self, mode: ReverseMode, budget: usize, ) -> Result<(), String>
Like Vm::run_recording_mode but with an explicit pebble CHECKPOINT budget (corner 2):
budget recomputable chain intermediates are kept journaled, so a reverse read stops its
re-walk at the nearest checkpoint instead of the chain root. budget = 0 is exactly
Vm::run_recording_mode (the recompute-everything corner).
Sourcepub fn recompute_ops(&self) -> usize
pub fn recompute_ops(&self) -> usize
The number of recompute re-executions performed by the last reverse pass (corner 2) — the time-cost instrument for the pebble time/space schedule.
Sourcepub fn take_journal(&mut self) -> Option<HistoryTape>
pub fn take_journal(&mut self) -> Option<HistoryTape>
Take the history tape recorded by Vm::run_recording.
Sourcepub fn run_recording_driven(&mut self) -> Result<(), String>
pub fn run_recording_driven(&mut self) -> Result<(), String>
Run forward to completion WITH recording, DRIVING the task through its concurrency blocks —
the single-task reversible-scheduler path. Accumulates one history tape across every slice; a
Sleep (virtual time) resumes with nothing. Multi-task/channel blocks are declined here (the
coordinator-driven reversible scheduler over several task VMs is the next layer). Declines a
program with any op outside the reversible subset before running.
Sourcepub fn run_reverse(&mut self, tape: HistoryTape) -> Result<(), String>
pub fn run_reverse(&mut self, tape: HistoryTape) -> Result<(), String>
Run BACKWARD: reconstruct the EXACT pre-run state by replaying the executed op path in strict
reverse order and applying each op’s inverse. The control-flow trace (steps) gives the exact
executed sequence — so branches and loops reverse with no special-casing (a loop is just the
trace with repeated pcs). A crate::vm::reverse::RevClass::Bijection op self-inverts
algebraically with NO data-tape interaction (the zero-garbage core, even inside a loop); every
other op that recorded a delta pops it and restores what it destroyed. The data tape stays
aligned because journaled ops are visited in exact reverse push order.
Sound because reversing in exact reverse order leaves the machine in each op’s POST-state when its inverse is applied, so every operand the inverse reads holds its forward value.
Sourcepub fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
pub fn take_unhandled(&mut self) -> Option<(String, Option<u32>)>
The failure a page entry the program took itself contained and no handler absorbed, taken
by the host that is carrying the page on — whose own record of the page’s failure it
becomes (crate::page_host::LoweredCalls::take_unhandled).
Sourcepub fn run_keeping_entries(&mut self) -> Result<(), String>
pub fn run_keeping_entries(&mut self) -> Result<(), String>
The main program, run to its end with any contained failure left for the host to take
(Vm::take_unhandled) rather than made the run’s own: the start of a page a host keeps
driving.
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.