pub struct Machine<'a, H: Host> { /* private fields */ }Expand description
The production bytecode interpreter.
Implementations§
Source§impl<'a, H: Host> Machine<'a, H>
impl<'a, H: Host> Machine<'a, H>
pub fn ordinary_number_to_string(number: f64) -> String
pub fn same_value_zero(&self, left: Value, right: Value) -> bool
Source§impl<'a, H: Host> Machine<'a, H>
impl<'a, H: Host> Machine<'a, H>
pub fn new( program: &'a Program<Verified>, host: &'a mut H, limits: Limits, ) -> Self
Sourcepub fn run(self) -> Result<Execution, RuntimeError>
pub fn run(self) -> Result<Execution, RuntimeError>
Evaluates the program, drives the automatic event loop to quiescence,
and returns the synchronous Execution snapshot taken right after
evaluation. Callbacks may mutate globals and append host output, but
the returned value and entry register snapshot stay those of the
synchronous evaluation.
Sourcepub fn evaluate(&mut self) -> Result<Execution, RuntimeError>
pub fn evaluate(&mut self) -> Result<Execution, RuntimeError>
Evaluates the program without draining queued microtasks.
The machine remains available for an explicit Self::drain_microtasks
checkpoint.
Sourcepub fn run_one_expired_timer(&mut self) -> Result<TimerRun, RuntimeError>
pub fn run_one_expired_timer(&mut self) -> Result<TimerRun, RuntimeError>
Runs at most one expired live timer callback.
This explicit checkpoint never drains microtasks. Expiry reports only
advance a monotonic watermark; visible delivery is ordered by the
machine-owned (deadline, sequence) key.
Sourcepub fn wait_for_timer_expiry(&mut self) -> Result<bool, RuntimeError>
pub fn wait_for_timer_expiry(&mut self) -> Result<bool, RuntimeError>
Blocks in the host provider until an expiry report is available. Returns whether at least one live timer became ready.
Sourcepub fn has_pending_timers(&self) -> bool
pub fn has_pending_timers(&self) -> bool
Returns whether any machine-owned live timer remains.
Sourcepub fn run_to_quiescence(&mut self) -> Result<(), RuntimeError>
pub fn run_to_quiescence(&mut self) -> Result<(), RuntimeError>
Drives the automatic event loop to quiescence after synchronous evaluation.
Drains every queued microtask first. While a live machine timer
remains, waits for one deadline to become ready, runs exactly one
timer callback, and drains microtasks again. A timer created by a
callback therefore waits for a later timer turn. The first uncaught
queueMicrotask or timer callback exception stops the loop and becomes
RuntimeErrorKind::UncaughtThrow; a timer exception is converted
before any later drain, so its queued microtasks and later timers stay
pending. Promise handler throws settle their derived promises and never
abort the loop. Fatal runtime failures propagate unchanged.
A false wait retries only while the host still exposes the timer
capability and the provider reports an armed timer; otherwise the loop
fails with RuntimeErrorKind::TimerProviderFailure instead of
spinning. Existing fuel is the only work bound: recursive jobs or
timers eventually fail with RuntimeErrorKind::FuelExhausted.
Sourcepub fn drain_microtasks(&mut self) -> Result<MicrotaskDrain, RuntimeError>
pub fn drain_microtasks(&mut self) -> Result<MicrotaskDrain, RuntimeError>
Runs queued microtasks in FIFO order until the queue is empty.
Jobs queued by another job run in the same checkpoint. Promise callback
throws settle their derived promises. Throws from queueMicrotask
callbacks are returned in MicrotaskDrain::uncaught.