Skip to content

Group locals by written type in binary writer#8568

Merged
tlively merged 2 commits intomainfrom
aswritten-locals
Apr 2, 2026
Merged

Group locals by written type in binary writer#8568
tlively merged 2 commits intomainfrom
aswritten-locals

Conversation

@tlively
Copy link
Copy Markdown
Member

@tlively tlively commented Apr 2, 2026

We have logic to group locals by type in the binary writer to take advantage of the run-length encoding of locals. But that logic previously grouped locals by their IR types, rather than the types that would actually be written to the binary. These can differ in when the IR uses more precise types than are allowed to be written given the enabled feature set. For example, the IR might use exact types but have to write inexact types because custom descriptors are not enabled. In such cases, it is possible that different groups of locals would be written with the same type, which is suboptimal. Fix the problem by grouping locals by their written types given the enabled features.

Fixes #7934.

We have logic to group locals by type in the binary writer to take advantage of the run-length encoding of locals. But that logic previously grouped locals by their IR types, rather than the types that would actually be written to the binary. These can differ in when the IR uses more precise types than are allowed to be written given the enabled feature set. For example, the IR might use exact types but have to write inexact types because custom descriptors are not enabled. In such cases, it is possible that different groups of locals would be written with the same type, which is suboptimal. Fix the problem by grouping locals by their written types given the enabled features.

Fixes #7934.
@tlively tlively enabled auto-merge (squash) April 2, 2026 16:24
@tlively tlively merged commit 13cb918 into main Apr 2, 2026
16 checks passed
@tlively tlively deleted the aswritten-locals branch April 2, 2026 16:54
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.

Binaryen writer seems to unnecessarily create multiple local sections for locals with same type

2 participants