V8 Engine
About
Written in C++
by Googgle.
Used to transform Javascript to bytecode so that the machine can execute.
Javascript
->C/C++
.C++
->Assembly
.
Used in browsers, nodejs, Deno and others.
Code Compilation
Ignition & Turbofan
V8 traditional way is to compile the code in two phases (Ignition & Turbofan
).

Ignition (Interpreter)
First phase the code is transformed into machine code. This process is fast BUT not optimal.
It is enough to get started.
More detailed steps are:
V8 parses the source code and turns it into an
Abstract Syntax Tree (AST)
, along withscopes
.Based on the
AST
andscopes
, theIgnition
interpreter can produce bytecode.At this point, the engine starts running the code and collecting type feedback.
Turbofan (Optimizing)
The second phase start at the same time as the first one, but it is a slower process as it produces more optimized code.
Once the slow compilation finishes, Javascript switches to that optimal compiled code.
To make it run faster, the byte code can be sent to the optimizing compiler along with feedback data. The optimizing compiler makes certain assumptions based on it and then produces highly-optimized machine code. This happens in parallel and V8 marks frequently used bytecodes as “hot” codes and converts it into more efficient machine code.
Just-in-Time (JIT)
A newer aproach created for the compilation process.
Last updated