Skip to content

Allow struct.wait expected value to be a supertype - #9139

Merged
stevenfontanella merged 2 commits into
mainfrom
supertype-fix
Sep 23, 2026
Merged

stevenfontanella merged 2 commits into
mainfrom
supertype-fix

Conversation

@stevenfontanella

@stevenfontanella stevenfontanella commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

For ref fields, the expected ref that's passed in does not need to be a subtype of the struct's field's type. See the typing rules from the proposal, and WebAssembly/shared-everything-threads#92 which explains why. From the spec:

wait_expected(i32) = i32
wait_expected(i64) = i64
wait_expected(t) = (ref null (shared eq)) -- if t <: (ref null (shared eq))

C |- struct.wait x y : [(ref null x) (ref null (shared waitqueue)) t i64] -> [i32]
 -- C.types[x] = shared? struct ft*
 -- ft*[y] = mut? t'
 -- t = wait_expected(t')

In this case t <: (ref null (shared eq)) and it's not required that t <: t'.


Since the expected value isn't required to be a subtype of the field type, we no longer need the fixing code in TypeRefining.cpp. This matches the behavior for the expected field of atomic cmpxchg, which doesn't touch curr->expected. The type-refining-gufa test was a mis-optimization before, because it caused the struct.wait to block (by changing the expected value to ref.null) when it did not block in the original program.

Part of #8315.

@stevenfontanella stevenfontanella changed the title Fix allowing supertypes as expected value in struct.wait Allow struct.wait expected value to be a supertype Sep 22, 2026
@stevenfontanella
stevenfontanella marked this pull request as ready for review September 23, 2026 20:13
@stevenfontanella
stevenfontanella requested a review from a team as a code owner September 23, 2026 20:13
@stevenfontanella
stevenfontanella requested review from kripken and removed request for a team September 23, 2026 20:13
Comment thread test/lit/passes/type-refining-gufa-rmw.wast
@stevenfontanella
stevenfontanella enabled auto-merge (squash) September 23, 2026 21:01
@stevenfontanella
stevenfontanella merged commit 1c0c9f3 into main Sep 23, 2026
26 of 32 checks passed
@stevenfontanella
stevenfontanella deleted the supertype-fix branch September 23, 2026 21:23
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