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.
| idx | variant | params after frame (before out) |
|---|---|---|
| 0 | LoadConstant | const_id: i32 |
| 1 | Unary | op: i32, operand: i64 |
| 2 | Binary | op: i32, left: i64, right: i64 |
| 3 | CreateObject | — |
| 4 | CreateArray | — |
| 5 | CreateClosure | function_id: i32, captures: i64 |
| 6 | GetProperty | object: i64, key: i64 |
| 7 | SetProperty | object: i64, key: i64, value: i64 |
| 8 | DeleteProperty | object: i64, key: i64 |
| 9 | Call | callee: i64, this: i64, arguments: i64 |
| 10 | Construct | callee: i64, arguments: i64 |
| 11 | Import | specifier: i32 |
| 12 | Truthy | value: i64 → i32 (no out, total) |
| 13 | ResumeValue | — |
| 14 | DefineAccessor | object: i64, key: i64, accessor: i64, kind: i32 |
| 15 | LoadGlobal | name: i32 |
| 16 | StoreGlobal | name: i32, value: i64 |
| 17 | TypeOfGlobal | name: i32 (total) |
| 18 | LoadThis | — (total) |
| 19 | LoadArguments | — (total) |
| 20 | LoadNewTarget | — (total) |
| 21 | ArrayPush | array: i64, value: i64 |
| 22 | ArrayExtend | array: i64, iterable: i64 |
| 23 | ObjectSpread | target: i64, source: i64 |
| 24 | SetPrototype | object: i64, prototype: i64 |
| 25 | CreatePrivateName | description: i32 (total) |
| 26 | CreateRegExp | pattern: i32, flags: i32 |
| 27 | GetIterator | src: i64, kind: i32 |
| 28 | IteratorNext | iterator: i64, done_reg: i32, value_reg: i32 (two-write) |
| 29 | Export | name: i32, src: i64 |
| 30 | ConsumeFuel | amount: i32 (total except FatalTrap) |
| 31 | CreateCell | — |
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
impl Helper
Sourcepub const fn external_index(self) -> u32
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.
Sourcepub const fn from_external_index(index: u32) -> Option<Helper>
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§
impl Copy for Helper
impl Eq for Helper
Source§impl Ord for Helper
impl Ord for Helper
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Helper
impl PartialOrd for Helper
impl StructuralPartialEq for Helper
Auto Trait Implementations§
impl Freeze for Helper
impl RefUnwindSafe for Helper
impl Send for Helper
impl Sync for Helper
impl Unpin for Helper
impl UnsafeUnpin for Helper
impl UnwindSafe for Helper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.