You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* threads: add `shared` heap types
The shared-everything-thread [proposal] specifies that all abstract heap
types can be marked `shared` by prepending them with the 0x65 prefix
byte. While we wait for clarification on what this precisely means, I
chose to implement the "extra byte" version, which will result in larger
binaries that use `shared` types.
The key change here is that `wasmparser::HeapType` now groups all of the
abstract heap types (e.g., `any`) into a
`wasmparser::HeapType::Abstract` variant, which allows us to mark those
as `shared` in a single place. This results in a cascade of changes
elsewhere, most of which are pretty harmless (an extra, internal `match`
on the `ty` of the `Abstract` variant). The real business left
unfinished by this commit is _what_ to do with the `shared` field in all
of these locations; for now I've just noted those as TODOs to get a
review on this approach so far before forging ahead.
[proposal]: https://github.com/WebAssembly/shared-everything-threads
[#64]: WebAssembly/shared-everything-threads#64
* threads: propagate `shared` field to `wasm_encoder`
This continues the work of the previous commit by propagating the
`shared` field of abstract heap types through to `wasm_encoder`, with
uses in various other crates. As before, the boundary at which we cannot
yet handle sharedness is marked with TODO.
* threads: propagate `shared` into `wast`
This finally extends `shared` into the heap types defined in `wast`. As
before, a distinction is drawn between abstract and concrete heap
types.
* review: refactor reading of short-hand reftypes
* review: run CI-specific `rustfmt` invocation
* review: use short-hand `RefType` constant for brevity
* review: use `Into` for wasmparser-to-wasm-encoder conversion
* review: document which proposal `shared` appears in
* review: fix typo, 'eqf' -> 'eq'
* review: remove unnecessary TODO
* review: link to shared-ness issue for reference conversions
* review: fix typo
* review: add `wasmparser` feature for `Into` conversions
* review: use type shorthand in wasm-smith
* review: use more `Into` conversions
* review: add aliases for heap types
* review: add clarity parentheses
* review: add and use more heap type aliases (in wasmparser)
* review: use aliases... more
* review: integrate with upstream
* review: re-add full explicit matching in subtype check
* fix: re-run rustfmt
* review: handle shared peeking in wast
* threads: check reference types for `shared`-ness
In previous commits, we were unable to determine if a reference type was
shared because concrete heap types point to a type elsewhere in the
module that we weren't able to retrieve at the time the check was made.
This change fixes that by plumbing a `TypeList` through to the right
place and implementing `TypeList::is_shared`. This will still fail with
a `todo!()` at the boundary of where shared-ness is implemented; once
composite types gain shared flags that `todo!()` should go away.
* threads: fix parsing ambiguities
When parsing a shared global in the WebAssembly text format, one might
run across the following text: `(global (shared anyref))`. In the
current paradigm, this should parse to a `shared` global that contains
an invalid `anyref` (i.e., `(ref null any)` in long-form, which is
unshared); this should be parseable but result in a validation error.
The correct form is `(global (shared (shared anyref)))`.
This change fixes several issues related to this as well as refactoring
some of the "short-hand"/"long-hand" parsing code.
* threads: add heap type tests
This change adds generated tests for all of the abstract heap types when
they are `shared` and placed in `shared` globals. Since globals are the
only thing we can mark shared now that can touch these types, they are a
good vehicle for testing the parsing, encoding, and validation of all of
this. Eventually the same must be done for concrete heap types once
composite types (`func`, `struct`, `array`) can be marked shared.
0 commit comments