Skip to main content

Helper

Enum Helper 

Source
pub enum Helper {
Show 32 variants LoadConstant, Unary, Binary, CreateObject, CreateArray, CreateCell, CreateClosure, GetProperty, SetProperty, DeleteProperty, Call, Construct, Import, Truthy, ResumeValue, DefineAccessor, LoadGlobal, StoreGlobal, TypeOfGlobal, LoadThis, LoadArguments, LoadNewTarget, ArrayPush, ArrayExtend, ObjectSpread, SetPrototype, CreatePrivateName, CreateRegExp, GetIterator, IteratorNext, Export, ConsumeFuel,
}
Expand description

A runtime routine the lowered code calls but does not define. Backends resolve each Helper::symbol to an address (JIT) or relocation (AOT).

§Stable helper table

The variant order below is the canonical external_index order and the public contract a backend and the runtime link against. frame (i64) leads and out (*mut Completion, i64) trails every completion helper; runtime Values are i64; small integer selectors and indices are i32.

idxvariantparams after frame (before out)
0LoadConstantconst_id: i32
1Unaryop: i32, operand: i64
2Binaryop: i32, left: i64, right: i64
3CreateObject
4CreateArray
5CreateClosurefunction_id: i32, captures: i64
6GetPropertyobject: i64, key: i64
7SetPropertyobject: i64, key: i64, value: i64
8DeletePropertyobject: i64, key: i64
9Callcallee: i64, this: i64, arguments: i64
10Constructcallee: i64, arguments: i64
11Importspecifier: i32
12Truthyvalue: i64i32 (no out, total)
13ResumeValue
14DefineAccessorobject: i64, key: i64, accessor: i64, kind: i32
15LoadGlobalname: i32
16StoreGlobalname: i32, value: i64
17TypeOfGlobalname: i32 (total)
18LoadThis— (total)
19LoadArguments— (total)
20LoadNewTarget— (total)
21ArrayPusharray: i64, value: i64
22ArrayExtendarray: i64, iterable: i64
23ObjectSpreadtarget: i64, source: i64
24SetPrototypeobject: i64, prototype: i64
25CreatePrivateNamedescription: i32 (total)
26CreateRegExppattern: i32, flags: i32
27GetIteratorsrc: i64, kind: i32
28IteratorNextiterator: i64, done_reg: i32, value_reg: i32 (two-write)
29Exportname: i32, src: i64
30ConsumeFuelamount: i32 (total except FatalTrap)
31CreateCell

Every helper except Helper::Truthy returns a bamts_native::CompletionTag. Helper::Truthy returns 0/1.

Variants§

§

LoadConstant

bamts_load_constant(frame, const_id, out): materialize the module constant named by const_id into out.value.

§

Unary

bamts_unary(frame, op, operand, out): apply the unary operator op (see [unary_op_selector]) to operand.

§

Binary

bamts_binary(frame, op, left, right, out): apply the binary operator op (see [binary_op_selector]) to left and right.

§

CreateObject

bamts_create_object(frame, out): fresh empty object into out.value.

§

CreateArray

bamts_create_array(frame, out): fresh empty array into out.value.

§

CreateCell

bamts_create_cell(frame, out): fresh compiler-private TDZ cell.

§

CreateClosure

bamts_create_closure(frame, function_id, captures, out): materialize a closure over the named function, binding the captured cells held in the captures array value, into out.value. The runtime reads the callee’s capture_count to copy the leading capture registers.

§

GetProperty

bamts_get_property(frame, object, key, out): out.value = object[key], with key a runtime value coerced to a property key.

§

SetProperty

bamts_set_property(frame, object, key, value, out): object[key] = value.

§

DeleteProperty

bamts_delete_property(frame, object, key, out): out.value = delete object[key].

§

Call

bamts_call(frame, callee, this, arguments, out): call callee with receiver this over the dynamic arguments array value.

§

Construct

bamts_construct(frame, callee, arguments, out): construct with callee over the dynamic arguments array value.

§

Import

bamts_import(frame, specifier, out): import the module named by the string constant specifier into out.value.

§

Truthy

bamts_truthy(frame, value) -> u32: the total ToBoolean coercion, returning 1 when value is truthy and 0 otherwise. Never throws and never writes out.

§

ResumeValue

bamts_resume_value(frame, out): write the verified resumed value for frame into out.value. Resolves the resume-input gap in the native entry ABI (see the crate docs); may return Throw (generator.throw) or FatalTrap.

§

DefineAccessor

bamts_define_accessor(frame, object, key, accessor, kind, out): install a getter or setter (kind, see [accessor_kind_selector]) under key.

§

LoadGlobal

bamts_load_global(frame, name, out): out.value = globalThis[name]; throws a ReferenceError for an undeclared global.

§

StoreGlobal

bamts_store_global(frame, name, value, out): globalThis[name] = value.

§

TypeOfGlobal

bamts_typeof_global(frame, name, out): out.value = typeof globalThis[name]; total, yielding "undefined" for an undeclared global.

§

LoadThis

bamts_load_this(frame, out): load the this binding into out.value. Total.

§

LoadArguments

bamts_load_arguments(frame, out): load the arguments object into out.value. Total.

§

LoadNewTarget

bamts_load_new_target(frame, out): load new.target into out.value. Total.

§

ArrayPush

bamts_array_push(frame, array, value, out): append value to array.

§

ArrayExtend

bamts_array_extend(frame, array, iterable, out): spread iterable onto the end of array.

§

ObjectSpread

bamts_object_spread(frame, target, source, out): copy the own enumerable properties of source onto target.

§

SetPrototype

bamts_set_prototype(frame, object, prototype, out): set the [[Prototype]] of object.

§

CreatePrivateName

bamts_create_private_name(frame, description, out): create a fresh private name into out.value. Total.

§

CreateRegExp

bamts_create_regexp(frame, pattern, flags, out): build a RegExp from the string-constant pattern and flags into out.value.

§

GetIterator

bamts_get_iterator(frame, src, kind, out): acquire an iterator over src using protocol kind (see [iterator_kind_selector]).

§

IteratorNext

bamts_iterator_next(frame, iterator, done_reg, value_reg, out): advance iterator, writing the done flag into handles[done_reg] and the produced value into handles[value_reg] directly (two writes). On Throw, the thrown handle is in out.value and neither slot is written.

§

Export

bamts_export(frame, name, src, out): export the local value src under the string constant name.

§

ConsumeFuel

bamts_consume_fuel(frame, amount, out): reserve amount bytecode instructions from the shared machine budget. Returns FatalTrap on exhaustion and never routes through a bytecode exception handler.

Implementations§

Source§

impl Helper

Source

pub const fn symbol(self) -> &'static str

The C symbol the backend links against.

Source

pub const fn external_index(self) -> u32

The stable helper index within HELPER_NAMESPACE; the index of the u1:<index> external name a backend must resolve to Helper::symbol.

Source

pub const fn from_external_index(index: u32) -> Option<Helper>

The helper for a HELPER_NAMESPACE external-name index, inverting Helper::external_index. Returns None for an unknown index.

Trait Implementations§

Source§

impl Clone for Helper

Source§

fn clone(&self) -> Helper

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 Copy for Helper

Source§

impl Debug for Helper

Source§

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

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

impl Eq for Helper

Source§

impl Hash for Helper

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Helper

Source§

fn cmp(&self, other: &Helper) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Helper

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Helper

Source§

fn partial_cmp(&self, other: &Helper) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Helper

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.