feat: implement params-ptr lowering for >16 flat params#65
Merged
Conversation
When a component function has more than MAX_FLAT_PARAMS (16) flat parameters, the canonical ABI uses the params-ptr calling convention: both caller and callee use a single i32 pointer to a buffer in linear memory instead of flat params on the stack. In multi-memory mode, the adapter must: 1. Allocate a buffer in the callee's memory via cabi_realloc 2. Bulk copy the params buffer from caller to callee memory 3. Fix up (ptr, len) pointer pairs inside the buffer by copying their pointed-to data (e.g., list elements) across memories 4. Convert borrow<T> resource handles inside the buffer to representations via [resource-rep] calls 5. Convert borrow<T> resource handles inside list element data via per-element fixup loops Changes: - parser.rs: Add total_flat_params(), params_area_byte_size(), params_area_max_align(), pointer_pair_params_byte_offsets(), params_area_slots(), resource_params_area_positions(), and collect_resource_byte_positions() methods - resolver.rs: Add params_area_byte_size, params_area_max_align, params_area_pointer_pair_offsets, params_area_copy_layouts, params_area_slots, and params_area_resource_positions fields to AdapterRequirements; populate in both resolution paths - adapter/mod.rs: Add ParamsAreaResourceFixup struct and params_area_borrow_fixups field to AdapterOptions - adapter/fact.rs: Add generate_params_ptr_adapter() method with full buffer copy, pointer pair fixup, borrow handle conversion, and inner list resource fixup; detect params-ptr case in generate_memory_copy_adapter() dispatch Promotes resource_aggregates fixture from fuse_only to runtime test. Co-Authored-By: Claude Opus 4.6 (1M context) <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
Implement params-ptr lowering for functions with more than 16 flat parameters
(canonical ABI MAX_FLAT_PARAMS). The adapter allocates a buffer in the callee's
memory, bulk-copies params, fixes up pointer pairs and resource handles.
generate_params_ptr_adapterin fact.rs (170 lines)Test plan
🤖 Generated with Claude Code