You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 62e16df
Browse filesBrowse the repository at this point in the historyBrowse files
feat(codegen): #225 PR2 — WasmGC CPS transform, Async base case (ADR-013) (#233)
Transparent async on the WasmGC backend for the recognised base case:
an Async fn whose body is `let r = <async-call>; <cont>` with no
live-local capture beyond the result binder. The author writes no
thenableThen/closure plumbing — the backend synthesises it.
lib/codegen.ml:
- eff_expr_has_async/fn_is_async: trigger iff Async in fd_eff. Bare
effects parse as EffVar (not EffCon — only Throws[E] is EffCon);
both spellings checked.
- detect_async_base_case: recognises the expression-let and the
block-statement (StmtLet :: rest) desugarings; conservative — any
unrecognised shape or extra live-local capture falls back to the
pre-existing synchronous lowering verbatim (zero behaviour change).
- gen_async_base_case: reifies <cont> as a zero-arg continuation via
the existing #199 ExprLambda path (binder auto-captured into the
[fnId@0,envPtr@4] env — no new closure code); once-resumption guard
module-global traps on a second entry (ADR-013 obligation 1).
- wired into gen_function, gated on fn_is_async + detector +
thenableThen resolvable; else the old path, untouched.
Two root-cause fixes in the #199 closure path, which until now had
only ever been static-verified (PR1's skeleton was pure pass-through);
PR2 is its first real end-to-end wasm exercise and surfaced both:
- export the function table as __indirect_function_table (the host
ABI dispatches through it; was unexported). Guarded on a non-empty
table so closure-free modules are byte-identical.
- closure_code used LocalTee where the surrounding code assumes
LocalSet, leaving a dangling pointer (two stack values); corrected.
stdlib/Http.affine: + pub extern fn thenableThen (the wasm-path
continuation-registration primitive the transform targets, mirroring
the proven #205 Vscode.thenableThen).
Conforms to typed-wasm ADR-005 / spec/async-convergence-abi.adoc as
amended (accessor model, (env_ptr)->i32) — see that spec's
Conformance — AffineScript section. typed Response reader is PR3
(strict ADR-013 PR2 scope).
New wasm e2e tests/codegen/http_cps_base.{affine,mjs}: host re-enters
the continuation, reads the settled scalar via a minimal accessor
(=200), fires exactly once, second entry traps. Full
tools/run_codegen_wasm_tests.sh green; dune test --force 258 green.
Refs #225#160
0 commit comments