Expand description
The binary Silicon ISA — the register bytecode as a stable, self-contained,
chip-decodable byte stream. The text sibling is crate::vm::isa (emit_isa, the
human-readable assembly listing); this is the machine form of the SAME opcode set.
Two roles, one artifact:
-
Wire transport.
encode_program/decode_programturn a wholeCompiledPrograminto a versioned, checksummed, SELF-CONTAINED frame. The frame carries its own symbol string-table, so a receiver with a freshInternerre-interns and runs it byte-identically. This is what makes “send the language bytecode over the wire and execute it” real: the raw bytecode’sSymbols are interner-relative (seecrate::vm::tier_cache) and thus NOT portable across machines; the frame lowers every symbol to a wire-local id into the string table and the decoder re-interns them on the far side. -
Chip ISA.
opcodeis the STABLE opcode number a hardware decoder shares. It is keyed onOp::namethrough an APPEND-ONLY table (ISA_OPCODES), so the number for a given op can never drift when theOpenum is reordered — the exact property a fabricated decoder needs (its wired constants outlive the source order). The reversible-core opcodes (RevAdd…RevSwap) sit at pinned low numbers so the adiabatic datapath’s control decode is fixed.
Constants§
- ISA_
MAGIC - The frame magic —
LOGOS Bytecode, format 1. A receiver rejects any buffer that does not open with these four bytes (a foreign or truncated frame is not a program). - ISA_
OPCODES - The APPEND-ONLY opcode table:
opcode(op) == position of op.name() in this slice. Order IS the ABI — a new op appends at the end and keeps every prior number fixed; the totality lock (this module’s unit testopcode_map_is_total_over_the_isa) forces a newly-addedOpto be registered here, and the append-only lock pins the reversible-core numbers so a chip decoder built against them can never silently mismatch. Never reorder or delete an entry. - ISA_
VERSION - The wire-format version. Bumped when the frame layout changes incompatibly; a decoder rejects a version it does not understand rather than mis-parsing it.
Functions§
- decode_
program - Decode an ISA frame back into an executable
CompiledProgram, re-interning its symbol table againstinterner(which may be BRAND NEW — the frame is self-contained). ReturnsNoneon any corruption: bad magic, wrong version, checksum mismatch, or malformed payload — a corrupt frame is not a program and is rejected, never half-executed. - encode_
program - Serialize a whole compiled program into a self-contained, portable ISA frame:
MAGIC ‖ version ‖ checksum ‖ bincode(WireProgram). Theinterneris the one the program was compiled against — every symbol string is captured from it so the frame stands alone. - opcode
- The stable opcode number for an op — the value a hardware decoder keys on. Total over the
ISA (a new op that forgets to register in
ISA_OPCODESpanics here, and the totality lock catches it in CI first). - opcode_
of_ name - The stable opcode number for an op name, or
Noneif the name is not in the ISA table.