Skip to content

[wasm-split] Split more active segments for --no-placeholders#8859

Open
aheejin wants to merge 2 commits into
WebAssembly:mainfrom
aheejin:wasm_split_active_segments2
Open

[wasm-split] Split more active segments for --no-placeholders#8859
aheejin wants to merge 2 commits into
WebAssembly:mainfrom
aheejin:wasm_split_active_segments2

Conversation

@aheejin

@aheejin aheejin commented Jun 18, 2026

Copy link
Copy Markdown
Member

If placeholders are not used, and if all functions in an element segment belong to a single secondary module, we can move the segment to that secondary module, because those functions aren't available until the secondary module is loaded anyway.

The primary module size decreases 5-9% for acx_gallery and essentials. These applications both use --no-placeholders.

  • acx_gallery (07/2025): 9.7%
  • acx_gallery (05/2026): 5.3%
  • essentials (04?/2026): 6.3%
  • essentials (05/2026): 8.4%

If placeholders are not used, and if all functions in an element segment
belong to a single secondary module, we can move the segment to that
secondary module, because those functions aren't available until the
secondary module is loaded anyway.

The primary module size decreases 5-9% for acx_gallery and essentials.
These applications both use `--no-placeholders`.
- acx_gallery (07/2025): 9.7%
- acx_gallery (05/2026): 5.3%
- essentials (04?/2026): 6.3%
- essentials (05/2026): 8.4%
@aheejin aheejin requested a review from a team as a code owner June 18, 2026 03:04
@aheejin aheejin requested review from tlively and removed request for a team June 18, 2026 03:04

@tlively tlively left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea!

There is an edge case where something like array.init_elem references an active element segment. This will trap unless the instruction accesses a slice of length 0 at index 0, so it is generally useless. But it still requires the element segment to be in the same module as the instruction for validation.

Is this edge case handled already? It doesn't seem like it is. One option is to optimize out all the useless instructions that access active element segments before doing anything else. We do something similar in MemoryPacking::optimizeSegmentOps, for instance.

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.

2 participants