This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
V8 uses GN + Ninja build system. The primary development tool is tools/dev/gm.py:
# Quick build and test
tools/dev/gm.py x64.release # Build release mode
tools/dev/gm.py x64.debug # Build debug mode
tools/dev/gm.py x64.release.check # Build and run tests
# Direct build commands
gn gen out/x64.release --args='is_debug=false target_cpu="x64"'
ninja -C out/x64.release d8
# Common build configurations
gn gen out/x64.debug --args='is_debug=true v8_enable_verify_heap=true'
gn gen out/arm64.release --args='is_debug=false target_cpu="arm64"'# Run all tests
tools/run-tests.py --outdir out/x64.release
# Run specific test suites
tools/run-tests.py --outdir out/x64.release mjsunit cctest unittests
# Run specific test patterns
tools/run-tests.py --outdir out/x64.release mjsunit/array-*
# Run single test file
tools/run-tests.py --outdir out/x64.release test/mjsunit/specific-test.js
# Use gm.py for automatic build detection
tools/dev/gm.py x64.release mjsunit/array-*Test files can specify V8 flags via comments: // Flags: --allow-natives-syntax
Parser → Ignition (interpreter) → Sparkplug (baseline) → Maglev (mid-tier) → TurboFan (optimizing)
src/execution/- Isolates, frames, stack managementsrc/interpreter/- Ignition bytecode interpretersrc/compiler/- TurboFan optimizing compilersrc/maglev/- Maglev mid-tier compilersrc/heap/- Garbage collector and memory managementsrc/objects/- V8 object systemsrc/builtins/- JavaScript built-in implementationssrc/wasm/- WebAssembly implementationsrc/codegen/{arch}/- Architecture-specific code generation
Architecture-specific code in src/codegen/ subdirectories:
- x64, ia32, arm, arm64, riscv32, riscv64, ppc64, s390x, loong64, mips64
test/mjsunit/- Main JavaScript unit teststest/cctest/- C++ unit teststest/unittests/- Isolated unit teststest/inspector/- DevTools protocol teststest/wasm/- WebAssembly tests
--allow-natives-syntax- Enable test/debug intrinsics--trace-gc- Trace garbage collection--print-opt-code- Print optimized code--trace-deopt- Trace deoptimizations--verify-heap- Enable heap verification
# Run d8 shell
out/x64.release/d8
# Run script with debugging
out/x64.debug/d8 --trace-gc --verify-heap script.jsFollows Google C++ Style Guide. Check style with:
tools/cpplint.py src/your-file.cc- Handles: Use Local, Persistent, or Global handles for GC-safe object references
- Heap Spaces: Young generation, old generation, large object space
- GC: Generational, concurrent, and incremental collection
Security feature that isolates V8's heap. Enable with v8_enable_sandbox=true in build args.
V8 objects defined in src/objects/. Key classes:
- HeapObject - Base for all heap-allocated objects
- JSObject - JavaScript objects
- Map - Hidden class describing object layout