feat: callback-driving adapter for P3 async fusion#95
Merged
Conversation
Complete handle table infrastructure: - ht_new/ht_rep/ht_drop in linear memory for re-exporter components - Function bodies re-rewritten to use ht_* for resource ops - Component wrapper routes LocalResource through $ht_*_N exports - Adapter uses ht_rep for caller extraction when caller has handle table (fixes handle escape from re-exporter→definer calls) Status: "unknown handle index" error fixed (handle no longer escapes to canonical resource table). Now hits "unreachable" trap — likely an initialization or argument issue in the handle table functions. 73/73 runtime tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Replace the canon lift/lower approach with a core wasm adapter that drives the callee's [async-lift] + [callback] loop directly. This eliminates the component boundary for internal async calls, avoiding call_might_be_recursive entirely. The adapter protocol (from the canonical ABI spec): 1. Call [async-lift] entry -> packed i32 (EXIT/WAIT/YIELD) 2. Loop: if WAIT, call waitable-set-poll; call [callback] with event 3. After EXIT, retrieve result via host intrinsic Merger: async adapter sites now resolved like sync sites. Result retrieval stubbed pending host API finalization. 73/73 P2 runtime tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Fix task.return shim matching: use original function name (extracted from callee component's core module imports) instead of type-based matching. This correctly routes each async function to its own shim globals. Add retptr convention support: when the caller uses the return-pointer convention (void return, extra param), write shim globals to the retptr address in caller memory instead of pushing to stack. All 4 P3 compute functions now produce correct results on stock wasmtime 41 (no fork, no special flags beyond component-model-async): prime 7 -> 7 is prime fibonacci 10 -> fibonacci(10) = 55 factorial 5 -> factorial(5) = 120 collatz 27 -> collatz(27) = 111 steps String-returning functions (analyze, search, etc.) still need cross-memory string copy in the result path. 73/73 P2 runtime tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add cross-memory string copy for async adapter retptr results: when the result is a (ptr, len) pair referencing callee memory, the adapter allocates in caller memory via cabi_realloc and copies the data with memory.copy. Remove the dead AsyncLiftLower code path from component_wrap.rs. Async imports are now fully handled by the callback-driving adapter in core wasm — no canon lift/lower needed inside the component. 73/73 P2 runtime tests pass. P3 compute functions correct on stock wasmtime. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1. --validate now supports component output format (enables COMPONENT_MODEL, CM_ASYNC, MULTI_MEMORY features in validator) 2. --emit-import-map includes 'kind' field classifying each import as 'p3-builtin', 'resource', 'wasi', or 'function' 3. Downgrade UNMAPPED func import messages from warn to debug (cosmetic noise from indirect table stubs) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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.
Summary
Implements P3 async cross-component call fusion using a callback-driving adapter that runs entirely in core wasm — no
canon lift/canon lowerinside the fused component, nocall_might_be_recursivetrap.The adapter drives the callee's
[async-lift]+[callback]loop directly:[async-lift]entry → packed i32 (EXIT/WAIT/YIELD)waitable-set-poll; call[callback]with eventKey changes
AsyncLiftLowercode path from component_wrap.rsRuntime results on stock wasmtime 41
No wasmtime fork. No special flags beyond
-W component-model-async=y.Remaining
Test plan
--features cm-async🤖 Generated with Claude Code