demo · v130
String Ops Bench
Chrome 130 ships WebAssembly JS String Builtins — Wasm functions that directly call JavaScript's built-in string methods without importing them from JS. This benchmark runs common string operations (concat, slice, search, compare, charCode) using the native JS path, simulates what the Wasm built-in version replaces, and shows relative throughput.
Checking WebAssembly JS String Builtins support…
100K
50 chars
Click Run benchmark to start.
Wasm string access methods compared
| Method | No builtins (pre-130) | JS String Builtins (130) | Speedup source |
|---|---|---|---|
| String.concat / + | Import JS glue function | Direct Wasm builtin | Eliminates JS↔Wasm boundary crossing |
| String.length | Import or extern ref | Inline length check | No function call overhead |
| charCodeAt / codePointAt | JS import + coercion | Direct memory read | Avoids string boxing/unboxing |
| substring / slice | JS import required | Built-in call | Avoids extern ref indirection |
| Comparison (===) | JS import | Builtin eq check | Fast interned string comparison |
| Type (stringref) | externref only | WasmGC stringref type | No GC pressure from extern wrapping |
// WebAssembly JS String Builtins (Chrome 130)
// WAT — access JS String methods directly
(module
(import "wasm:js-string" "concat" (func $concat (param stringref stringref) (result stringref)))
(import "wasm:js-string" "charCodeAt" (func $charCodeAt (param stringref i32) (result i32)))
(import "wasm:js-string" "substring" (func $substring (param stringref i32 i32) (result stringref)))
(import "wasm:js-string" "equals" (func $equals (param stringref stringref) (result i32)))
(import "wasm:js-string" "length" (func $length (param stringref) (result i32)))
;; Equivalent JavaScript (pre-130 Wasm approach via import object)
;; { "js": { "concat": (a, b) => a + b, ... } }
;; Chrome 130: "wasm:js-string" namespace maps to engine-native builtins
;; No JS import object needed at instantiation time
)
// Instantiate with builtins enabled
const { instance } = await WebAssembly.instantiateStreaming(
fetch('module.wasm'),
{}, // No JS glue imports needed for wasm:js-string
{ builtins: ['js-string'] } // Chrome 130
);