Skip to main content

Crate nodejs

Crate nodejs 

Source
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).
arity
name and length of the ECMAScript intrinsic functions.
ast
JavaScript abstract syntax tree.
banner
The REPL wordmark. Deliberately NOT printed on startup — the interactive node --repl shows 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 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.
cache
rkyv-backed bytecode cache for compiled JS scripts (mirrors the fleet’s pythonrs/zshrs/rubylang design). Every ordinary node foo.js run is transparently cached: the source is hashed, the shard consulted, and on a hit the compiled fusevm::Chunks run directly — lex/parse/lower are skipped entirely. On a miss the program is compiled, stored, then run. node --build warms 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 node binary.
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 RegExp on top of the fancy_regex crate.
repl
Interactive REPL (node --repl, or node on 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_completion_strict
As compile_completion, with the caller’s strictness folded in — what a direct eval inherits.
compile_debug
Compile with per-statement DAP line markers enabled (node --dap).
compile_or_load
Transparent bytecode cache: return the cached compiled Program for src (skipping lex/parse/lower entirely), else compile it, store it in the ~/.node-js/scripts.rkyv shard, and return it. This runs on EVERY ordinary node foo.js / node -e invocation, so scripts are rkyv-cached automatically — not only under --build. Set NODE_JS_TRACE=1 to log hit/miss to stderr (silent otherwise; normal runs print nothing).
eval_file
Read and run a .js file (transparently rkyv-cached — see compile_or_load).
eval_file_debug
Read and run a .js file under the DAP debugger.
eval_in_global_scope
Compile src and 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 globals bound and the program’s output captured in-process, returning the program’s outcome alongside everything it wrote.
eval_str_from
eval_str with the entry-point NAME node reports for it: [eval] for -e, [stdin] for source piped in. The two are observably different — __filename, module.id and a stack frame’s file all carry it.
eval_str_print
node -p <src>: evaluate as -e does, then write the program’s COMPLETION value through the console.log formatter, exactly as Node’s --print does (node -p '[1,2]' prints [ 1, 2 ], node -p '"s"' prints the bare s). Side effects still happen, so node -p 'console.log("x")' prints x and then undefined.
exit_code
process.exitCode as the program left it, or None if it was never set.
exit_code_after_failure
Run the exit event 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 f on a thread with JS_STACK_SIZE of stack, falling back to the calling thread if the reservation is refused (a ulimited or memory-capped environment must still run programs, just at a lower recursion ceiling — host::stack_exhausted measures whatever stack it ends up on).
with_source
Attach the text a program was parsed from, which its functions’ spans index (Function.prototype.toString).