Skip to content

Compiler & Interpreter

Modern JavaScript engines use a JIT (Just-In-Time) compilation approach — they interpret code initially for fast startup and compile hot paths to machine code for performance.

V8’s Ignition interpreter executes bytecode directly. It’s fast to start but slower than compiled code.

// Bytecode (Ignition)
// LdaGlobal 'console' ; Load global
// Star0 ; Store
// LdaNamedProperty r0, 'log'
// Star1
// LdaSmi [42]
// CallProperty1 r1, r0

TurboFan compiles frequently executed (“hot”) functions to highly optimized machine code.

flowchart TD
A["Function starts"]
B["Ignition interprets bytecode"]
C["Is function hot?"]
D["TurboFan compiles to machine code"]
E["Execute optimized code"]
F["Deoptimize on type change"]
A --> B
B --> C
C -->|No| B
C -->|Yes| D
D --> E
E -->|"✅ Works"| E
E -->|"❌ Type change"| F
F --> B
FeatureInterpreterCompiler
Start timeFastSlow
Execution speedSlowFast
OptimizationNoneExtensive
MemoryLessMore
  • Interpretation: fast start, slow execution (Ignition)
  • Compilation: slow start, fast execution (TurboFan)
  • JIT combines both — starts interpreting, compiles hot paths
  • Can deoptimize when assumptions break