Skip to content

fix(fused): preserve element-section segment-count on remap (closes #172, v1.1.11)#173

Merged
avrabe merged 1 commit into
mainfrom
fix/172-fused-element-section
Jun 10, 2026
Merged

fix(fused): preserve element-section segment-count on remap (closes #172, v1.1.11)#173
avrabe merged 1 commit into
mainfrom
fix/172-fused-element-section

Conversation

@avrabe

@avrabe avrabe commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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 for element_section_bytes. wasm_encoder's Encode::encode writes a length-prefixed body (<LEB128 len><payload>) — no section-id byte. The extraction assumed id + len + payload and skipped a phantom id byte, stripping the leading <segment-count> off the payload. The count-less segment re-validated as section 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 (sha256 3213a135…): 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 validate passes. New test_remap_element_section_preserves_segment_count; 393 lib + 85 integration tests pass.

Known-red gates (pre-existing, unrelated)

Closes #172.

🤖 Generated with Claude Code

)

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
@avrabe avrabe merged commit 905f0ed into main Jun 10, 2026
@avrabe avrabe deleted the fix/172-fused-element-section branch June 10, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fused optimization pass invalidates core module 0 (section size mismatch) — falls back to original, ~0% on the hot module

1 participant