docs/overview.md
V8 is Google's open source high-performance JavaScript and WebAssembly engine, written in C++. It is used in Google Chrome and in Node.js, among others.
This document provides a high-level overview of V8's architecture and execution pipeline.
V8 executes JavaScript code using a multi-tier execution pipeline. The goal is to start executing code as quickly as possible and then optimize hot code for peak performance.
src/parsing/)Responsible for scanning and parsing JavaScript source code into an Abstract Syntax Tree (AST).
src/interpreter/)Ignition is V8's register-based interpreter. It executes bytecode and collects profiling information used by optimizing compilers.
src/baseline/): Compiles bytecode directly to machine code without complex optimizations.src/maglev/): Generates optimized code quickly, filling the gap between Sparkplug and TurboFan.src/compiler/): V8's traditional peak optimizing compiler based on a sea-of-nodes IR.src/compiler/turboshaft/): The new optimizing compiler pipeline that replaces TurboFan's sea-of-nodes IR with a more efficient linear IR.src/heap/)V8 manages memory in a garbage-collected heap. It uses a generational garbage collector with a young generation (semi-space) and an old generation. It also employs concurrent and parallel marking and sweeping techniques to minimize pause times.
src/objects/)V8 uses "Maps" (also known as hidden classes or shapes) to represent the structure of JavaScript objects. This allows for fast property access via Inline Caching (IC).
src/wasm/)V8 provides a full-featured WebAssembly implementation, including a streaming compiler and integration with the JavaScript garbage collector.
src/sandbox/)A security feature that protects the integrity of the V8 heap by ensuring that memory corruptions cannot easily access memory outside the sandbox.
src/builtins/)Implementations of JavaScript built-in objects and functions, often written in Torque or CodeStubAssembler for performance.
src/snapshot/)Used to speed up startup by serializing the heap state and deserializing it when new isolates are created.
include/ and src/api/)V8 can be embedded in other C++ applications. The public API is defined in include/ and implemented in src/api/.