Expand description
The JavaScript object heap and runtime, reached from fusevm through
registered builtins (register_builtin) and the strict numeric hook.
node-js owns no VM and no JIT: the compiler lowers JS to fusevm::Chunk, and
every JS-specific operation the VM can’t do natively is a builtin call that
lands here. Local variables live in Rc<RefCell> environments chained
parent-to-child, so a nested function/closure captures its enclosing scope by
reference.
Value representation:
- immediate:
Value::Float(every JS number — one IEEE-754 f64 type),Value::Bool(true/false),Value::Undef(undefined); - heap
Value::Obj(u32)handles: string, array, object, function, builtin-namespace, and the canonicalnull— the reference types.
Modules§
- binop
- Bitwise/shift op tags carried by
ops::BINOP(JS ToInt32/ToUint32 rules). - member
DEF_MEMBERmember-kind tags.- ops
- Builtin ids emitted by the compiler and registered on every VM. The compiler
(
compiler.rs) and the handler table (builtins.rs::install) must agree on these exactly. - unop
- Unary op tags carried by
ops::UNARY. - unwind
SIG_UNWINDscope tags: what the emitting site is nested in.
Structs§
- Class
Val - A live class constructor. The prototype object (holding instance methods) and
the static-side own properties live on the heap;
parentis the superclass constructor value (Nonefor a base class). - EnvData
- A local-variable environment, shared (by
Rc) between a frame and any nested function that captures it. - Frame
- One function activation.
- FuncDef
- A compiled function template: parameter shape + body chunk. Shared by every closure created from the same function/arrow.
- FuncVal
- A live closure value.
- JsHost
- The JavaScript runtime.
- Param
Slot - One parameter slot.
nameis the simple bound name; a destructuring pattern is lowered to a synthetic.arg{i}name plus body prologue code. - Proc
Listener - One
process.on/process.onceregistration.onceis not decoration: aoncelistener must be UNREGISTERED before it runs, so a secondemitof the same event does not reach it. Treatingonceas an alias ofonmadeprocess.once('e', f); process.emit('e'); process.emit('e')callftwice and leave it inprocess.listeners('e')— node v26.7.0 calls it once and reports zero listeners afterwards. - Promise
Cell - A Promise’s settled state and pending reactions.
- Prop
Attrs - The three ECMAScript own-property attributes.
PropAttrs::default()is the all-true shape a plaino.k = vassignment produces, which is why only deviations need storing. - RegExp
Obj - A
RegExpobject: the compiledfancy_regex::Regexplus the JS-visible source, flag booleans, and the mutablelastIndexcursor (used byg/ymatching). fancy-regex adds lookaround + backreferences on top of the Rustregexfast path, so the JS grammar node-js can accept is a near-superset. - Timer
- A scheduled macrotask (
setTimeout/setInterval/setImmediate). Ordering is by(delay, seq)— a deterministic virtual clock, never wall time. - TryDef
- A compiled
try/catch/finallyblock. Bodies are bare chunks run in the current scope.
Enums§
- GenReq
- One queued
[[AsyncGeneratorQueue]]request. ECMA-262 27.6.3.6AsyncGeneratorEnqueuerecords a completion, not just a sent value, which is why.return()and.throw()queue behind pending.next()calls instead of unwinding the body on the spot. - GenStep
- Outcome of resuming a generator: a yielded value (not done), or the final completion value (done).
- JsObj
- A heap object.
- MapKey
- A
Map/Setkey under SameValueZero:NaNcollapses to one key,-0and+0are the same key, primitives compare by value, objects by heap identity. - ObjKind
- Promise
Reaction - A pending Promise reaction: a user
.then(JS handlers + a result promise) or a native continuation (Promise chaining / asyncawaitresumption). - Promise
State - Signal
- A non-local control signal.
Break/Continuecarry the optional loop label and are only raised when the target loop lives in an ENCLOSING chunk (abreakinside atryblock, which the host runs as its own chunk); a same-chunkbreakis a plain compiler-resolved jump. - Super
Ref - The result of resolving
super.name: a getter to invoke (accessor property) or a directly-usable value (method / data property). - Task
- A queued unit of work: either a JS callback invocation (
queueMicrotask,nextTick, timer body) or a native step (Promise reaction / async resume). - This
State - The
[[ThisBindingStatus]]of a function environment (9.1.1.3), as far as it is observable: only a DERIVED class constructor starts withthisuninitialized, and onlysuper()binds it.
Constants§
- CODE_
MARK - The marker
plain_coded_errorhides a code behind, andsynth_errorstrips. - DOM_
MARK - Marks an error string as a
DOMExceptioncarrying a WHATWG error NAME rather than one of the ECMAScript error classes. WebCrypto and the abort APIs reject with these, and the name (NotSupportedError) is not a classsynth_errorcould otherwise recognise. - ERROR_
NAMES - The set of builtin error constructor names forming the error hierarchy.
- FIELDS_
MARK - Marks the start of the extra string own properties a
plain_coded_error_witherror carries after its message. - MAX_
STRING_ LENGTH - V8’s
String::kMaxLengthon a 64-bit build, in UTF-16 code units — the largest string the engine will materialize. - ORD_
MARKER - Prefix of the hidden property-map entry that reserves an accessor’s slot in
own-key insertion order (see
set_accessor). - WELL_
KNOWN_ SYMBOLS - Which variant a heap object is, carrying none of its contents.
Functions§
- array_
index - If
kis an array-index property key, return its numeric value. Per ECMAScript, a String property keyPis an array index iffToString(ToUint32(P)) === PandToUint32(P) !== 2^32 - 1— i.e. a canonical decimal (no leading zeros, no sign) in the range0..=2^32-2. - async_
gen_ enqueue AsyncGeneratorEnqueue— queue one request against anasync function*and hand back the promise its{value, done}record (or rejection) will settle.- async_
gen_ step - One
.next(v)of anasync function*. - async_
step - One step of a
for awaitloop: return a Promise that settles to a{value, done}record. For a native async iterator this isiter.next()(already a promise of the record). For the sync fallback it pops the next raw value, awaits it, and packages{value: resolved, done:false}(or{done:true}at exhaustion). - await_
value - The AWAIT op body (runs inside the async coroutine): suspend, yielding the awaited value; on resume, unwrap the settlement packet (throwing on reject).
- bigint_
to_ f64 - Coerce a BigInt to
f64(forNumber(bigint)and mixed relational compares); out-of-range magnitudes become ±Infinity, matching Node. - build_
class - Build a class constructor value from its parts. The compiler emits (via
MKCLASS) the evaluated parent (or undefined) and the constructor closure (or undefined for a default constructor); methods/getters/setters/statics/fields are installed afterward byDEF_MEMBER/DEF_FIELD. - builtin_
is_ callable - Property read that walks the prototype chain (used by iteration helpers).
Whether the builtin named
nis CALLABLE. Most are (Array,parseInt,Math.floor); the exceptions are the namespace objects a script can only read properties off (Math,JSON, everyrequire()d core module), which reporttypeof === "object"and carry noname/length. - call_
method recv.name(args).- call_
named - Resolve a bare name and call it (
f(args),parseInt(args)). - call_
site_ text - Rewrite a
<subject> is not a function/is not a constructormessage with the SOURCE TEXT of the callee at the currently executing op, as V8 does. - canonicalize_
own_ keys - Reorder an object’s own-property map into
OrdinaryOwnPropertyKeysorder in place: array-index keys ascending first, then the remaining keys in their existing (insertion) order. A no-op unless at least one index key is present, so the overwhelmingly common all-string-key object keeps its exact order and pays nothing.IndexMap::sort_byis a stable sort. - child_
env - A fresh empty scope chained under
parent. - clear_
call_ sites - clear_
yield_ sites - close_
iterator - Call
iterator.return()if it has one, as IteratorClose does. - coded_
error - A Node coded error raised from the JS layer:
Name [ERR_CODE]: message. - construct
- Construct an instance with
new— creates a fresh object, binds it asthis, runs the constructor, and returns the object (unless the constructor returns its own object). - construct_
nt newwith an explicitnew.target(differs fromctorwhen a derived class callssuper(...)— the target stays the originally-newed class).- current_
static_ this - The constructor the running builtin static was called on, if it was reached through a subclass rather than directly.
- define_
field - Register an instance-field initializer thunk on a class (
DEF_FIELD). - define_
member - Install a method / getter / setter on a class (
DEF_MEMBER).kindis amember::*tag;is_statictargets the constructor side. - dom_
error - A
DOMExceptionerror string:nameis the WHATWG error name. - error_
proto - error_
proto_ of - Error prototype lookup with a borrowed host (used inside a
with_hostblock). - fmt_
number - Format a JS number exactly as
Number.prototype.toStringdoes for the common range (no exponential-notation threshold handling for very large/small). - func_
key - Pool key for the body of user function
def_id. - gen_
close - Force a generator to completion (used by
.return()and abandoned loops): marks it done without running further. - gen_
resume - Resume a generator until its next
yieldor its body returns. Preserves the shared host: the coroutine is taken out so the body re-enterswith_hostfreely, and the volatile context is swapped so the caller’s frames/signal survive the switch. - gen_
return generator.return(v): force the generator to complete, running any pendingfinally. If it is already done (or never started) it just reports{value:v, done:true}without executing the body.- gen_
throw generator.throw(e): inject a throw at the suspension point, running any pendingfinallyand letting an enclosingtry/catchin the body handle it.- gen_
yield yield v— suspend the running generator, handingvto the resumer; returns the value the nextgen_resume(x)supplies (a.next(x)argument).- get_
async_ iterator - Obtain an async iterator for
for await. Ifsrchas aSymbol.asyncIteratormethod, use it (its.next()returns a promise of{value, done}); otherwise fall back to the sync iterable, materialized into aJsObj::Iterwhose values are awaited one at a time byasync_step. - get_
prop_ chain - init_
one_ field - Evaluate ONE instance-field initializer thunk and install the result on
inst. - instance_
of obj instanceof ctor— walkobj’s prototype chain looking forctor.prototype.- invalid_
arg_ type TypeError [ERR_INVALID_ARG_TYPE]: The "<name>" <kind> must be of type <expected>. Received …— Node’s single most common argument rejection.- invalid_
string_ length - The error V8 raises for a string operation whose RESULT would exceed
MAX_STRING_LENGTH. It is raised from the length arithmetic, before any allocation:'a'.repeat(2**40)throws promptly on node where node-js used to sit building a 1 TiBStringuntil it was killed. - invoke
- Call any callable value.
- is_
async_ generator - Whether
vis anasync function*object (its.next()yields promises). - is_
callable - Whether
h.get(v)is any callable kind. A Proxy is callable exactly when its target is (10.5: the[[Call]]slot is installed only for a callable target), sotypeofand everyis_callableguard agree on one answer. - is_
primitive - Whether
vis an ECMAScript primitive, i.e.ToPrimitiveis the identity on it.undefined,null, booleans, numbers, strings, symbols and bigints qualify; every other heap cell (objects, arrays, functions,Map/Set, native-tagged instances) is an object and must be converted. - is_
symbol_ key - Whether the internal key
kcame from a SYMBOL used as a property key (@@sym:<id>, or a well-known@@iterator), as opposed to one of node-js’s hidden slots (@@native,@@bytes,@@ms,@@kind, …). Only the former is an observable JavaScript property. - iter_
all - iter_
for_ each - Drive an iterator object (one with a
.next()returning{value, done}) to exhaustion. Stepsrc’s iterator, handing each value tof, and CLOSE the iterator iffexits abruptly (7.4.9 IteratorClose). - iter_
take - Fully materialize any iterable into a vector of values.
Pull at most
nvalues, then close the iterator — 8.6.2 IteratorBindingInitialization, which is what an array destructuring pattern without a...restelement performs. - join_
stack_ pop - Pop the innermost
join_stack_push. - join_
stack_ push - V8’s
JoinStackPush: record thatvis being joined, or reportfalseif it already is. - key_
order_ cmp - Compare two own-property keys for
OrdinaryOwnPropertyKeysenumeration order: integer-index keys sort ascending-numeric and precede all string keys; two non-index keys compareEqualso a stable sort leaves them in insertion order. (Symbols are stored as@@…/#…string keys and are non-index, so they also fall into the stable-insertion-order tail.) - lookup_
accessor - Find a getter/setter accessor for
keyonrecvor up its prototype chain. - lookup_
chain - map_key
- Convert a Map/Set key value into a
MapKeyunder SameValueZero. - name_
call_ site - not_
a_ function_ message - V8’s “not a function” wording for a value that was expected to be callable.
A number/string/boolean is named WITH its value (
number 1 is not a function,string "s" is not a function); every other type is named by type alone (object is not a function,symbol is not a function). - own_
enum_ entries_ deep - The own enumerable
(key, value)pairs ofvwith every enumerable own accessor’s getter invoked — the observable shapeObject.values,Object.entries, object spread andJSON.stringifyall need. Must be called outside awith_hostborrow because a getter re-enters the host. - parked_
iters - The number of loop iterators parked on the stack at the op currently
executing, for the abrupt-completion close in
b_yield. - parse_
bigint_ str - Parse a string to a BigInt under JS
StringToBigIntrules: trimmed, empty →0n, decimal or0x/0o/0bprefixed; any junk →None. - plain_
coded_ error - A Node coded error raised from the native layer:
.codeis set, but the name is never bracketed, soString(err)is the plainName: message. - plain_
coded_ error_ with plain_coded_errorplus extra enumerable string own properties, set aftercodein the order given —new URL('x', 'nope')throws withObject.keys(e)reading["code","input","base"].- plain_
error_ text - An error string as a person reads it:
TypeError: Invalid URL, with the internal code and field markers ofplain_coded_error/plain_coded_error_withremoved. An uncaught native error is printed from its string, and printed the wire format (\u{1}code:ERR_INVALID_URL…). - promise_
of - A promise for
v:vitself if it is already a promise, else a promise resolved withv. - promise_
then - Register a user
.thenreaction (JS handlers + result promise). - protocol_
lookup - Walk
recv’s own props then its prototype chain forkey, returning the stored value (methods, inherited data props). Does NOT invoke accessors. A PROTOCOL lookup —Symbol.toPrimitive,Symbol.hasInstance,toJSON,thenand the rest — which the spec performs with[[Get]]. - range_
error - ref_
error - register_
call_ sites - Record every call site of a freshly built chunk.
- register_
yield_ sites - reject_
promise_ val - reset_
host - Reset the host to a clean slate (fresh module frame).
- resolve_
promise_ val - The Promise “resolve” operation: adopt
value’s state if it is a promise, else fulfill with it. - restore_
site_ tables - Put a snapshot back — what a cache hit does in place of compiling.
- run_
chunk_ in_ global_ scope - Run
chunkin the GLOBAL scope instead of the caller’s. - run_
chunk_ keyed - Run the chunk filed under
key, building it withmakeonly if no VM is already holding it. A recycled VM re-runs the chunk it kept, so a repeated call copies no bytecode at all. - run_
chunk_ on - Register every node-js builtin + the numeric hook on a VM, then run it.
- run_
event_ loop - Drive the event loop to quiescence.
- run_
main - Run the top-level program chunk, then drain the event loop (microtasks + timers) until quiescent — matching Node, which keeps the process alive while pending async work remains.
- run_
user_ func - Execute a user function/closure body on a fresh frame.
- run_
user_ func_ nt - As
run_user_func, but with an explicitnew.target(set bynew). - run_
user_ func_ of run_user_funcwith the function VALUE the call came through, which theargumentsobject needs for itscallee.- set_
debug_ mode - Enable/disable DAP debug execution (
node --dap). - set_
error_ proto - Register a builtin error prototype (for
instanceof Erroretc.). - set_
inspect_ break_ length - Set the
util.inspectbreakLengthfor the next render. - set_
inspect_ compact - Set the
util.inspectcompactoption for the next render (0 forfalse). - set_
inspect_ custom - Set the
util.inspectcustomInspectoption for the next render. - set_
inspect_ max_ array_ length - Set the
util.inspectmaxArrayLengthfor the next render. - set_
inspect_ max_ depth - Set the
util.inspectdepth for the next render (restore to 2 after). - set_
inspect_ show_ hidden - Set the
util.inspectshowHiddenoption for the next render. - set_
inspect_ sorted - Set the
util.inspectsortedoption for the next render. - site_
tables - Snapshot both registries.
- split_
error_ fields - Split a
plain_coded_error_withmessage back into the message and its fields. A message with no field mark comes back whole with no fields. - stack_
exhausted - Whether the native stack is too close to its floor for one more nested run.
- stack_
overflow_ error - The error V8 raises when the call stack is exhausted. Catchable, and with the
RangeErrorconstructor node uses — not apanic!. - string_
ctor_ value String(v)— 22.1.1.1. Identical toto_string_valueexcept that a SYMBOL argument is allowed and renders asSymbol(desc)(step 2a).- subscribe_
native - Register a native reaction on promise
id(schedules immediately if already settled). - super_
construct - Run a parent constructor as part of
super(...): dispatch on the parent’s kind (class vs plain function vs builtin) using the existing instance. Run the parent constructor againstinst. - take_
exc_ or_ error - The JS value of a just-caught error: the live
exc(a real thrown value) or a synthesizedErrorfrom the internal message. - tdz_
error - The error a read of a lexical binding still in its TEMPORAL DEAD ZONE
raises. Distinct from
ref_erroron purpose: node says which of the two happened, and the difference is how a reader tells a misspelled name from aletused above its declaration. - this_
before_ super_ error - The ReferenceError for touching
thisin a derived constructor beforesuper()— or returning from one without calling it. - to_
array_ length ToUint32-validated array length — ECMA-262 10.4.2.2ArrayCreatestep 1 and 10.4.2.4ArraySetLengthstep 3.- to_
number_ value ToNumber(v)— ECMA-262 7.1.4 — with the object case going throughToPrimitive(v, number)first, so+{ valueOf() { return 7 } }is7and+new Date(0)is0.JsHost::to_numberalone cannot do this: it runs under the host borrow and so can never invoke a JSvalueOf.- to_
primitive ToPrimitive(v, hint)— ECMA-262 7.1.1.hintis"default","number"or"string".- to_
property_ key ToPropertyKey(v)— ECMA-262 7.1.19. A symbol keeps its stable internal key; anything else isToPrimitive(v, string)thenToString, soobj[{ toString() { return 'k' } }]really readsobj.k.- to_
string_ value ToString(v)withToPrimitivemethod dispatch: an object is converted with the string hint (so a usertoString— orvalueOf, iftoStringis absent or returns an object — is invoked), then rendered bystr_of. Returns a heap string value.- try_key
- Pool key for one part of
trystatementtry_id: 0 = the block, 1 = the handler, 2 = the finalizer. - type_
error - user_
iterator_ fn - If
vhas an own/inheritedSymbol.iteratormethod (internal key@@iterator), return it. Arrays/strings use the native fast path instead. - with_
host - Run
fwith mutable access to the thread-local host. - with_
static_ this - Run
fwithrecvrecorded as the receiver of a builtin static call.
Type Aliases§
- Accessor
- An accessor property:
(getter, setter), either optional. - Env
- IoTask
- A unit of I/O work handed from a background I/O thread to the main-thread
event loop. It is a boxed closure so
host.rsstays agnostic ofnet/http: the I/O thread captures only plainSenddata (bytes, ids,TcpStreams) and the closure runs the JS-touching dispatch on the main thread (where the thread-local host lives). I/O threads NEVER touch the host directly. - Site
Tables - Every call site and yield site registered so far, as the cache stores them:
(op_hash, ip)keys with their recorded value. - VarMap
- The map behind a scope. Hashing these with
FxHashinstead of the default was measured SLOWER, not faster — fib went 652ms to 1086ms and a 5M-iteration counting loop 1894ms to 2381ms on the same machine — so the default stands.