pub struct CodeUnit {Show 20 fields
pub code: Box<[Insn]>,
pub handlers: Box<[Handler]>,
pub register_count: u16,
pub parameter_count: u16,
pub local_count: u16,
pub flags: u16,
pub this_slots: u16,
pub constant_count: u32,
pub spill_register: u16,
pub spill_slots: u16,
pub ic_base: u32,
pub ic_count: u32,
pub children: Box<[CodeUnitId]>,
pub captures: Box<[Capture]>,
pub debug: DebugInfo,
pub name_atom: Option<StringId>,
pub length: u16,
pub source: Option<Box<[u8]>>,
pub direct_eval_sites: Box<[u32]>,
pub atoms: Box<[StringId]>,
}Expand description
The compiled form of one function.
The register window of a frame is laid out as: register 0 is this, then
parameter_count parameters, then local_count locals, then the operand
temporaries up to register_count.
Fields§
§code: Box<[Insn]>§handlers: Box<[Handler]>§register_count: u16§parameter_count: u16§local_count: u16§flags: u16§this_slots: u16Distinct this.x = names in a constructor body: the slots New
reserves on the receiver.
constant_count: u32The length of the constant table attached on the heap.
spill_register: u16The register holding the frame’s spill scope, or NO_SPILL: a
function with more locals than the register window holds keeps the
rest in the slots of one scope object, created by NewSpill.
spill_slots: u16The slots of the spill scope.
ic_base: u32The unit’s first entry in the cache store, set when it is published.
ic_count: u32Cache sites, numbered by CodeBuilder::finish.
children: Box<[CodeUnitId]>Inner functions, by MakeClosure index. Published before the unit.
captures: Box<[Capture]>The cells a closure over this unit captures, from the frame that
creates it; LoadCaptured indexes them.
debug: DebugInfo§name_atom: Option<StringId>The function’s name (an atom), or None for "".
length: u16The function’s length.
source: Option<Box<[u8]>>The function’s source text, for Function.prototype.toString, in
WTF-8 (a lone surrogate of Function constructor source is kept as
its three-byte form, as QuickJS’s JS_ToCStringLen2 keeps it).
direct_eval_sites: Box<[u32]>Sorted indices of the calls written as a direct eval, which runs as
indirect eval: a backtrace lists no native frame for them, as QuickJS’s
direct eval has none.
atoms: Box<[StringId]>The atoms a dynamic unit keeps alive (CodeUnit::key_atoms), set
when it is published; empty for a static unit, whose atoms are
pinned.