Expand description
Binary serialization for compiled Bytecode (.mbc files).
Format and safety model: docs/bytecode-snapshot-design.md. This module is defense layer L1: structural validation plus a linear scan over every instruction stream, so bytecode that reaches the VM never indexes out of range and never jumps into the middle of an instruction. Stack discipline and runtime types are deliberately left to the VM’s own checks (L3).
Enums§
Constants§
- FORMAT_
VERSION - Bump when the container layout changes (header, sections, tags, varint rules). Bytecode ABI changes are covered by the fingerprint instead. v2: debug info carries local bindings and free names per function.
Functions§
- bytecode_
abi_ fingerprint - Fingerprint of the bytecode ABI: every opcode (discriminant, name,
operand widths, in enum order) and every builtin (index, name, in table
order —
OpGetBuiltinoperands are indexes into that table). This is a compatibility sentinel, not integrity protection: safety against forged headers rests on the L1/L2/L3 checks, not on this value. - read_
bytecode - Deserialize and validate an
.mbcbuffer. The input is untrusted: every malformed input returnsErr, and anything returnedOkhas passed the L1 checks (§6 of the design doc). - write_
bytecode - Serialize
bytecodeinto the.mbccontainer. Withstrip_debugthe debug section is omitted entirely (flags bit 0 cleared).