kdocs
GitHub
Lang - Runtime
Lang - Runtime
  • Go
    • Modules & Packages
    • Variables
    • Structs
    • Interfaces
    • Functions
    • Control Structures
    • Erro Handling
    • Concurrency
    • Testing
    • Fuzzing
  • Web
    • V8 Engine
    • Node.js
      • New Project
    • Deno
      • New Project
Powered by GitBook
On this page
  • About
  • Code Compilation
  • Ignition & Turbofan
  • Just-in-Time (JIT)
  1. Web

V8 Engine

PreviousFuzzingNextNode.js

Last updated 4 months ago

About

Written in C++ by Googgle.

Used to transform Javascript to bytecode so that the machine can execute.

  1. Javascript -> C/C++.

  2. 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 with scopes.

  • Based on the AST and scopes, the Ignition 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.