SharedArrayBuffer
SharedArrayBuffer lets a Worker and the main thread share the same memory region with zero-copy transfer, but requires cross-origin isolation (COOP+COEP) against Spectre.
Purpose
To share large memory across Workers zero-copy for performance, while requiring cross-origin isolation to prevent Spectre side channels.
Mechanism
new SharedArrayBuffer(size) creates shared memory passed via postMessage (transferable). Atomics provides atomic operations. Since Spectre, crossOriginIsolated is required (COOP same-origin + COEP require-corp).
Use cases
- Worker zero-copy shared memory
- WASM threading
- High-performance computing