feat(p3-async): cross-memory ptr-pair return for stackful lift#150
Merged
Conversation
Closes the v0.8.0-deferred follow-up: stackful async lifts returning a string or list<T> across different linear memories. The emitter previously errored out clearly on this path; this PR routes it through the same realloc + memory.copy + nested-indirection + retptr-write sequence the callback emitter already used. Refactor: - Extracted emit_ptr_pair_result_writeback as a shared helper. Both the callback emitter's is_ptr_len_pair branch and the stackful emitter's is_ptr_pair branch now call this single method, so the SR-12 / SR-17 cross-memory copy contract has a single source of truth. - Stackful emitter's locals count bumped from 8 to 12 (1 step-0.5 scratch + 4 ptr-pair scratch + 6 nested-indirection patching + 1 headroom). Tests: - stackful_ptr_pair_return_emits_realloc_memcopy_retptr_writes pins the wasm shape: memory.copy (0xFC 0x0A), >=2 i32.store (retptr write), >=2 call (cabi_realloc + lift). - 208 lib pass (207 prior + 1 new); 11 P3 async integration unchanged. Refs: SR-32, sub-#94, follow-up from #147 / v0.8.0 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Closes the v0.8.0-deferred follow-up under SR-32: stackful async lifts
returning a `string` or `list` across different linear memories.
The v0.8.0 emitter errored out clearly on this path (the
"deferred to follow-up" error); this PR routes it through the same
realloc + memory.copy + nested-indirection + retptr-write sequence the
callback emitter already used.
Refactor
Extracted `emit_ptr_pair_result_writeback` as a shared method on
`FactStyleGenerator`. Both the callback emitter's `is_ptr_len_pair`
branch and the stackful emitter's `is_ptr_pair` branch now call this
single method. SR-12 / SR-17 cross-memory copy contract has a single
source of truth.
Stackful emitter's locals count bumped from 8 to 12:
Tests
the wasm shape:
Test plan
Refs
🤖 Generated with Claude Code