The latest version of the Wasm GC proposal introduces a notion of a "recursion group" (https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md#type-definitions), which is a way to explicitly introduce recursive types in an iso-recursive type system. These type definitions use the operator `rec` to introduce types. An example `rec` type declaration: ``` (module (rec (type $f (func (result (ref 0)))) (type $s (struct)))) ``` JSC will need to support these and also new `sub` types to fully support the GC proposal. The basic implementation of rec types is thankfully not too difficult in JSC thanks to the fact that Wasm type definitions are already hash-consed. (the iso-recursive type system design makes it easy to support a bottom-up, hash-consed implementation strategy)
Created attachment 458174 [details] Patch
This patch modifies one of the wasm.json files. Please ensure that any changes in one have been mirrored to the other. You can find the wasm.json files at "Source/JavaScriptCore/wasm/wasm.json" and "JSTests/wasm/wasm.json".
I've marked this for review now since EWS is looking green. If this patch lands after more Wasm GC struct patches land, it will likely need to change to also put in type expansion in appropriate places for struct operations. (if it lands before, then the struct patches should change for the same reason)
I'm rebasing this now on top of recent Wasm GC patches that landed (there are some conflicts). The patch also needs some modification because I found a bug in the GC reference interpreter (https://github.com/WebAssembly/gc/issues/290), which changes some of expectations for test cases. (Specifically, function signatures should be tracked as type indices in more places because, e.g., import or call_indirect signature checks need to use the type index of the recursion group projection instead of just the underlying function)
Created attachment 458536 [details] Patch
<rdar://problem/92537953>
Created attachment 458895 [details] Patch
Rebased and made some small refactorings to prepare it better for the `sub` type patch. I've also mostly finished a patch for sub types, which I'll upload after `rec` types land.
Pull request: https://github.com/WebKit/WebKit/pull/740
Committed 253491@main (5f3859595e5e): <https://commits.webkit.org/253491@main> Reviewed commits have been landed. Closing PR #740 and removing active labels.
Re-opened since this is blocked by bug 244062
Pull request: https://github.com/WebKit/WebKit/pull/3599
Committed 253736@main (38c77df13331): <https://commits.webkit.org/253736@main> Reviewed commits have been landed. Closing PR #3599 and removing active labels.