liveBook · Manning

Bytecode

As explained in JavaScript in Depth

An intermediate, executable representation of program instructions intended for processing by a virtual machine or runtime.

Bytecode is V8's intermediate instruction format for executing a parsed JavaScript function before specialized machine-code optimization. It is not designed for human readability; it gives the runtime a compact representation that can carry execution feedback. section 6.6.2

A function usually reaches bytecode only when called. V8 pre-parses function bodies to check syntax and identify declarations, then defers full parsing and bytecode generation for unused functions. This reduces initialization work but makes a function's first call slower. section 6.6.1 section 6.6.2

A small bytecode sequence

For `add(a, b) { return a + b; }`, Ignition emits operations that load argument `b`, add argument `a`, and return the accumulator. The add instruction includes a feedback slot where V8 records type information. Consistent numeric calls can support later optimization; a string call invalidates that feedback and requires new instructions. section 6.6.2

[generated bytecode for function: add (0x289efd349e91 <SharedFunctionInfo add>)]
Bytecode length: 6
Parameter count 3
Register count 0
Frame size 0
   20 S> 0x2da5e7fc16f0 @    0 : 0b 04             Ldar a1
   29 E> 0x2da5e7fc16f2 @    2 : 3f 03 00          Add a0, [0]
   33 S> 0x2da5e7fc16f5 @    5 : b3                ReturnReturn

Inspect the generated bytecode for the addition function and map its load, add, feedback-slot, and return operations to the source. section 6.6.2

Bytecode is the first execution tier in V8's pipeline: lazy parsing produces the function representation, Ignition produces bytecode, and repeated execution can lead through baseline or optimizing machine-code tiers. Execution frequency therefore determines how far compilation proceeds. section 6.6.2

How JavaScript in Depth covers it

How deep it goes
Shows instruction meanings, feedback slots, lazy generation, and tier transitions, but does not detail bytecode encoding internals.
Examples
Uses an addition function, generated bytecode instructions, a large deferred function, and repeated getTotal calls to show tier performance.
What it assumes
Assumes familiarity with JavaScript functions, parameters, calls, and basic type differences while introducing the pipeline from parsing to machine code.
What you can do after
Evaluate first-call costs, feedback invalidation, and performance changes across V8's compilation tiers.
How it connects
Connects bytecode with lazy parsing, abstract syntax trees, feedback slots, Ignition, Sparkplug, Maglev, and TurboFan.

Also explained in

Compare how 2 books explain bytecode →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of JavaScript in Depth. The section links point to the parts of the book it draws on.