Expand description
The register machine: the register file and frame table, the main loop, its slow paths, exception unwinding and the leaf-native ABI.
A frame owns a window of the register file: register 0 is this, then
the parameters, the locals and the operand temporaries of its code unit. A
call’s window starts inside the caller’s, on the callee’s operands, so no
argument is copied. Both tables live inside the Heap as fixed roots:
a safepoint marks registers[..top] and every frame’s function.
Modules§
- compile
- Code compiled at run time:
eval, theFunctionconstructors,$262.evalScriptandFunction.prototype.toString’s source text, through the compile host the embedder installs. - frame_
flags - ic
- Inline caches: one 16-byte entry per cache site, in a store beside the code store.
- module
- ECMAScript modules.
- native
- The native ABI: host functions that read their receiver and arguments from
the register file by index and call back into JavaScript through the
re-entrant
callandconstructas straight-line Rust. A native roots what it holds across an allocation or a call on the root stack, which is cut back when it returns. The natives themselves are the realm’s builtins (crate::builtins). - regexp
- Regular-expression objects: the program store and the
RegExpobject kind. A literal allocates a new object on every evaluation, as the specification requires, over one compiled program per distinct(source, flags), compiled on first use;new RegExp(source, flags)shares the store, so a program built in a loop does not grow it without bound. The store lives in the heap: aRegExpobject’s payload names its program, a collection marks the programs of the live objects (and their two atoms), and sweeps the rest.
Structs§
- Services
- Runtime state the natives reach beside the heap: output, the random
stream, the symbol registry, and the embedder’s
Host. - Throw
- A thrown JavaScript value. It is not rooted: whoever receives it stores it in a register, a root or a handle before the next allocation.
- VmStack
- The register file and the frame table.
Enums§
Constants§
- DEFAULT_
STACK_ LIMIT - Registers the file may hold before a call fails with
InternalError: stack overflow: 8 MiB of values. - INTERRUPT_
INTERVAL - Back-edges and calls between two interrupt polls. QuickJS’s
JS_INTERRUPT_COUNTER_INITis 10,000; a tenth of it costs the loop nothing measurable (the poll is cold), and stops a script ten times sooner. - NATIVE_
STACK_ BUDGET - Native stack bytes nested re-entries may use (debug builds have large loop frames; the default thread stack of a test is 2 MiB).