liveBook · Manning

Machine language

As explained in JavaScript in Depth

Processor-executable instructions produced by a compiler from a higher-level program representation.

Machine language is the processor-executable form reached after higher-level code passes through compilation. In V8, JavaScript does not jump directly to final machine code: frequently executed functions move from bytecode through baseline compilation toward highly optimized machine code. section 6.6.2

The pipeline changes representation and optimization level as execution data accumulates:

  • Ignition compiles parsed functions into bytecode, a simplified instruction set intended for the runtime rather than human readers. section 6.6.2
  • Feedback slots record type information for individual instructions; stable numeric inputs can support optimization, while a string input can invalidate prior assumptions. section 6.6.2
  • Sparkplug and Maglev provide baseline machine-code stages, while TurboFan produces highly optimized machine code for sufficiently hot functions. section 6.6.2

A small addition function

For function add(a, b) { return a + b; }, generated bytecode loads the second argument, adds the first through a feedback slot, and returns the accumulator. Repeated numeric calls can enable optimization; changing the input type can force V8 to restart with new instructions. section 6.6.2

Figure 6.1 The V8 Compilation Pipeline

Use the pipeline figure to trace movement from lazy parsing through interpretation, baseline compilation, and optimized machine code. section 6.6.2

How JavaScript in Depth covers it

How deep it goes
Descends to bytecode instructions, registers, feedback slots, and optimization tiers, while not detailing every machine-code transformation.
Examples
Uses an add function, generated bytecode, and getTotal benchmarks to show how execution tiers affect performance.
What it assumes
Assumes JavaScript functions and basic execution knowledge while introducing bytecode, feedback slots, and tiered compilation.
What you can do after
Diagnose performance cliffs by relating call frequency, input-type stability, optimization tiers, and discarded machine code.
How it connects
Connects machine language with compilers, bytecode, type feedback, runtime optimization, and deoptimization.

Also explained in

Compare how 2 books explain machine language →

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.