« All posts

Concurrent JavaScript: A Thread Model for JSC (2017 Revisit)

WebKit's 2017 thought experiment on extending JavaScript's concurrency model beyond SharedArrayBuffer to full heap-wide object sharing.

A 2017 WebKit engineering post examines whether JavaScript's concurrency model, currently limited to SharedArrayBuffer, could be extended so any object on the heap can be shared across threads. The proposal centers on a strawman Thread API with separate stacks but a shared heap, an extended Atomics interface that supports locks on arbitrary properties (not just typed arrays), plus Lock, Condition, and ThreadLocal helper classes.

The core engineering question is whether JavaScriptCore's existing single-thread-optimized architecture can support this without breaking performance guarantees. Stated goals include zero regression for non-concurrent code, near-linear scalability when running parallel threads without shared state, real speedups on workloads that do share objects, and a memory model at least as strong as what modern hardware already provides — all while remaining compatible with DOM usage.

The implementation sketch suggests most property accesses would incur negligible overhead (roughly one extra arithmetic instruction), with rare edge cases costing up to 7x. Built on 64-bit assumptions and never empirically benchmarked, the post remains a useful reference for engineers thinking about what true multi-threaded semantics would require inside a modern JS engine.