-
Notifications
You must be signed in to change notification settings - Fork 236
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
Update handling and parsing of element segments #1126
Merged
alexcrichton
merged 2 commits into
bytecodealliance:main
from
alexcrichton:fix-element-segments
Jul 17, 2023
Merged
Update handling and parsing of element segments #1126
alexcrichton
merged 2 commits into
bytecodealliance:main
from
alexcrichton:fix-element-segments
Jul 17, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit started off by updating the spec testsuite submodule to the latest version and I ended up fixing various bits of parsing element segments. The changes here are a little subtle, but they are: * The text format for element segments was refactored and audited to attempt to match what's currently written in the spec. The spec testsuite doesn't look like it follows the spec perfectly so a few adjustments are made. The main change here functionally is that inline element segments on `table` definitions might now automatically switch a list-of-index text format into a list-of-expression binary format. This is what bytecodealliance#952 and its discussion was about. Other than this though some parsing has been tightened up as previously some invalid element segments were allowed and now require some more specifiers. For example `(elem)` was previously considered valid but that is no longer valid, instead it must be `(elem func)`. * The `wasmparser` and `wasm-encoder` crates have both removed the type field from their element segment representations, instead only having this type information on the list-of-expressions payload. This reflects how in the binary format the list-of-indexes form of element segments does not have type information. This was primarily done to adjust validation to pass a new test where a list-of-indexes element segment seems to be expected to fit in a table of `(ref func)`. This means that the type of the element segment previously inferred as `funcref` was no longer valid and instead it should be `(ref func)`. To better represent this these pieces were refactored internally. * Validation of the `table_init` instruction was updated to perform a subtyping check between the element segment and the destination table to allow initializing a nullable table with a non-nullable element segment, which is a valid operation where the types are not exactly equal. * One extra error message had to be allowed for some new spec tests about invalid modules. Overall this isn't expected to be a major update of any form. Just another in the long line of updates and adjustments to how element segments work and validate.
Merged
pchickey
approved these changes
Jul 17, 2023
dhil
pushed a commit
to dhil/wasm-tools
that referenced
this pull request
Jul 21, 2023
* Update handling and parsing of element segments This commit started off by updating the spec testsuite submodule to the latest version and I ended up fixing various bits of parsing element segments. The changes here are a little subtle, but they are: * The text format for element segments was refactored and audited to attempt to match what's currently written in the spec. The spec testsuite doesn't look like it follows the spec perfectly so a few adjustments are made. The main change here functionally is that inline element segments on `table` definitions might now automatically switch a list-of-index text format into a list-of-expression binary format. This is what bytecodealliance#952 and its discussion was about. Other than this though some parsing has been tightened up as previously some invalid element segments were allowed and now require some more specifiers. For example `(elem)` was previously considered valid but that is no longer valid, instead it must be `(elem func)`. * The `wasmparser` and `wasm-encoder` crates have both removed the type field from their element segment representations, instead only having this type information on the list-of-expressions payload. This reflects how in the binary format the list-of-indexes form of element segments does not have type information. This was primarily done to adjust validation to pass a new test where a list-of-indexes element segment seems to be expected to fit in a table of `(ref func)`. This means that the type of the element segment previously inferred as `funcref` was no longer valid and instead it should be `(ref func)`. To better represent this these pieces were refactored internally. * Validation of the `table_init` instruction was updated to perform a subtyping check between the element segment and the destination table to allow initializing a nullable table with a non-nullable element segment, which is a valid operation where the types are not exactly equal. * One extra error message had to be allowed for some new spec tests about invalid modules. Overall this isn't expected to be a major update of any form. Just another in the long line of updates and adjustments to how element segments work and validate. * Fix benchmark
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit started off by updating the spec testsuite submodule to the latest version and I ended up fixing various bits of parsing element segments. The changes here are a little subtle, but they are:
The text format for element segments was refactored and audited to attempt to match what's currently written in the spec. The spec testsuite doesn't look like it follows the spec perfectly so a few adjustments are made. The main change here functionally is that inline element segments on
table
definitions might now automatically switch a list-of-index text format into a list-of-expression binary format. This is what Support for Wast table initialisation syntactic sugar with typeful references #952 and its discussion was about. Other than this though some parsing has been tightened up as previously some invalid element segments were allowed and now require some more specifiers. For example(elem)
was previously considered valid but that is no longer valid, instead it must be(elem func)
.The
wasmparser
andwasm-encoder
crates have both removed the type field from their element segment representations, instead only having this type information on the list-of-expressions payload. This reflects how in the binary format the list-of-indexes form of element segments does not have type information. This was primarily done to adjust validation to pass a new test where a list-of-indexes element segment seems to be expected to fit in a table of(ref func)
. This means that the type of the element segment previously inferred asfuncref
was no longer valid and instead it should be(ref func)
. To better represent this these pieces were refactored internally.Validation of the
table_init
instruction was updated to perform a subtyping check between the element segment and the destination table to allow initializing a nullable table with a non-nullable element segment, which is a valid operation where the types are not exactly equal.One extra error message had to be allowed for some new spec tests about invalid modules.
Overall this isn't expected to be a major update of any form. Just another in the long line of updates and adjustments to how element segments work and validate.