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.
Architecture
Narrow 7-parameter ABI, Sparkplug, Maglev, TurboFan structured CFG, and host stack charging
@browser-ports/v8-wasm API
Full V8 C++ mirror, GuestRealm membrane, ShadowRealm, SES Compartment, and JSC C-API
Live Playground
Run JS against V8-wasm, inspect generated Wasm, and compare against the host engine
Benchmarks
Octane 2.0 results (12,493 in Helium), JIT verification baseline, and implemented optimizations
Execution Stack
Every tier runs inside the browser sandbox without native code injection or browser flags:
| Tier | Role | Codegen Target |
|---|---|---|
| Ignition | Register-based bytecode interpreter | Embedded Wasm bytecode handlers with narrow 7-param ABI |
| Sparkplug | Non-optimizing baseline JIT | Batched multi-function Wasm slabs (BaselineBatchCompiler) |
| Maglev | Fast SSA optimizing compiler | Wasm codegen covering 110/110 IR methods across 48 node classes |
| TurboFan / Turboshaft | Peak-throughput optimizing JIT | Stackifier structured CFG with Chrome 154 metadata.code.branch_hint |
| Irregexp | Compiled regular expressions | Native Wasm loop/br_if scans with hoisted bitmaps |
| Wasm-in-Wasm | Liftoff and TurboFan guest Wasm | Typed (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); // 75025Explicit 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.