From 4906b9fb56fc2af0bb254984a43b8d4f178b0842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20T=C3=B6rcsv=C3=A1ri?= Date: Wed, 5 Aug 2026 20:02:18 +0200 Subject: [PATCH] design-b D-1b: delete the legacy handlesleep runtime from the injector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doc 20 D-1, second slice: the injector now injects asyncify-scheduler.js unconditionally — the WX_SCHEDULER=0 legacy opt-out, the SHIM_DISABLE_HANDLESLEEP ablation skip, and the SHIM_DISABLE_TRAMPOLINE_HEAL ablation skip are gone, and scripts/common/shims/handlesleep.js is deleted (the scheduler subsumed its capture/restore, fiber guard, and trampoline-heal duties in S2). Comment-only scrubs point the remaining references at the scheduler shim. .ci-cache-epoch bumped (shim/injector behavior changed). Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01TEHGiiXMShNXbBr7gSJ7iz --- .ci-cache-epoch | 2 +- scripts/build-wasm-test.sh | 4 +- scripts/common/inject-dyncall-shims.sh | 56 +-- scripts/common/shims/handlesleep.js | 423 ------------------ .../asyncify/asyncify-races-scheduler.spec.ts | 8 +- tests/kicad/collab-load-fuzz.spec.ts | 4 +- tests/kicad/load-pcb.spec.ts | 2 +- tests/kicad/mailbox-ordering.spec.ts | 2 +- tests/kicad/timer-park-repro.spec.ts | 8 +- tests/kicad/utils/guard-beacons.ts | 2 +- 10 files changed, 34 insertions(+), 477 deletions(-) delete mode 100644 scripts/common/shims/handlesleep.js diff --git a/.ci-cache-epoch b/.ci-cache-epoch index f599e28..b4de394 100644 --- a/.ci-cache-epoch +++ b/.ci-cache-epoch @@ -1 +1 @@ -10 +11 diff --git a/scripts/build-wasm-test.sh b/scripts/build-wasm-test.sh index 501403b..73ddc9f 100755 --- a/scripts/build-wasm-test.sh +++ b/scripts/build-wasm-test.sh @@ -132,8 +132,8 @@ if [ "$make_rc" -ne 0 ]; then exit "$make_rc" fi -# Inject the dyncall + handlesleep currData shims into every freshly-linked app. The -# handlesleep currData save/restore (Emscripten #9153) is needed: without it a rewind that +# Inject the dyncall + asyncify-scheduler shims into every freshly-linked app. The +# scheduler's currData save/restore (Emscripten #9153) is needed: without it a rewind that # resumes through a fresh wasm re-entry hits _asyncify_start_rewind(null) -> "memory access out # of bounds" — e.g. a context-menu pick while the main loop is parked. The Makefile only injects # it for the coroutine apps; inject-dyncall-shims.sh is idempotent (skips an already-shimmed glue), diff --git a/scripts/common/inject-dyncall-shims.sh b/scripts/common/inject-dyncall-shims.sh index 9799a54..ac26b27 100755 --- a/scripts/common/inject-dyncall-shims.sh +++ b/scripts/common/inject-dyncall-shims.sh @@ -4,10 +4,9 @@ # # The actual JavaScript that gets injected lives in readable, standalone files in # scripts/common/shims/ (not inline heredocs): -# - handlesleep.js nested-Asyncify handleSleep currData save/restore (#9153) # - asyncify-scheduler.js the mailbox/scheduler (docs/features/async/17) — -# the DEFAULT shim; WX_SCHEDULER=0 opts back into -# the legacy handlesleep.js +# the ONLY asyncify runtime (the legacy handlesleep.js +# opt-out was deleted at doc 20 D-1) # - diagnostics.js optional logging-only instrumentation (see SHIM_DIAGNOSTICS) # # Native wasm-EH is the only build mode, so the .js has no invoke_* wrappers / dynCall_ call @@ -20,7 +19,6 @@ # Usage: # inject-dyncall-shims.sh # SHIM_DIAGNOSTICS=1 inject-dyncall-shims.sh # also inject diagnostics.js -# WX_SCHEDULER=0 inject-dyncall-shims.sh # legacy opt-out (handlesleep.js instead of the scheduler) set -e @@ -36,7 +34,7 @@ if [ -z "$JS_FILE" ] || [ ! -f "$JS_FILE" ]; then echo "Usage: $0 " exit 1 fi -for f in handlesleep.js asyncify-scheduler.js diagnostics.js; do +for f in asyncify-scheduler.js diagnostics.js; do if [ ! -f "$SHIM_DIR/$f" ]; then echo "Error: missing shim source $SHIM_DIR/$f" exit 1 @@ -73,25 +71,18 @@ apply_fix 'var iterFunc = (() => {});' 'var iterFunc = () => wasmExports["dynCal apply_fix '(a1 => {})(userData);' 'wasmExports["dynCall_vi"](entryPoint, userData);' "fiber entry callback(s) (wasmExports.dynCall_vi)" echo "Total: Fixed $TOTAL_FIXED empty callback(s)" -# --- 3. Asyncify shim: legacy handleSleep fix OR the S2 scheduler -------------- +# --- 3. Asyncify scheduler shim ------------------------------------------------ # Injected after Emscripten's fiber glue (the _emscripten_fiber_swap.isAsync marker), # or at EOF for non-fiber apps (a plain wx app still needs the currData machinery: # without it a rewind resuming through a fresh wasm re-entry hits # _asyncify_start_rewind(null) -> "memory access out of bounds"). # -# WX_SCHEDULER (doc 17 S5): the scheduler is the DEFAULT since 2026-08-05 — -# asyncify-scheduler.js REPLACES handlesleep.js. It subsumes the -# capture/restore, fiber guard, and trampoline heal, and adds the deferred-wake -# drain + N1 single-writer tripwire + the mailbox/wait lanes. Injecting BOTH -# would double-manage the wake path (the scheduler refuses to install its core -# then). WX_SCHEDULER=0 is the explicit legacy opt-out (kept until CI has run -# scheduler-only across the full matrix; the C++ legacy paths it exercises are -# deleted together with it — see doc 17 S5's demolition ledger). -# -# SHIM_DISABLE_HANDLESLEEP=1 skips the legacy shim: the asyncify-races red-green -# harness uses it to keep the historical "sleep buffer clobbered by fiber swap" -# crash reproducible. On WX_SCHEDULER=1 builds the variant still gets the -# scheduler — the ablation pins become scheduler-subsumption pins (doc 17 §3c). +# asyncify-scheduler.js (docs/features/async/17) is the ONLY asyncify runtime: +# it owns the currData capture/restore, fiber guard, and trampoline heal, and +# adds the deferred-wake drain + N1 single-writer tripwire + the mailbox/wait +# lanes. The legacy handlesleep.js opt-out (WX_SCHEDULER=0) and the ablation +# skip (SHIM_DISABLE_HANDLESLEEP) were deleted at doc 20 D-1 together with the +# wx C++ paths they exercised. inject_shim_at_marker() { #