AST → instructions06 / 19

Bytecode: instructions for Ignition

How the bytecode generator turns an AST into instructions for Ignition.

Bytecode contains compact instructions for the Ignition interpreter. They describe the operations to perform: obtain a value, add numbers, call a function, or return a result.

function add(a, b) {
  return a + b;
}

For this function, the generator produces instructions whose meaning is: obtain a, add b, and return the result. Bytecode describes these operations; Ignition executes them.

In the next lesson we will step through these instructions and see how the result changes.

Key takeaway

Bytecode contains instructions for Ignition. The bytecode generator creates them from the AST produced by the parser.

Check the primary source ↗

V8 · Ignition↗The official description of the register-based interpreter.V8 · Ignition design↗The purpose of bytecode and the design of V8's interpreter.V8 · Embedding the virtual machine↗The official documentation calls V8 itself a virtual machine and describes how to embed it in an application.V8 · Generating bytecode from an AST↗The generator takes the parser's AST and produces a sequence of instructions for Ignition.