Static Roots: Objects with Compile-Time Constant Addresses
V8's static roots place the read-only heap at the start of every pointer-compression cage and generate it deterministically, so core objects like `undefined` get compressed addresses known at compile time (e.g. `undefined` is always 0x61). A generated static-roots.h file, cached in the repo and regenerated only when the read-only heap layout changes, lets libv8's C++ and the builtins compiler embed these constants instead of loading from a global roots array. Grouping related objects also turns checks such as "is string" or "is truthy" into address range comparisons. Shipped in Chrome 111, the change gave roughly a 1% Speedometer 2 gain on M1.
Related posts
- V8 release v6.9 · V8
V8 easyNoviceV8 v6.9 embeds built-in functions directly into the binary on x64, so all Isolates share one copy instead of each holding up to 700 KB on its own heap. Across the top 10k sites this cut median V8 heap size by 9%, and 10% of sites saved 3.7 MB or more. Liftoff, a new baseline WebAssembly compiler, speeds startup by over 10×. DataView methods were reimplemented in Torque and inlined by TurboFan to match TypedArray speed, and concurrent, incremental and parallel WeakMap processing roughly halves Mark-Compact GC pauses, with a linear-time fallback replacing worst cases that could take seconds. The release also adds Array.prototype.flat and flatMap.
- How Bun supports V8 APIs without using V8 (part 1)
Bun hardMaster
Bun, which runs on JavaScriptCore, implements a growing subset of V8's C++ embedding API so Node.js native modules like cpu-features load without V8. The post contrasts JSC and V8 value representation, calling conventions, isolates/contexts and handle-based lifetimes. It then shows why an initial approach of reinterpreting JSC's 8-byte JSValue as V8's Local<T> pointer failed. V8's inline header functions such as Object::GetInternalField dereference Local pointers and read map and instance-type fields at fixed offsets, so Bun's in-memory layouts must match what V8's compiled-in inline code expects.
- How Bun supports V8 APIs without using V8 (part 2)
Bun hardMaster
Bun emulates V8's memory layout on top of JavaScriptCore so that precompiled native addons, which inline V8 functions assuming specific pointer layouts, keep working. The approach uses tagged pointers (Smis or heap pointers), a small set of static fake Map objects with instance types at the expected offset, and 24-byte Handles in a handle scope that store the tagged pointer, map pointer and JSCell pointer side by side, avoiding separate allocations outside the GC. Walkthroughs of Local, HandleScope, Number::New/Value and objects with internal fields show how JSC values are presented to V8-compiled code.
- Turbocharging V8 with mutable heap numbers
V8 hardMasterV8 eliminated a performance cliff in JetStream2's async-fs benchmark caused by a custom Math.random whose `seed` lives in a ScriptContext slot. Every update to the seed allocated a new immutable HeapNumber, and the integer bitwise math was compiled as floating-point. V8 now tracks slot types (constant, SMI, HeapNumber, Int32, other) and lets a context slot own a mutable HeapNumber that is updated in place, storing raw Int32 values when they stay in range. Optimized code depends on the slot type staying stable and deoptimizes if it changes, and the change gives about a 2.5x speedup on async-fs and about 1.6% on the overall JetStream2 score.
- The V8 Sandbox
V8 hardMasterThe V8 Sandbox is a lightweight, in-process software sandbox that isolates the V8 heap so memory corruption from engine bugs cannot spread to the rest of the renderer process. It is now included in Chrome's VRP as of Chrome 123. V8 exploits usually stem from 2nd-order logic bugs, often in JIT compilers, which neither Rust nor memory tagging can prevent. The sandbox therefore replaces raw pointers and 64-bit sizes on the heap with 40-bit offsets from a 1TB reserved region, plus a pointer-table indirection for external objects. Overhead is about 1% on Speedometer and JetStream, and the design is testable through a memory-corruption API and a sandbox-violation detection mode used for fuzzing.