Skip to content

[Parser] Preserve try labels - #6505

Merged
tlively merged 1 commit into
mainfrom
parser-try-labels
Apr 17, 2024
Merged

[Parser] Preserve try labels#6505
tlively merged 1 commit into
mainfrom
parser-try-labels

Conversation

@tlively

Copy link
Copy Markdown
Member

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.
@tlivelyGraphite App

Copy link
Copy Markdown
MemberAuthor

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

Join @tlively and the rest of your teammates on GraphiteGraphite

@tlively
tlively merged commit 4a84a4b into mainApr 17, 2024
@tlively
tlively deleted the parser-try-labels branch April 17, 2024 20:49
@gkdngkdn mentioned this pull request Aug 31, 2024
Sign up for freeto 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

@tlively@kripken