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

wasmprinter: print function bodies with code section #1788

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

keithw
Copy link
Contributor

@keithw keithw commented Sep 16, 2024

wasmprinter has traditionally read the code section first and then printed each function's body as soon as it reaches its entry in the function section.

For printing instructions in folded form, it's going to be inconvenient to print code before having read the whole function section (or any of the tag section), because it's necessary to have parsed these sections to know the arities of the call and throw instructions.

This PR reorders the wasmprinter output to print function bodies with the code section.

(PR 1/3 of adding a folding option to wasmprinter)

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Sounds like a good idea to me, thanks! IIRC the motivation for doing it this way was historically wasm-tools tried to match wabt's output exactly and this is the order wabt printed things. Over time though the exact match test requirement was removed and so there's no longer any need to preserve this exact output, so I think it's reasonable to change.

For the test failures there's a few more files that need to be "blessed", and you should be able to do it with:

BLESS=1 cargo test --workspace

(or BLESS=1 cargo test -p wasm-compose for just the exact test that's failing on CI, but I suspect at least the wit-component crate may also have some differences)

@alexcrichton alexcrichton added this pull request to the merge queue Sep 16, 2024
Merged via the queue into bytecodealliance:main with commit 610b7aa Sep 16, 2024
30 checks passed
@keithw keithw deleted the reorder-code-section branch September 17, 2024 00:26
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