Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

V8 11 min read Deep dive hardMaster

The V8 Sandbox

The 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.

Related posts

  • Celebrating 10 years of V8 · V8

    V8 easyNovice

    V8 grew over ten years from a secret project started in 2006 on a Danish farm into a JavaScript and WebAssembly engine supporting eight instruction sets, embedded by both Chrome and Node.js. Key milestones include the Irregexp regex engine, the Crankshaft and later TurboFan optimizing compilers, the Ignition interpreter, the incremental and then Orinoco parallel/concurrent garbage collectors, idle-time GC, code caching, Liftoff, and Spectre mitigations. V8 Bench scores rose 4× from 2008 to 2018, with dips from the initial ES2015 features and Spectre mitigations. The curve flattens after 2013 because the team shifted from synthetic micro-benchmarks to real-world performance, and Speedometer 1 scores rose another 4× over 2013–2018.

  • 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 hardMaster

    V8 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.

  • 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.

  • Announcing Stable V8 Bindings for Rust

    Deno mediumAdept

    Rusty V8, Deno's zero-overhead Rust bindings to V8's C++ API, is now stable and skips 1.0 to align with Chrome versioning, starting at 129.0.0. The crate integrates V8's build into Cargo and supports custom runtimes, WebAssembly, the V8 Inspector, the Fast API and cppgc garbage collection. Rust's scope-tied `Local<T>` handles catch invalid handle use at compile time, which C++ embedders must manage by hand. The major version bumps every 4 weeks with each V8 upgrade, so breaking changes follow semver and land only alongside V8 updates.

The quest for software engineering knowledge.

Look:
Layout: