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§

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.
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.