-
-
Notifications
You must be signed in to change notification settings - Fork 669
Implement preliminary creation of Wasm GC types #2537
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reading the GC explainer wrt. the failing duplicate-fields test, the rules in play are
i.e. mutable fields are invariant. I guess there is a reason for this limitation Edit: Reason is, of course, that class Animal {
parent: Animal;
}
class Cat extends Animal {
parent: Cat;
}
class Dog extends Animal {
parent: Dog;
}
let animal: Animal = new Cat();
animal.parent = new Dog(); is allowed by covariance but unsound, so we should revert to make this actually type safe. Was introduced in #2158. |
Adds logic to incrementally create Wasm GC types with Binaryen's type builder. Is necessary because Binaryen is switching to utilize GC types internally to have all the information, even when the GC feature is disabled, then emitting reference types. Required by #2531 so we can create
ref.func
expressions with concrete types (cc @MaxGraey).Still some TODOs:
array
members yet. AnArray<T>
for example would wrap a GCarray
, while anArrayBuffer
would be represented by one. However, since the respective code and stdlib changes have not yet been made, yet would go in tandem with the types, this is left out for now. My expectation is that we'd add a source-level (lower case)array<T>
type that is directly bound to the respective Wasm GC type for stdlib to use, perhaps somewhat like:foo
with a subtyping relationship.This is sound afaict, butappears to be not supported by Wasm GC, unless bothfoo
s would be immutable fields, which they aren't in our case. Looks like we'd have to revert support for specializing duplicate fields like this in order to use Wasm GC (see below).func_subtype
and whatnot, even though the GC feature is disabled. See: Regression when generatingref.func
? WebAssembly/binaryen#5136 (comment)ensureType(theFunctionSignature)
for use withModule#ref_func
to make it work again, even if the GC type isn't otherwise used and Binaryen would outputfuncref
iiuc.