Skip to main content

Module builtins

Module builtins 

Source
Expand description

Builtin op handlers (compiler-emitted CallBuiltin ids) plus the JS standard library (console, Math, JSON, Object, array/string methods) reachable from the host. Handlers pop their arguments off the VM operand stack and return the result value, which the VM pushes back.

Constants§

DEFAULT_PREPARE
[[Get]](name, receiver) — 10.1.8. receiver is the object the read STARTED from and is what a getter sees as this; it differs from recv only when the read was forwarded down a prototype chain, which is why Reflect.get(t, k, r) and a Proxy get trap’s third argument both need it. Every ordinary read passes recv itself. Re-format an error’s .stack header on its first read, the way V8 does.
DOM_EXCEPTION_CODES
The legacy numeric DOMException.code a WHATWG error name maps to. A name outside the table — including the default "Error" — reports 0.
OBJECT_PROTO_METHODS
The Object.prototype methods installed as thunks on the real Object.prototype object, so Object.prototype.toString.call(x) and a class prototype’s inherited hasOwnProperty both resolve through the chain.
REQUIRE_CACHE
The namespace name of the require.cache view. A Builtin rather than an object literal because the module cache is the single source of truth: a populated copy would answer reads correctly and silently ignore a delete, which is the operation the property exists for.

Functions§

builtin_meta
The name and length a builtin function reports, from the generated intrinsic table (crate::arity::BUILTIN_ARITY). None for a key the table does not cover — every non-function namespace (Math, require('fs')), and the core-module functions, whose arity is not specified anywhere.
builtin_name
The name a builtin function reports. The table answers for an intrinsic; anything else falls back to the last segment of the key, which is what the name is for every builtin this frontend synthesizes: @proto:TypedArray:set is set and fs.readFileSync is readFileSync. Reporting the whole key was how [Function: @proto:TypedArray:set] reached console.log.
call_builtin_function
Call a resolved builtin function (global or namespace.method).
call_type_method
Dispatch recv.name(args) for the built-in prototype methods.
construct_builtin
Construct via new for the builtin constructors.
define_property_pub
[[DefineOwnProperty]] reachable from crate::proxy’s no-trap forward.
delete_property
[[Delete]] (10.1.10) for an already-resolved property key: the one place delete o[k], delete o.k and Reflect.deleteProperty all go through, so the three cannot drift. Reports false for a non-configurable property (sloppy mode ignores the failure rather than throwing) and true otherwise, which is also what deleting an absent key reports.
dom_exception
new DOMException(message, name).
dom_exception_slot
A DOMException’s name/message/code, which live in internal slots rather than as own properties. None for anything else.
dynamic_function
Build a callable from a complete function-expression source text — the ONE dynamic-function generator on this frontend.
error_string
A short Name: message string for an error value (used when an await rejection unwinds as a thrown error).
eval_source
eval(src). direct selects the scope the source runs in: a DIRECT eval — the literal eval(...) call form — evaluates in the CALLER’s scope, every other route to the same function value is an INDIRECT eval and evaluates in the global scope (ECMA-262 19.2.1.1 PerformEval). The two are told apart in host::call_named, which ops::CALL reaches and ops::CALL_VALUE/APPLY do not.
function_builtin_method
Function.prototype methods (call/apply/bind) plus Symbol.prototype/ generator handling done elsewhere. Returns Ok(None) if name is not one of these (so the caller can try statics).
function_ctor
new Function(p1, …, pN, body) / Function(p1, …, pN, body).
get_property
get_property_recv
has_property
key in obj respecting the prototype chain. Reports a Result because a Proxy’s has trap is user code and may throw.
install
Register every node-js builtin id on a VM.
is_arguments
The bare brand name behind Object.prototype.toString (Array, Uint8Array …), without the [object …] wrapper. Split out so the brand and the Symbol.toStringTag property read cannot disagree about what a value is. Whether v is a function’s arguments object.
is_arguments_h
is_arguments for a caller that already holds the host borrow — object_brand runs under one, and re-entering through with_host aborts the process.
is_known_builtin
is_object_builtin_method
materialize_stack
namespace_constants
The numeric constants a core namespace owns, in the order node reports them under getOwnPropertyNames. ONE table rather than a value match plus a name list: the enumeration and the read have to agree, and they did not — every one of these read correctly while Object.getOwnPropertyNames(Math) omitted all eight of Math’s, so a member that plainly exists was invisible to any reflective copy of the namespace.
namespace_property
A property on a builtin namespace object (Math.PI, Number.MAX_SAFE_INTEGER, console.log).
numeric_hook
Host callback for arithmetic fusevm cannot complete natively (a non-Int/ non-Float operand). Supplies JavaScript + concatenation and coercion.
object_builtin_method
Dispatch an Object.prototype builtin method on an object/instance.
own_descriptor_pub
[[GetOwnProperty]] reachable from crate::proxy’s no-trap forward.
own_prop_facts
An object’s OWN property as (value, writable, configurable, is_accessor), or None when it has none. Reads through a Proxy’s getOwnPropertyDescriptor trap, so it answers for any object.
pending_promise_with_resolver
Promise.withResolvers() — a fresh pending promise paired with its own resolve/reject continuations (the same @@presolve/@@preject thunks the executor receives), returned as a plain { promise, resolve, reject } object. A fresh pending promise paired with the thunk that resolves it, for stdlib callers that hand the resolver to an event listener.
private_brand_message
The TypeError a failed private brand check raises. Node words it two ways: a private METHOD or accessor names the class the receiver should have been an instance of, while a private FIELD names the member.
promise_resolve_pub
Promise.resolve(v) for stdlib callers that need to hand back an already-settled promise.
promise_species_from
The species constructor of a promise RECEIVER — what then/catch/finally build their result with (SpeciesConstructor(p, %Promise%), 27.2.5.4 step 3).
proto_getter_name
The name of an intrinsic accessor’s getter thunk, or None for anything else. Kept out of builtin_name’s &str return, which cannot own the "get size" it has to build.
proto_method
prototype_of
[[GetPrototypeOf]] (10.1.1) — the answer Object.getPrototypeOf, Reflect.getPrototypeOf and a __proto__ READ all have to agree on.
set_property_pub
[[Set]] reachable from crate::proxy’s no-trap forward, which has to land on the same path a plain o.k = v takes.
set_with_receiver
OrdinarySetWithOwnDescriptor (10.1.9.2) with a receiver distinct from the object the lookup started on — what Reflect.set(t, k, v, receiver) and a proxy set trap forwarding to it both need.
to_bigint
ToBigInt(v) — 7.1.13. The conversion every BigInt-typed SINK performs: a 64-bit typed array’s element write, DataView.prototype.setBigInt64, and BigInt arithmetic’s operand check.
to_object
ToObject(v) (7.1.18) for a primitive: the wrapper object with the matching prototype and a [[StringData]]/[[NumberData]]/[[BooleanData]] slot.
uses_side_table
Object(x): box/pass-through — for our model, non-object args just return a fresh object; objects pass through. Whether v’s own properties live in the fn-prop SIDE TABLE rather than in a property map. A Map/Set/Promise/RegExp/generator/symbol/bigint is an ordinary object that also has internal slots, so it can carry own properties like anything else — but its heap variant holds only those slots, so a write had nowhere to go and vanished: m.x = 5 left m.x undefined.
wrapped_primitive
The primitive a wrapper object boxes (new String("a") → "a"), or None for every other value. The slot is a hidden @@primitive own property — the same @@ marker convention the engine already uses for internal state, so it stays out of Object.keys and JSON.stringify on its own.