Add shared memory support for mprotect-able platforms#380
Open
kateinoigakukun wants to merge 2 commits into
Open
Add shared memory support for mprotect-able platforms#380kateinoigakukun wants to merge 2 commits into
kateinoigakukun wants to merge 2 commits into
Conversation
A `shared` memory is backed by `SharedMemoryStorage`, which reserves its full address range up front so the base pointer stays stable, then commits pages on `memory.grow` under a spinlock that the SIGSEGV/SIGBUS handler also takes, so a concurrent grow cannot race an in-flight access; `memory.atomic.wait32/64` and `memory.atomic.notify` block and wake threads through `AtomicParkingLot`. Adds `SharedMemoryStorageTests` and `AtomicParkingLotTests`.
kateinoigakukun
force-pushed
the
katei/shared-memory-reload
branch
3 times, most recently
from
July 20, 2026 23:45
56f4609 to
cdb0b3d
Compare
kateinoigakukun
force-pushed
the
katei/shared-memory-reload
branch
from
July 21, 2026 00:02
cdb0b3d to
4d7b014
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for shared linear memory (the WebAssembly threads proposal), building on #359 but dropping software-bounds-checking support for shared memory to keep the approach small.
Atomic instructions already work on
main. This makes asharedmemory instantiable and shareable across threads, including cross-threadmemory.atomic.wait/notify.ndows).
Limitations
Shared memory requires mprotect bounds checking (64-bit macOS/Linux). Under software bounds checking, token threading, ASan, Windows, WASI, or memory64, creating a shared memory traps with
sharedMemoryRequiresMprotect.