Skip to main content

CodeUnit

Struct CodeUnit 

Source
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: u16

Distinct this.x = names in a constructor body: the slots New reserves on the receiver.

§constant_count: u32

The length of the constant table attached on the heap.

§spill_register: u16

The 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: u16

The slots of the spill scope.

§ic_base: u32

The unit’s first entry in the cache store, set when it is published.

§ic_count: u32

Cache 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: u16

The 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.

Implementations§

Source§

impl CodeUnit

Source

pub const fn temp_base(&self) -> u32

The first operand temporary, T(0): after the locals, or after the spill register when the locals do not all fit in the window.

Source

pub const fn has(&self, flag: u16) -> bool

Source§

impl CodeUnit

Source

pub fn bytes(&self) -> usize

Bytes the unit holds: its instructions, tables, positions, source text and cache entries. A dynamic unit charges them to the heap.

Trait Implementations§

Source§

impl Clone for CodeUnit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodeUnit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CodeUnit

Source§

impl PartialEq for CodeUnit

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CodeUnit

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.