bytecodealliance / wasm-tools

CLI and Rust libraries for low-level manipulation of WebAssembly modules
Apache License 2.0
1.21k stars 224 forks source link

threads: add `shared` heap types #1600

Closed abrown closed 2 weeks ago

abrown commented 3 weeks ago

This changes heap types everywhere to allow them to be shared as described in the shared-everything-threads proposal. The key refactoring is to push down all the abstract heap types (e.g., func, any, etc.) into an AbstractHeapType, leaving the HeapType enum with two variants: Abstract and Concrete. This allows the Abstract side to be marked shared; the Concrete side's shared-ness must be checked by looking at the pointed-to type, something which isn't yet addressed by this PR.

There are several parts of the PR that bump up against the boundary of what can be marked shared currently (e.g., FuncType and related types can't yet be marked shared). I've commented these locations with TODO: handle shared to be dealt with in future PRs that continue expanding shared everywhere.

abrown commented 3 weeks ago

High-level question, how complete do you want to get this before landing? For example do you want to have all the // TODO resolved?

No, I think I want to keep the boundary-level TODO: handle shared around so I can make sure to check all these places when I expand shared types even more. The real question for me about completeness is testing: as I describe above, I can't write spec tests without shared-checking, but I kind of wanted to defer that for a future PR. I'm open to fixing it all here, though, but it's all getting a bit unwieldy...