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§
- Async
Request - One queued
next/return/throwon an async generator: the reference’sJSAsyncGeneratorRequest. - FdInterest
- A descriptor the host has to poll, and which directions have a handler.
- Field
Cache - One validated property lookup.
- Generator
State - A generator object’s saved execution.
- Interp
- The interpreter: a realm plus a frame stack.
- Realm
- Everything one JavaScript realm owns.
- Well
Known Symbols - The realm’s well-known symbols, indexed by the order
builtins::symbolcreates them in.
Enums§
- Delete
Failure - What a store does when the object refuses the write.
- Hint
- Which type
ToPrimitiveprefers when it converts an object. - Job
- One microtask.
- Resume
Kind - Which of
%GeneratorPrototype%’s three methods resumed a generator. - Signal
- Why execution stopped.
- Suspend
Kind - 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.
- Well
Known - Which well-known symbol a caller wants.
Constants§
- DEFAULT_
STACK_ SIZE - The stack budget when the host sets none: the reference’s
JS_DEFAULT_STACK_SIZE. - MAX_
FRAMES - The frame-count ceiling that backs up
DEFAULT_STACK_SIZE.
Functions§
- debug_
display - How
printrenders a value: the reference’sJS_PrintValue. - display
- How
printrenders a value.
Type Aliases§
- JsResult
- What an execution step produced.