Skip to main content

Module bytecode

Module bytecode 

Source
Expand description

Register bytecode: fixed-width instructions, code units and the store that owns them.

A code unit is built once by the lowering, checked once by validate when it is published, and then run without any decoding: the main loop matches on the typed Opcode and indexes registers with plain []. Units published before the program runs live in the CodeStore for the runtime’s lifetime; units compiled at run time live in the heap, which frees each once no function, frame or job reaches it.

Re-exports§

pub use self::builder::CodeBuilder;
pub use self::disasm::disassemble;
pub use self::opcode::Format;
pub use self::opcode::Opcode;
pub use self::validate::ValidateError;
pub use self::validate::ValidateErrorKind;

Modules§

builder
The construction API the lowering emits through: one method per operand format, forward jumps patched by index, and finish into a CodeUnit.
disasm
The disassembler: one instruction per line, registers by role (this, p0, l3, t2, or r300 above a frame’s temporaries).
flags
opcode
The opcode table: one line per opcode with its operand format.
validate
The publication validator: run once per code unit, so the main loop can index registers, constants, children and targets without further checks. A failure is an internal error of the lowering, never a JavaScript exception.

Structs§

CodeStore
The units published before the program runs. It lives in the runtime beside the heap, not in it, so the main loop can hold &[Insn] across heap calls; units compiled at run time live in the heap (DynamicUnits).
CodeUnit
The compiled form of one function.
CodeUnitId
Index of a CodeUnit in the CodeStore.
DebugInfo
Source information kept for the disassembler and error messages.
Handler
An exception handler: a throw at an instruction in start..end stores the thrown value in register (the temporary at the handler’s stack depth) and continues at target. Entries are ordered innermost first.
Insn
One register instruction. a, b, c are register operands or small counts; imm is a constant index, an absolute jump target, a key’s bits, a scope slot or an i32 literal, as the opcode’s Format says.
SourcePosition
A one-based source line and column, from instruction pc on.
Units
Every unit the runtime holds, static and dynamic, for reading.

Enums§

Capture
Where a closure created by MakeClosure gets one captured cell, read in the frame that runs the MakeClosure.
UnitRef
A borrowed code unit: a unit of the CodeStore for the store’s lifetime, or a counted reference to a unit the heap owns, which keeps it alive while the loop runs it across a collection.

Constants§

NO_SPILL
CodeUnit::spill_register of a unit without a spill scope.
WINDOW
Register operands address a 256-register window; registers above it are reached through LoadWide and StoreWide.