ReviewOS

zig-utils/zig-js

WebAssembly threads: execute atomics, wait, notify, and fence

#286
Closed chris opened this 9 days ago ·
9 days ago

Parent: #265 Depends on: #284, #285 Related: #1, #49 Roadmap: #142, #134

Execute the complete pinned atomic instruction family against shared WebAssembly memory.

Acceptance:

  • Implement atomic load/store, read-modify-write, compare-exchange, and fence for every selected width.
  • Implement memory.atomic.wait32/wait64 and memory.atomic.notify with exact result codes, timeout conversion, alignment, and trap behavior.
  • Make bounds/alignment failure atomic and preserve sequentially consistent visibility across no-GIL Context Threads and Workers.
  • Coordinate waiters with termination, memory growth, context destruction, and host interruption without hangs or leaked wait records.
  • Add exact single-thread, multi-thread, contention, timeout, termination, and differential tests.
9 days ago

Implemented and published on main.

Evidence:

  • f4eaa0db executes every selected atomic load/store, RMW, compare-exchange, fence, wait32/wait64, and notify form with proposal-exact widths, alignment, bounds, result codes, timeouts, traps, and SeqCst ordering.
  • Waits publish parked stack roots, release/reacquire the optional GIL, and use targeted host-stop predicates. Worker termination, Context teardown paths, interruption unlinking, growth, and native Memory-owner destruction are covered without leaked waiter records.
  • 1d7b0fb6 adds the exact pinned Threads corpus profile and makes conversion failures explicit runner errors rather than hidden zero-command files.
  • f5cc0f7a makes overlapping ordinary/atomic shared access host-race-free: ECMAScript no-tear integer TypedArrays use one monotonic width-sized event; tearable DataView, float/BigInt, scalar/SIMD Wasm, and bulk-memory paths use byte events.
  • Exact upstream witness: threads/atomic.wast 372/372, 0 fail, 0 n/a, 0 runner.
  • Complete unit root: 1,069/1,069, 0 skipped, 0 failed, 0 leaked.
  • Focused overlapping-access ThreadSanitizer witnesses: 4/4 clean.
  • Integration witnesses include 8 no-GIL Threads x 1,000 Wasm atomic increments, JS Atomics/Wasm differential access on one shared Memory, real wait/notify, mismatch/timeout/unshared behavior, and Worker termination of an infinite Wasm wait.
  • dfff7df3 publishes the evidence and exact remaining #287 boundary in README/docs.

The proposal-level (thread ...) litmus/script directives are deliberately not counted here; the pinned WABT converter cannot lower them, the harness reports them as runner errors, and #287 owns that script runner plus the terminal full-corpus/TSan/scaling evidence.

Sign in to comment on this issue.