fix: propagate host parameter transitively through direct calls (issu…#22
Merged
fix: propagate host parameter transitively through direct calls (issu…#22
Conversation
…#19 part 2) Fixes compilation errors when a function A calls function B via IrInstr::Call, and B needs the host parameter. Before the fix: 1. A's signature didn't have host (no transitive propagation) 2. emit_call never passed host to the callee **Changes:** 1. assembly.rs: Add fixpoint propagation after enrich_ir_functions. If function A directly calls function B and B.needs_host is true, then A.needs_host = true. This ensures every function in a call chain to an import-calling function gets the host parameter. 2. backend/mod.rs: Add has_host parameter to emit_call trait method 3. backend/safe.rs: Update emit_call to insert "host" between Wasm args and resource args (globals, memory, table) 4. instruction.rs: When handling IrInstr::Call, check if target function needs_host and pass has_host to emit_call (only if caller_has_host AND target_needs_host) 5. function.rs: Use ir_func.needs_host directly instead of recomputing. The IR builder's fixpoint algorithm is authoritative after the transitive propagation. **Tests:** - call_import_transitive.wat: regression test with caller → writer → import chain - call_import_transitive.rs: integration test verifying the transitive chain works All existing tests pass, including indirect_call_import tests. Co-Authored-By: Claude Haiku 4.5 <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.
…e #19 part 2)
Fixes compilation errors when a function A calls function B via IrInstr::Call, and B needs the host parameter. Before the fix:
Changes:
assembly.rs: Add fixpoint propagation after enrich_ir_functions. If function A directly calls function B and B.needs_host is true, then A.needs_host = true. This ensures every function in a call chain to an import-calling function gets the host parameter.
backend/mod.rs: Add has_host parameter to emit_call trait method
backend/safe.rs: Update emit_call to insert "host" between Wasm args and resource args (globals, memory, table)
instruction.rs: When handling IrInstr::Call, check if target function needs_host and pass has_host to emit_call (only if caller_has_host AND target_needs_host)
function.rs: Use ir_func.needs_host directly instead of recomputing. The IR builder's fixpoint algorithm is authoritative after the transitive propagation.
Tests:
All existing tests pass, including indirect_call_import tests.