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. - 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.
- 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). - stdlib
- Node.js core modules implemented natively for node-js.
- tiers
- Which fusevm execution tier a program’s bytecode actually reaches.
Enums§
- Value
- Core value type — what lives on the stack and in variables.
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_
str - Parse/load, compile, and run a JS source string on a fresh host (rkyv-cached).
- 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.