tree: 36bef95ad9fc8491a2ff394e0614ca92f9868499 [search]
  1. builtins/
  2. codegen/
  3. compiler/
  4. heap/
  5. interpreter/
  6. objects/
  7. parsing/
  8. regexp/
  9. runtime/
  10. sandbox/
  11. security/
  12. snapshot/
  13. torque/
  14. viewer/
  15. wasm/
  16. api.md
  17. become-committer.md
  18. benchmarks.md
  19. blink-layout-tests.md
  20. build-gn.md
  21. build.md
  22. builtin-functions.md
  23. committer-responsibility.md
  24. compile-arm64.md
  25. contribute.md
  26. cross-compile-arm.md
  27. cross-compile-ios.md
  28. d8.md
  29. debug-arm.md
  30. design-review-guidelines.md
  31. embed.md
  32. evaluate-code-coverage.md
  33. feature-launch-process.md
  34. flake-bisect.md
  35. gdb-jit.md
  36. gdb.md
  37. i18n.md
  38. ide-setup.md
  39. index.md
  40. inspector.md
  41. javascript-overview.md
  42. linux-perf.md
  43. memory-leaks.md
  44. merge-patch.md
  45. node-integration.md
  46. official-support.md
  47. overview.md
  48. OWNERS
  49. ports.md
  50. profile-chromium.md
  51. profile.md
  52. rcs.md
  53. README.md
  54. release-process.md
  55. respectful-code.md
  56. source-code.md
  57. stack-trace-api.md
  58. test.md
  59. trace.md
  60. triage-issues.md
  61. untrusted-code-mitigations.md
  62. version-numbers.md
  63. wasm-shipping-checklist.md
  64. webassembly-opcode.md
docs/README.md

V8 Architecture and Engineering Documentation

Welcome to the V8 codebase architecture documentation. These guides are designed for both human engineers onboarding to V8 (providing a clear conceptual model at the top of each document) and experienced V8 developers and AI coding agents (providing exact C++ class names, bitfield layouts, cross-tier invariants, and sharp edges verified against src/).

(Note: The top-level .md files directly inside docs/ are legacy copies of historical v8.dev/docs articles. The structured subsystem and cross-component documentation lives in the subdirectories indexed below.)


1. Parsing, Scopes, and TDZ Hole Check Elision (docs/parsing/)

How JavaScript source text is scanned, parsed into an AST, analyzed for variable allocation, and checked for Temporal Dead Zone (TDZ) invariants across tiers:

  • Parser, Scanner, and AST: Scanner (1-character c0_ lookahead + 4-token TokenDesc ring buffer), off-heap AstRawString / AstConsString deduplication in AstValueFactory (internalized in Parser::PostProcessParseResult), ParserBase<Impl> CRTP, single-pass ambiguity resolution via ExpressionScope, vtable-free AstNode bit-packing, DeclarationScope::Analyze, and Rewriter::Rewrite (.result).
  • Lazy Parsing, PreParser, and PreparseData: Eager vs lazy compilation heuristics (IIFE/PIFE detection), ParserTypes<PreParser> (PreParserExpression 32-bit bitfields), why PreParser tracks outer variable references (VariableProxy), and how ProducedPreparseData / ConsumedPreparseData avoid re-preparsing nested functions.
  • TDZ Hole Check Elision Overview (Cross-Component Pipeline): End-to-end overview of how V8 represents lexical TDZ bindings with tdz_hole_value (TdzHole) and eliminates redundant checks across three compiler stages:
    • Stage 1: Parser & Scope Hole Check Elimination: Static position analysis in UpdateNeedsHoleCheck (src/ast/scopes.cc), ScopeInfo::kMaxVariablePositionDistance, module import & kDynamic/kDynamicLocal edge cases, and eliding LdaTdzHole via ForceHoleInitializationFlag.
    • Stage 2: Bytecode Hole Check Elision: Ignition's 64-bit Variable::HoleCheckBitmap (tracking up to 63 variables per function in bits 1..63), HoleCheckElisionScope, and branch intersection via HoleCheckElisionMergeScope.
    • Stage 3: Optimizing Compiler Hole Check Elision: Maglev (ValueNode::IsTdzHole(), ThrowReferenceErrorIfTdzHole, KnownNodeAspects) and TurboFan / Turboshaft (TdzHoleConstant, RootEqual) hole check elimination, including how Maglev prevents LoadContextSlotNoCells (loaded_context_constants_) in the “Inverted Generator” pattern from poisoning catch block merges before ThrowReferenceErrorIfTdzHole.

2. Object Model, Hidden Classes, and Sentinels (docs/objects/)

