pub struct CompiledCode {
pub code: Function,
pub arg_cell: Vec<i32>,
pub loc_cell: Vec<i32>,
}Expand description
The bytecode of one function, plus the slot-to-cell mapping.
This is a separate GC object from the closure so that a frame can hold a handle
to it and read it while the function object itself is free to be borrowed.
Holding a RefCell borrow across a call would deadlock the moment a function
referred to itself.
Fields§
§code: FunctionThe resolved bytecode.
arg_cell: Vec<i32>For each argument slot, the index of its reference cell, or -1 when the
slot holds its value directly.
A captured binding lives in a cell so that closures outlive the frame; every
other slot is a plain value. Precomputing the mapping keeps the hot
get_arg/put_arg paths to one array read instead of a lookup.
loc_cell: Vec<i32>The same, for local slots.
Implementations§
Source§impl CompiledCode
impl CompiledCode
Sourcepub fn new(code: CompiledFunction) -> CompiledCode
pub fn new(code: CompiledFunction) -> CompiledCode
Build the slot-to-cell mapping for code.
Cells are numbered the way CompiledFunction::var_ref_count counts them:
the captured arguments first, then the captured locals, each in slot order.