Expand description
The fusevm execution engine — stack-based bytecode dispatch loop.
This is the hot path. Every cycle counts. The dispatch loop uses
a flat match on Op variants — Rust compiles this to a jump table.
Frontends register extension handlers via ExtensionHandler for
language-specific opcodes (Op::Extended, Op::ExtendedWide).
§Optimizations
- Type-specialized integer fast paths: Add, Sub, Mul, Mod, comparisons
check for
Int×Intfirst and skipto_float()coercion entirely. - Zero-clone dispatch: ops are borrowed from the chunk, not cloned per cycle.
LoadConstcopies scalars (Int/Float/Bool) without touching Arc refcounts. - In-place container mutation: array/hash ops (Push, Pop, Shift, Set, HashSet, HashDelete) mutate globals directly — no clone-modify-writeback.
Cow<str>string coercion:as_str_cow()borrowsStrvariants without allocation. Used in string comparisons, Concat, Print, hash key lookup.- Inline builtin cache:
CallBuiltindispatches through a pre-registered function pointer table — no name lookup at runtime. - Fused superinstructions: hot loop patterns run as single ops (AccumSumLoop, SlotIncLtIntJumpBack, etc.)
- Pre-allocated collections: Range, MakeHash, HashKeys/Values use exact or estimated capacity. ConcatConstLoop pre-sizes the string buffer.
Structs§
Enums§
- VMResult
- Result of VM execution
Type Aliases§
- Builtin
Handler - Builtin function handler: (vm, argc) → Value
- Extension
Handler - Extension handler for language-specific opcodes. Frontends register this at VM init.
- Extension
Wide Handler - Wide extension handler (usize payload).