Skip to content

Add shared memory support for mprotect-able platforms#380

Open
kateinoigakukun wants to merge 2 commits into
mainfrom
katei/shared-memory-reload
Open

Add shared memory support for mprotect-able platforms#380
kateinoigakukun wants to merge 2 commits into
mainfrom
katei/shared-memory-reload

Conversation

@kateinoigakukun

@kateinoigakukun kateinoigakukun commented Jul 20, 2026

Copy link
Copy Markdown
Member

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 a shared memory instantiable and shareable across threads, including cross-thread memory.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.

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
kateinoigakukun force-pushed the katei/shared-memory-reload branch 3 times, most recently from 56f4609 to cdb0b3d Compare July 20, 2026 23:45
@kateinoigakukun
kateinoigakukun force-pushed the katei/shared-memory-reload branch from cdb0b3d to 4d7b014 Compare July 21, 2026 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants