Skip to Content
V8-wasm

Overview

Full-JIT V8 compiled to WebAssembly with a typed TypeScript host API

V8-wasm compiles upstream Chromium V8 directly to WebAssembly with its full multi-tier execution pipeline intact: Ignition bytecode interpreter, Sparkplug baseline compiler, Maglev mid-tier optimizing compiler, TurboFan/Turboshaft optimizing compiler, Irregexp JIT, and nested WebAssembly Liftoff/TurboFan compilation with deoptimization.

Instead of interpreting JavaScript through a slow tree-walker or restricting V8 to --jitless, V8-wasm lowers generated V8 machine code straight into executable WebAssembly modules installed into the host engine at runtime.

Execution Stack

Every tier runs inside the browser sandbox without native code injection or browser flags:

TierRoleCodegen Target
IgnitionRegister-based bytecode interpreterEmbedded Wasm bytecode handlers with narrow 7-param ABI
SparkplugNon-optimizing baseline JITBatched multi-function Wasm slabs (BaselineBatchCompiler)
MaglevFast SSA optimizing compilerWasm codegen covering 110/110 IR methods across 48 node classes
TurboFan / TurboshaftPeak-throughput optimizing JITStackifier structured CFG with Chrome 154 metadata.code.branch_hint
IrregexpCompiled regular expressionsNative Wasm loop/br_if scans with hoisted bitmaps
Wasm-in-WasmLiftoff and TurboFan guest WasmTyped (ref $sig) dispatch, SIMD128, and --wasm-deopt resume

Quick Start

Install @browser-ports/v8-wasm, initialize the Emscripten V8-wasm module factory once, and spin up an isolated GuestRealm with its own V8 Isolate, Context, intrinsics, and bidirectional Membrane:

import { initV8, createGuestRealm } from '@browser-ports/v8-wasm';
import createV8Module from './v8_wasm_api.mjs';

await initV8({ module: createV8Module });

using realm = createGuestRealm();
realm.defineGlobal('hostLog', (msg: string) => console.log('[guest]', msg));

const result = realm.evalInRealm(`
  function fib(n) {
    return n <= 1 ? n : fib(n - 1) + fib(n - 2);
  }
  hostLog('tiering up');
  fib(25);
`);

console.log(result); // 75025

Explicit Resource Management

ManagedIsolate, GuestRealm, Compartment, ShadowRealm, RealmSandbox, HandleScope, IsolateScope, ContextScope, TryCatch, Global, and InspectorBridge all implement [Symbol.dispose]() in addition to explicit .dispose() methods.

Verification Baseline

The full multi-tier wasm/d8.cjs build is verified with DCHECK_ALWAYS_ON=1 against 2,320 / 2,320 applicable official V8 JIT tests (100% pass rate across mjsunit/baseline, mjsunit/regexp, mjsunit/wasm/deopt, mjsunit/maglev, mjsunit/turbolev, and mjsunit/compiler), plus --jitless fallback parity.

On this page