Movies Rule
Films · Streaming · Screens
engineeringSaturday, June 20, 2026·3 min read

Bun Adds Shared-Memory Threads to JavaScriptCore

Bun open PR for shared-memory threads in JavaScriptCore

Appetizing pastries with cream and toppings, displayed in a bakery setting.
Photo: Valeria Boltneva

A recent open PR on GitHub proposes adding shared-memory threads to JavaScriptCore, a significant development for the JavaScript ecosystem. This feature would enable true parallelism in JavaScript, allowing developers to run functions on separate threads while sharing the same heap and objects. The implications of this change are substantial, as it could fundamentally alter how JavaScript applications are designed and developed.

## What happened The PR, submitted by Jarred-Sumner, introduces a new Thread function that allows running functions on separate threads, all within the same heap and with access to the same objects. This approach eliminates the need for structured cloning, message passing, or relying on SharedArrayBuffer as an escape hatch. The implementation has made significant progress, with parallel JavaScript execution through all four JIT tiers and the thread test suite now passing without a global lock. However, the PR is still in its experimental phase and requires further work, including thread-sanitizer cleanup, fuzzing, and benchmarking. ## Why it matters The addition of shared-memory threads to JavaScriptCore matters because it addresses a long-standing limitation of JavaScript: its single-threaded nature. By enabling true parallelism, developers can create more efficient and scalable applications. This feature could particularly benefit applications that rely heavily on computational tasks, such as scientific simulations, data processing, and machine learning. The change also aligns with the broader trend of increasing parallelism in software development, driven by the growing availability of multi-core processors.
+ Pros
  • Enables true parallelism in JavaScript, improving performance and efficiency.
  • Simplifies development by allowing shared access to objects and eliminating the need for complex messaging protocols.
  • Could lead to significant advancements in applications that rely on computational tasks.
Cons
  • Introduces complexity and potential risks associated with shared-memory concurrency, such as race conditions and memory leaks.
  • May require significant changes to existing codebases and development practices.
  • Could lead to increased memory usage and potential performance issues if not managed properly.
## How to think about it When considering the implications of shared-memory threads in JavaScriptCore, developers should think about how this feature can be leveraged to improve the performance and efficiency of their applications. This might involve identifying computational bottlenecks that could be addressed through parallelism, as well as rethinking development practices to accommodate shared-memory concurrency. It's also crucial to weigh the potential benefits against the added complexity and risks, ensuring that the use of shared-memory threads is judicious and well-managed. ## FAQ
What are shared-memory threads in JavaScriptCore?+
Shared-memory threads in JavaScriptCore refer to the ability to run functions on separate threads while sharing the same heap and objects, enabling true parallelism in JavaScript.
How do shared-memory threads differ from workers in JavaScript?+
Shared-memory threads differ from workers in that they share the same heap and objects, whereas workers run in separate contexts and require messaging protocols to communicate.
What are the potential benefits and risks of using shared-memory threads in JavaScriptCore?+
The potential benefits include improved performance and efficiency, while the risks include added complexity, potential race conditions, and memory leaks.

Sources
  1. 01Bun has an open PR adding shared-memory threads to JavaScriptCore
  2. 02Shared-memory threads for JavaScriptCore (experimental, not working yet) by Jarred-Sumner · Pull Request #249 · oven-sh/WebKit
  3. 03Bun has an open PR adding shared-memory threads to JavaScriptCore | Hacker News
  4. 04Workers - Bun
Keep reading