This post, originally published in Chinese on zhichai.net, is a detailed walkthrough of WebAssembly 3.0, framing it as a major 2025 update to the standard that became a W3C recommendation in 2017. It positions Wasm as the "fourth language" of the web platform alongside HTML, CSS, and JavaScript, enabling near-native performance for languages like C/C++ and Rust.
Key points
Multithreading support
- A complete threading model: atomic operations for thread-safe data access, shared linear memory for inter-thread communication, and synchronization primitives (mutexes, condition variables).
- Seamless integration with Web Workers; multiple Wasm threads can share memory for true parallelism on multi-core CPUs.
- Example: a C++ program using
std::atomic<int>withfetch_addacross four threads. - Full 128-bit SIMD support: one instruction processes multiple data elements (4×f32 or 8×i16), well suited to image processing and audio/video codecs.
- Efficient mapping to native hardware SIMD (AVX, NEON) plus compiler auto-vectorization support.
- Example: Rust intrinsics using
v128_load,f32x4_add, andv128_storefor vector addition. - Reference types enabling direct references to external objects such as DOM elements.
- Optimized memory growth and allocation, shared-memory improvements for multithreaded access, and garbage collection integration so Wasm can cooperate with the JavaScript GC.
- JavaScript example using
new WebAssembly.Memory({ initial: 10, maximum: 100, shared: true })passed into a Worker and an instantiated module. - Wasm is a stack-based virtual machine with a binary (.wasm) format; modules are structured into type, import, function, code, export, and memory sections.
- Execution pipeline: fetch the .wasm file → compile → instantiate → execute.
- Compared to WebAssembly 2.0 (single-threaded, limited SIMD, basic memory management, glue-code-heavy JS interop), 3.0 adds full multithreading, comprehensive SIMD, optimized memory management, and more direct JavaScript integration.