Skip to content

[Stack Switching] Fix binary writing of continuation types when GC is not enabled#7827

Closed
kripken wants to merge 3 commits intoWebAssembly:mainfrom
kripken:cont.no-gc
Closed

[Stack Switching] Fix binary writing of continuation types when GC is not enabled#7827
kripken wants to merge 3 commits intoWebAssembly:mainfrom
kripken:cont.no-gc

Conversation

@kripken
Copy link
Copy Markdown
Member

@kripken kripken commented Aug 14, 2025

Continuation types refer to a Function type, and the old code was
emitting a top type instead of that function type, which is invalid.

@kripken kripken requested a review from tlively August 14, 2025 20:01
Copy link
Copy Markdown
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right. If GC is not enabled, so we only have reference types, then e.g. a local variable holding a reference to a particular function type should be emitted as funcref whether or not stack switching is also enabled.

How does CallIndirect emit its function type index? We should do the same when emitting a continuation type definition.

@kripken
Copy link
Copy Markdown
Member Author

kripken commented Aug 14, 2025

Ah, good point, I had a vague worry like that, but didn't see tests fail so I figured I was confused...

Fixed like callIndirect, and simplifed callIndirect too.

Comment on lines +24 to +26
(cont.new $cont
(ref.func $main)
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this doesn't make any sense without typed function references. If the ref.func is just a funcref, then there's no way to validate that the continuation type has the the same parameters as the type of the function reference it is initialized with.

And we don't differentiate between typed-function-references and gc as features, so continuations without GC simply don't make sense.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, wasn't there an effort to avoid continuations from depending on GC?

Anyhow, I'm fine with making stack switching depend on GC, is that the right thing then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but they still depend on typed function references, and we don't differentiate between that and GC. So making stack switching depend on GC is the right thing for our purposes. We can revisit this in the future (probably by adding a separate typed-function-references feature again) if anyone really needs it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I opened #7830 and will close this.

@kripken kripken closed this Aug 15, 2025
@kripken kripken deleted the cont.no-gc branch August 15, 2025 00:06
kripken added a commit that referenced this pull request Aug 15, 2025
Stack switching depends on part of GC, at least atm.

See

#7827 (comment)
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