Skip to main content

Module host

Module host 

Source
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 canonical null — the reference types.

Modules§

binop
Bitwise/shift op tags carried by ops::BINOP (JS ToInt32/ToUint32 rules).
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.

Structs§

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.
ParamSlot
One parameter slot. name is the simple bound name; a destructuring pattern is lowered to a synthetic .arg{i} name plus body prologue code.
TryDef
A compiled try/catch/finally block. Bodies are bare chunks run in the current scope.

Enums§

JsObj
A heap object.
Signal
A non-local control signal.

Functions§

call_method
recv.name(args).
call_named
Resolve a bare name and call it (f(args), parseInt(args)).
construct
Construct an instance with new — creates a fresh object, binds it as this, runs the constructor, and returns the object (unless the constructor returns its own object).
fmt_number
Format a JS number exactly as Number.prototype.toString does for the common range (no exponential-notation threshold handling for very large/small).
invoke
Call any callable value.
ref_error
reset_host
Reset the host to a clean slate (fresh module frame).
run_chunk_on
Register every node-js builtin + the numeric hook on a VM, then run it.
run_main
Run the top-level program chunk.
run_user_func
Execute a user function/closure body on a fresh frame.
type_error
with_host
Run f with mutable access to the thread-local host.

Type Aliases§

Env