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
finishinto aCodeUnit. - disasm
- The disassembler: one instruction per line, registers by role (
this,p0,l3,t2, orr300above 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§
- Code
Store - 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). - Code
Unit - The compiled form of one function.
- Code
Unit Id - Index of a
CodeUnitin theCodeStore. - Debug
Info - Source information kept for the disassembler and error messages.
- Handler
- An exception handler: a throw at an instruction in
start..endstores the thrown value inregister(the temporary at the handler’s stack depth) and continues attarget. Entries are ordered innermost first. - Insn
- One register instruction.
a,b,care register operands or small counts;immis a constant index, an absolute jump target, a key’s bits, a scope slot or ani32literal, as the opcode’sFormatsays. - Source
Position - A one-based source line and column, from instruction
pcon. - Units
- Every unit the runtime holds, static and dynamic, for reading.
Enums§
- Capture
- Where a closure created by
MakeClosuregets one captured cell, read in the frame that runs theMakeClosure. - UnitRef
- A borrowed code unit: a unit of the
CodeStorefor 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_registerof a unit without a spill scope.- WINDOW
- Register operands address a 256-register window; registers above it are
reached through
LoadWideandStoreWide.