How JavaScript values, strings, hidden classes (Maps), properties, elements, and internal sentinels are laid out in the V8 heap:

  • Holes and Internal Sentinels (Cross-Component Guide): Why V8 segregates ReadOnlyRoots holes (TheHole strictly for array/dictionary elements, TdzHole for lexical TDZ & derived this, PropertyCellHole, HashTableHole, PromiseHole, UninitializedHole, ExceptionHole, TerminationException, OptimizedOut, etc.), --unmap-holes 64 KB hardware guard pages (Hole::kPayloadSize), kHoleNanInt64 vs user NaN canonicalization (DOUBLE_LITERAL vs HOLEY_DOUBLE_LITERAL), and two-phase literal boilerplate initialization (JSDataObjectBuilder / FoldedMutableHeapNumberAllocation / gc-observable stores).
  • Strings: Representations, Encoding, and Hashing: InstanceType low 7-bit string encoding (kStringRepresentationMask, kIsIndirectStringMask, kStringEncodingMask, kUncachedExternalStringMask, Bit 5 kSharedStringMask, and Bit 6 kIsNotInternalizedMask), SeqString, ConsString in-place flattening and GC shortcutting, SlicedString, ExternalString / UncachedExternalString, ThinString, and Name::raw_hash_field_ (kHash, kIntegerIndex, kForwardingIndex in StringForwardingTable, kEmpty).
  • DescriptorArrays and TransitionArrays: DescriptorArray header (number_of_all_descriptors, number_of_descriptors, slack descriptors, concurrent marking raw_gc_state, EnumCache), 3-slot entry layout, FieldType encoding (None, Any, Weak<Map>), DescriptorPointer binary search, TransitionsAccessor::Encoding (6 inline/out-of-line states), TransitionArray, and SideStepTransition (kCloneObject, kObjectAssign).
  • Fields, Elements, and Map Generalization: In-object fields vs PropertyArray, why Representation::Double() fields box values in mutable HeapNumbers under pointer compression, SwissNameDictionary (SIMD SSE2/NEON H2 probing + insertion-order meta_table), ElementsKind transition sequence (kFastElementsKindSequence vs enum order warning), and MapUpdater generalization.
  • LookupIterator: Property Resolution State Machine: receiver_ vs lookup_start_object_ (super.prop), holder_, the LookupIterator::State machine (ACCESS_CHECK, INTERCEPTOR, JSPROXY, TYPED_ARRAY_INDEX_NOT_FOUND, DATA, ACCESSOR, TRANSITION), two-pass masking vs non-masking InterceptorState, and write transitions (PrepareForDataProperty, PrepareTransitionToDataProperty).

3. Execution Runtime, ICs, Tiering, and Deoptimization (docs/runtime/)

How V8 executes functions, caches property accesses, walks the call stack, unwinds exceptions, tiers up across compilers, and deoptimizes back to bytecode:

  • Function Architecture (JSFunction, SharedFunctionInfo, Context, FeedbackVector): Separation of per-definition SharedFunctionInfo (dual trusted_function_data_ and untrusted_function_data_ slots) from per-closure JSFunction (context() invariant pointing to the creation scope's Context), JSDispatchTable dispatch (dispatch_handle_), and the three-stage FeedbackCell lifecycle (Undefined -> ClosureFeedbackCellArray -> FeedbackVector).
  • Scopes, Contexts, ScopeInfo, and ContextCell: Compile-time Scope analysis vs persistent ScopeInfo bit-packing, runtime Context chains, and ContextCell state specialization (kConst, kSmi, unboxed kInt32, unboxed kFloat64, and kDetached with DependentCode deoptimization).
  • Hidden Classes and Inline Caches (ICs): IC state lattice (UNINITIALIZED -> MONOMORPHIC -> POLYMORPHIC -> MEGAMORPHIC), LoadHandler and StoreHandler Smi bitfields, variable-length DataHandler (smi_handler_, validity_cell_, data1..data5), prototype validity cells, and the three per-Isolate StubCaches (load_stub_cache_, store_stub_cache_, define_own_stub_cache_ with primary_ and secondary_ tables).
  • Hidden Classes Step-by-Step Tutorial: Walkthrough of hidden-class transitions, shared DescriptorArray prefixes, branching TransitionArrays, and PropertyConstness::kConst constant folding (DependentCode::kFieldConstGroup).
  • Execution Tiers and the TieringManager: How FeedbackCell::interrupt_budget_ drives TieringManager::OnInterruptTick, feedback allocation + Sparkplug batch compilation on the 1st interrupt tick, IC stabilization (NotifyICChanged), JSDispatchTable::SetTieringRequest (TieringBuiltin), and On-Stack Replacement (FeedbackVector::osr_urgency, JumpLoop loop_depth, and Maglev-to-TurboFan deopt-to-OSR).
  • Deoptimization Architecture: DeoptimizeKind::kEager vs kLazy, trusted-space DeoptimizationData (DeoptimizationLiteralArray vs ProtectedDeoptimizationLiteralArray), DeoptimizationFrameTranslation opcodes (INTERPRETED_FRAME_WITH_RETURN vs WITHOUT_RETURN, DOUBLE_LITERAL vs HOLEY_DOUBLE_LITERAL, CAPTURED_OBJECT), and two-phase no-GC stack rewriting followed by GC-allowed heap materialization.
  • Exception Handling: Isolate::pending_exception vs scheduled_exception, TerminationException, HandlerTable encodings (kRangeBasedEncoding with CatchPrediction + HandlerWasUsed vs kReturnAddressBasedEncoding), kNoHandlerFound = -1 vs kLazyDeopt = HandlerOffsetField::kMax, how Sparkplug handles exceptions directly via BytecodeArray's HandlerTable without deoptimizing, and finally token re-dispatch.
  • Stack Walking and Frame Layouts: Frame pointer (fp) chains, Context vs Smi StackFrame::Type markers (INTERPRETED, BASELINE, MAGLEV, TURBOFAN_JS, ENTRY, EXIT, BUILTIN_CONTINUATION, WASM), c_entry_fp bridging, StackFrameIterator vs signal-safe StackFrameIteratorForProfiler (and why it must never be V8_EXPORT_PRIVATE), and Conservative Stack Scanning (CSS) with SafepointTables.

4. Interpreter, Compilers, Codegen, Builtins, and Torque


5. Heap, Memory Management, Sandbox, Snapshot, Wasm, RegExp, and Security