Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Parser] Preserve try labels #6505

Merged
merged 1 commit into from
Apr 17, 2024
Merged

[Parser] Preserve try labels #6505

merged 1 commit into from
Apr 17, 2024

Conversation

tlively
Copy link
Member

@tlively tlively commented Apr 17, 2024

In the standard text format, try scopes can be targeted by both normal branches
and delegates, but in Binaryen IR we only allow them to be targeted by
delegates, so we have to translate branches to try scopes into branches to
wrapper blocks instead. These wrapper blocks must have different names than the
try expressions they wrap, so we actually need to track two label names for try
expressions: one for delegates and another for normal branches.

We previously tried to avoid this complexity by tracking only the branch label
and computing the delegate label from the branch label as necessary, but that
produced unnecessary wrapper blocks and ugly label names that did not appear in
the source.

To produce better IR and minimize the diff when switching to the new text
parser, bit the bullet and track the delegate and branch label names separately.
This eliminates unnecessary wrapper blocks and keeps try names the same as in
the wat source where possible.

In the standard text format, try scopes can be targeted by both normal branches
and delegates, but in Binaryen IR we only allow them to be targeted by
delegates, so we have to translate branches to try scopes into branches to
wrapper blocks instead. These wrapper blocks must have different names than the
try expressions they wrap, so we actually need to track two label names for try
expressions: one for delegates and another for normal branches.

We previously tried to avoid this complexity by tracking only the branch label
and computing the delegate label from the branch label as necessary, but that
produced unnecessary wrapper blocks and ugly label names that did not appear in
the source.

To produce better IR and minimize the diff when switching to the new text
parser, bit the bullet and track the delegate and branch label names separately.
This eliminates unnecessary wrapper blocks and keeps try names the same as in
the wat source where possible.
Copy link
Member Author

tlively commented Apr 17, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @tlively and the rest of your teammates on Graphite Graphite

@tlively tlively merged commit 4a84a4b into main Apr 17, 2024
13 checks passed
@tlively tlively deleted the parser-try-labels branch April 17, 2024 20:49
@gkdn gkdn mentioned this pull request Aug 31, 2024
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