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

Update handling and parsing of element segments #1126

Merged
merged 2 commits into from Jul 17, 2023

Conversation

alexcrichton
Copy link
Member

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 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.

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.
@alexcrichton alexcrichton merged commit c91f611 into bytecodealliance:main Jul 17, 2023
15 checks passed
@alexcrichton alexcrichton deleted the fix-element-segments branch July 17, 2023 17:08
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants