Skip to main content

Module interp

Module interp 

Source
Expand description

The bytecode interpreter.

The machine is the same shape as the reference’s: a value stack per frame, a program counter into js_compile’s resolved bytecode, and a frame chain. Two properties of that design are worth stating up front because they are visible everywhere below.

Frames are explicit, not recursive. A JavaScript call pushes a frame onto Interp::frames and the loop continues; it never recurses in Rust. Deep JavaScript recursion therefore costs heap, not C stack, and the depth limit is ours to enforce rather than the host’s to crash.

Exceptions live on the value stack. catch pushes a Value::CatchOffset marker and an exception is found by walking the frame’s stack downwards looking for the innermost one. There is no side table, which is why a try inside a loop costs nothing until it throws.

Structs§

AsyncRequest
One queued next/return/throw on an async generator: the reference’s JSAsyncGeneratorRequest.
FdInterest
A descriptor the host has to poll, and which directions have a handler.
GeneratorState
A generator object’s saved execution.
Interp
The interpreter: a realm plus a frame stack.
Realm
Everything one JavaScript realm owns.
WellKnownSymbols
The realm’s well-known symbols, indexed by the order builtins::symbol creates them in.

Enums§

DeleteFailure
What a store does when the object refuses the write.
Hint
Which type ToPrimitive prefers when it converts an object.
Job
One microtask.
ResumeKind
Which of %GeneratorPrototype%’s three methods resumed a generator.
Signal
Why execution stopped.
SuspendKind
Why a frame parked, which decides how the resumption is delivered.
Task
One macro-task: work the event loop owes the script but has not run yet.
Turn
What one turn of the event loop did, so the caller cannot spin by accident.
WellKnown
Which well-known symbol a caller wants.

Functions§

debug_display
How print renders a value: the reference’s JS_PrintValue.
display
How print renders a value.

Type Aliases§

JsResult
What an execution step produced.