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

Always do a full roundtrip in run-roundtrip.py #1661

Merged
merged 1 commit into from
Mar 1, 2023
Merged

Always do a full roundtrip in run-roundtrip.py #1661

merged 1 commit into from
Mar 1, 2023

Conversation

sbc100
Copy link
Member

@sbc100 sbc100 commented Apr 8, 2021

Even when the result is to be printed rather than compared byte for byte
with the first version its still good to process the resulting wat
output file so that we know we can parse what we generate.

Case in point, this changed caused me to fix two latent bugs:

  1. We were not correctly parsing events with inline import/export.
  2. We were output element segment names even when bulk memory
    was not enabled (See wasm2wat --generate-names produces invalid names #1651)

The fix for (2) is a little more involved that we might like since for
the first time the wat writer needs to know what features are enabled.

Fixes: #1651

Copy link
Member

@ngzhian ngzhian left a comment

Choose a reason for hiding this comment

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

I'm not too familiar with the event field parsing part, the rest lgtm, nice clean up in the run-roundtrip.py script!

src/wat-writer.cc Outdated Show resolved Hide resolved
@sbc100
Copy link
Member Author

sbc100 commented Apr 8, 2021

@binji .. do you think there is any way we can avoid having to pass features to the wat writer here?

@sbc100
Copy link
Member Author

sbc100 commented Apr 8, 2021

@binji .. do you think there is any way we can avoid having to pass features to the wat writer here?

I guess the alternative would be instead to pass Features to GenerateNames and in that case avoid generating segment names at all?

// The first name we encounter here, pre-bulk-memory, was intended to refer to
// the table while segment names were not supported at all. For this reason
// we cannot emit a segment name here without bulk-memory enabled, otherwise
// the name will be assumed to be the ame of a table and parsing will fail.
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, typo here, s/ame/name.

@sbc100
Copy link
Member Author

sbc100 commented Apr 12, 2021

@binji any objections to this approach?

@keithw
Copy link
Member

keithw commented Aug 15, 2022

I took the liberty of rebasing this on top of the current main branch, which caused it to start crashing on a bug that is fixed by #1889, which I also rebased on top of the current main branch and then rebased this PR on top of it.

@takikawa @sbc100 any objections to merging both of these in their present form?

@keithw
Copy link
Member

keithw commented Aug 15, 2022

Longer-term, it could be nice to try to enforcing roundtripping on every (valid?) module in the spec tests.

@keithw
Copy link
Member

keithw commented Feb 25, 2023

It doesn't look like #1889 will be merged soon, but it seems like it would still be nice to get this PR in after almost two years and benefit from the enhanced testing. How about if we disable the roundtrip/fold-function-references.txt test for now? (Thanks to this PR's full roundtripping, that test file starts exposing a bug that #1889 would fix.)

I just rebased this on the current main branch (and added a SKIP to that test file). @sbc100 Any objections to merging at this point?

Even when the result is to be printed rather than compared byte for byte
with the first version its still good to process the resulting wat
output file so that we know we can parse what we generate.

Case in point, this changed caused me to fix two latent bugs:

1. We were not correctly parsing events with inline import/export.
2. We were output element segment names even when bulk memory
   was not enabled (See #1651)

The fix for (2) is a little more involved that we might like since for
the first time the wat writer needs to know what features are enabled.

Fixes: #1651
Copy link
Member Author

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Great! Lets land it

@keithw keithw merged commit 86d025b into main Mar 1, 2023
@keithw keithw deleted the roundtrip branch March 1, 2023 00:30
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.

wasm2wat --generate-names produces invalid names
3 participants