Skip to main content

Module webizen_bytecode

Module webizen_bytecode 

Source
Expand description

Bytecode execution engine.

Runs a compiled mini_parser program against a &[NQuin] database slice, writing every matching Quin into a caller-supplied output buffer. No heap allocation is performed inside this module.

§Return value

execute_program returns Ok((match_count, vm_cycles)):

  • match_count — number of Quins written to out[..match_count].
  • vm_cycles — total VM opcodes decoded across all Quin evaluations. The daemon exposes this as X-Qualia-Compute-Cost.

For richer diagnostics use execute_program_with_stats which returns an ExecutionStats breakdown distinguishing topological-pointer ops (MSB=1, did:q42 coordinates) from plain dictionary/lexicon hash ops (MSB=0).

§Error contract

  • Err(VmError::OutputBufferFull)out was exhausted; return HTTP 413.
  • Err(VmError::InvalidProgram) — malformed bytecode.

§MSB dispatch convention

Operand bit 63 encodes the evaluation path for every MATCH_* opcode:

  • MSB = 1 → operand is a did:q42 topological pointer (physical byte-offset coordinate produced by crate::identifier::parse_did_q42). The VM takes the direct jump path: the value is compared as a raw hardware address with no lexicon indirection.
  • MSB = 0 → operand is a plain FNV-1a dictionary hash. The VM takes the lexicon lookup path: standard equality against the stored Quin field.

Structs§

ExecutionStats
Per-execution breakdown returned by execute_program_with_stats.
GuardianshipContext

Enums§

VmError

Functions§

execute_program
Execute program against every Quin in db, collecting matches into out.
execute_program_simd
Scalar fallback used on non-wasm32 targets or when wasm_simd is not enabled.
execute_program_with_stats
Execute program against every Quin in db, returning full ExecutionStats.