fix(fused): preserve element-section segment-count on remap (closes #172, v1.1.11)#173
Merged
Merged
Conversation
) The fused component pass invalidated core modules that have an element segment: after removing a dead function it rebuilds the element section (remap_element_section_refs) and extracts the raw payload to store in element_section_bytes. wasm_encoder's Encode::encode writes a length-prefixed BODY (<LEB128 len><payload>), NOT a full <id><len><payload> section — but the extraction skipped a phantom section-id byte, stripping the leading <segment-count> off the payload. The count-less segment then re-validated as "section size mismatch: unexpected data at the end of the section", so loom fail-safe-fell-back to the original bytes — leaving the largest core module of gale's falcon-flight component at ~0% optimization. Fix: strip only the leading LEB128 length, from offset 0. Verified on gale's exact artifact (falcon-flight-v1.34.wasm, sha256 3213a135…): all 4 core modules now optimize (was 3/4), component 0.2% → 3.9% (core module 0: 96.5KB → 92.6KB), wasm-tools validate passes. New test_remap_element_section_preserves_segment_count; 393 lib + 85 integration tests pass. Bumps 1.1.10 -> 1.1.11. Closes #172. Trace: REQ-12
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.
gale #172 — fused pass invalidates core modules with element segments
The fused component pass fail-safe-fell-back on falcon-flight's core module 0 (~96 KB, the hot one), leaving it at ~0% optimization.
Root cause
After removing a dead function, the pass rebuilds the element section (
remap_element_section_refs) and extracts the raw payload forelement_section_bytes.wasm_encoder'sEncode::encodewrites a length-prefixed body (<LEB128 len><payload>) — no section-id byte. The extraction assumedid + len + payloadand skipped a phantom id byte, stripping the leading<segment-count>off the payload. The count-less segment re-validated assection size mismatch: unexpected data at the end of the section.Fix
Strip only the leading LEB128 length, from offset 0.
Verified on gale's exact artifact
falcon-flight-v1.34.wasm(sha2563213a135…): all 4/4 core modules now optimize (was 3/4), component 0.2% → 3.9% (core module 0: 96.5 KB → 92.6 KB),wasm-tools validatepasses. Newtest_remap_element_section_preserves_segment_count; 393 lib + 85 integration tests pass.Known-red gates (pre-existing, unrelated)
Closes #172.
🤖 Generated with Claude Code