Expand description
node-js — JavaScript as a fusevm frontend.
Pipeline: lexer → parser builds a JS AST → compiler lowers it to a
fusevm::Chunk (plus a table of function/arrow sub-chunks and try-block
chunks) → fusevm executes it, calling back into the host (through
registered builtins and the strict numeric hook) for every JS-specific
operation. There is no bespoke VM or JIT here — execution and codegen live in
fusevm.
Modules§
- aot
- Ahead-of-time compilation (
node --build). - aot_
native - Native AOT for node-js via
fusevm::aot(node --build). - ast
- JavaScript abstract syntax tree.
- banner
- The REPL wordmark. Deliberately NOT printed on startup — the interactive
node --replshows a bare prompt with no banner, version stripe, or welcome message (house rule: prompt appears immediately, no startup chatter). Kept as a reusable asset should an explicit, user-requested--version-style banner ever be wanted. - builtins
- Builtin op handlers (compiler-emitted
CallBuiltinids) 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. - cache
- rkyv-backed bytecode cache for compiled JS scripts (mirrors the fleet’s
pythonrs/zshrs/rubylang design). Every ordinary
node foo.jsrun is transparently cached: the source is hashed, the shard consulted, and on a hit the compiledfusevm::Chunks run directly — lex/parse/lower are skipped entirely. On a miss the program is compiled, stored, then run.node --buildwarms the same shard ahead of time. - capture
- Does a piece of a program hold on to the scope it runs in?
- cli
- Command-line interface for the
nodebinary. - compiler
- Lower the JavaScript AST to
fusevm::Chunk. - dap
- Debug Adapter Protocol over stdio (
node --dap). - host
- The JavaScript object heap and runtime, reached from fusevm through
registered builtins (
register_builtin) and the strict numeric hook. - lexer
- JavaScript tokenizer.
- lsp
- Builtin / keyword / method corpus for offline documentation.
- module
- CommonJS module loader.
- parser
- JavaScript parser: token stream → AST.
- proxy
Proxy— the ECMAScript exotic object (10.5) whose essential internal methods are redirected to a handler’s traps.- regexp
- JavaScript
RegExpon top of thefancy_regexcrate. - repl
- Interactive REPL (
node --repl, ornodeon a TTY). - rust_
ffi - JavaScript wiring for inline Rust FFI (
rust { ... }blocks). - slots
- Which locals can live in fusevm frame slots instead of the host’s scope chain.
- stdlib
- Node.js core modules implemented natively for node-js.
- tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
- utf16
- The UTF-8 ⇄ UTF-16 boundary for JS string indices.
Enums§
- Value
- Core value type — what lives on the stack and in variables.
Constants§
- JS_
STACK_ SIZE - Stack reserved for the thread JS runs on (
run_on_js_stack).
Functions§
- compile
- Compile a source string to a runnable program.
- compile_
completion - Compile leaving the final top-level expression as the program’s completion
value (for
vm.runInThisContext/eval). - compile_
debug - Compile with per-statement DAP line markers enabled (
node --dap). - compile_
or_ load - Transparent bytecode cache: return the cached compiled
Programforsrc(skipping lex/parse/lower entirely), else compile it, store it in the~/.node-js/scripts.rkyvshard, and return it. This runs on EVERY ordinarynode foo.js/node -einvocation, so scripts are rkyv-cached automatically — not only under--build. SetNODE_JS_TRACE=1to log hit/miss to stderr (silent otherwise; normal runs print nothing). - eval_
file - Read and run a
.jsfile (transparently rkyv-cached — seecompile_or_load). - eval_
file_ debug - Read and run a
.jsfile under the DAP debugger. - eval_
in_ global_ scope - Compile
srcand run it on the LIVE host — no reset, no event-loop drain — in the GLOBAL scope, returning its completion value. - eval_
str - Parse/load, compile, and run a JS source string on a fresh host (rkyv-cached).
- eval_
str_ captured - Run a JS source string on a fresh host with
globalsbound and the program’s output captured in-process, returning the program’s outcome alongside everything it wrote. - eval_
str_ from eval_strwith the entry-point NAME node reports for it:[eval]for-e,[stdin]for source piped in. The two are observably different —__filename,module.idand a stack frame’s file all carry it.- eval_
str_ print node -p <src>: evaluate as-edoes, then write the program’s COMPLETION value through theconsole.logformatter, exactly as Node’s--printdoes (node -p '[1,2]'prints[ 1, 2 ],node -p '"s"'prints the bares). Side effects still happen, sonode -p 'console.log("x")'printsxand thenundefined.- exit_
code process.exitCodeas the program left it, orNoneif it was never set.- exit_
code_ after_ failure - Run the
exitevent for a program that died on an uncaught exception, and report the status to leave with. - load_
merged - Rebase a freshly compiled program’s func/try ids above those already loaded on the host, install its functions/tries, and return the (rebased) main chunk to run.
- run_
compiled - Run an already-compiled program on the current host.
- run_
on_ js_ stack - Run
fon a thread withJS_STACK_SIZEof stack, falling back to the calling thread if the reservation is refused (aulimited or memory-capped environment must still run programs, just at a lower recursion ceiling —host::stack_exhaustedmeasures whatever stack it ends up on).