Bug 239666 - [Wasm-GC] Add support for recursion groups
Summary: [Wasm-GC] Add support for recursion groups
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebAssembly (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 244062
Blocks: 247394
  Show dependency treegraph
 
Reported: 2022-04-22 12:23 PDT by Asumu Takikawa
Modified: 2022-11-02 17:15 PDT (History)
9 users (show)

See Also:


Attachments
Patch (75.06 KB, patch)
2022-04-22 14:26 PDT, Asumu Takikawa
no flags Details | Formatted Diff | Diff
Patch (82.38 KB, patch)
2022-04-28 11:15 PDT, Asumu Takikawa
no flags Details | Formatted Diff | Diff
Patch (81.97 KB, patch)
2022-05-05 11:03 PDT, Asumu Takikawa
asumu: review?
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Asumu Takikawa 2022-04-22 12:23:43 PDT
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)
Comment 1 Asumu Takikawa 2022-04-22 14:26:13 PDT
Created attachment 458174 [details]
Patch
Comment 2 EWS Watchlist 2022-04-22 14:27:47 PDT
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".
Comment 3 Asumu Takikawa 2022-04-22 22:30:25 PDT
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)
Comment 4 Asumu Takikawa 2022-04-27 16:31:07 PDT
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)
Comment 5 Asumu Takikawa 2022-04-28 11:15:06 PDT
Created attachment 458536 [details]
Patch
Comment 6 Radar WebKit Bug Importer 2022-04-29 12:24:15 PDT
<rdar://problem/92537953>
Comment 7 Asumu Takikawa 2022-05-05 11:03:49 PDT
Created attachment 458895 [details]
Patch
Comment 8 Asumu Takikawa 2022-05-05 11:04:45 PDT
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.
Comment 9 Asumu Takikawa 2022-05-18 12:37:49 PDT
Pull request: https://github.com/WebKit/WebKit/pull/740
Comment 10 EWS 2022-08-16 16:15:35 PDT
Committed 253491@main (5f3859595e5e): <https://commits.webkit.org/253491@main>

Reviewed commits have been landed. Closing PR #740 and removing active labels.
Comment 11 WebKit Commit Bot 2022-08-17 15:20:03 PDT
Re-opened since this is blocked by bug 244062
Comment 12 Asumu Takikawa 2022-08-23 17:07:19 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3599
Comment 13 EWS 2022-08-24 12:40:13 PDT
Committed 253736@main (38c77df13331): <https://commits.webkit.org/253736@main>

Reviewed commits have been landed. Closing PR #3599 and removing active labels.