Skip to main content

Module snapshot

Module snapshot 

Source
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§

SnapshotError
SnapshotWriteError

Constants§

FORMAT_VERSION
Bump when the container layout changes (header, sections, tags, varint rules). Bytecode ABI changes are covered by the fingerprint instead.

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 — OpGetBuiltin operands 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 .mbc buffer. The input is untrusted: every malformed input returns Err, and anything returned Ok has passed the L1 checks (§6 of the design doc).
write_bytecode
Serialize bytecode into the .mbc container. With strip_debug the debug section is omitted entirely (flags bit 0 cleared).