pub struct RegChunk {
pub name: String,
pub code: Vec<RegOp>,
pub constants: Vec<Value>,
pub n_regs: u16,
pub param_slots: u16,
pub arity: usize,
pub required: usize,
}Expand description
A register-mode chunk (function body), i.e. one frame layout.
Three different quantities used to share one field: the frame’s window size, the count of parameter slots to reserve at the bottom of the frame, and the declared parameter count. They are kept apart here because they answer different questions and only happen to coincide for a plain function:
RegChunk::n_regs- how many registers the frame needs (window size);RegChunk::param_slots- how many of them are reserved for the parameters and an implicitthis(the translator’s initial stack height);RegChunk::arity/RegChunk::required- the parameter-count contract from the chunk’sFunctionObj, used to check a call.
Fields§
§name: String§code: Vec<RegOp>§constants: Vec<Value>§n_regs: u16Registers the frame must allocate: the highest register index any instruction of the chunk uses, plus one.
param_slots: u16Registers reserved at the bottom of the frame for parameters and an
implicit this: this is the translator’s initial stack height, so the
chunk’s own let/var locals and every expression temp live at
param_slots..n_regs.
It is not the declared parameter count and it is not the function’s
arity: a method reserves an extra slot for this, and a chunk reached
through CallDirect has no FunctionObj to ask.
arity: usizeDeclared parameter count (max) of the chunk’s FunctionObj, used for
the arity check when the call site holds the function value.
Stays 0 for chunks that only CallDirect reaches.
required: usizeDeclared required-parameter count, as RegChunk::arity.