Expand description
Register-based interpreter for one virtual flow.
The VM never touches threads, mailboxes, timers or the Cap table. It runs
until it finishes, hits an instruction budget, or needs a scheduler
effect — then returns a VmResult and stops. That split is what lets
the M:N scheduler move a suspended Vm between workers freely.
| Type | Role |
|---|---|
Vm | Per-flow machine state (frames, pc, natives handle) |
VmResult | Complete / Yield / Sleep / Spawn / Send / Receive / Ask / … |
Fault | Type errors, traps, native failures → flow failure |
NativeTable | Host FFI slots indexed by CallNative |
Re-exports§
pub use crate::bytecode::Value;
Structs§
- Native
Table - Immutable, indexable set of natives. Gaps left by
NativeTableBuilder::register_atareNone— calling them faults withFault::BadNative. - Native
Table Builder - Fluent builder for a
NativeTable. - Vm
- One virtual Flow’s execution state: call stack + registers. Cheap
enough to construct that spawning a Flow is a handful of small heap
allocations, not a native thread/stack (contrast: a
std::threadreserves megabytes of stack whether it uses them or not).
Enums§
- Fault
- Anything that can go wrong inside a running Flow’s VM.
- VmResult
- What happened at the end of a
crate::Vm::runslice.
Constants§
- MAX_
CALL_ DEPTH - Hard limit on call nesting. Frames are heap-allocated (see [
Frame]), so unbounded recursion would grow the Flow’s memory instead of crashing the worker thread’s native stack — which is worse, not better, without a limit.4096comfortably covers real recursive algorithms while keeping a runawayfn f() { f() }aFault, not an OOM.
Functions§
- expect_
arg - Require
args[index]to exist. - expect_
bool - Require
args[index]to be a bool (ints: nonzero = true). - expect_
int - Require
args[index]to coerce to an int (Value::as_int). - expect_
message - Require
args[index]to be acrate::Message. - expect_
u64 - Coerce
args[index]tou64fromInt(≥ 0),Pid,Cap, orBool.
Type Aliases§
- Native
Fn - A host-side function callable from bytecode via
Opcode::CallNative. - Native
Result - Result type for a native function.