Bug 247394

Summary: ☂️ [Wasm-GC] WebAssembly Garbage Collection Proposal
Product: WebKit Reporter: Asumu Takikawa <asumu>
Component: WebAssemblyAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: adamk, bashorov, chi187, cryze92, darkwei233, dcviana, elitree, michalkubizna, nimajneb0905, tjc, tomac, vitaldu, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 233416, 233919, 244388, 244838, 253029, 254760, 258219, 261640, 265601, 272004, 237029, 239493, 239666, 239668, 240980, 240982, 242261, 243078, 243079, 243208, 244352, 245252, 245405, 246049, 246769, 246981, 247336, 247399, 247401, 247403, 247536, 247576, 247874, 249149, 249197, 249503, 250107, 250474, 250489, 250613, 251039, 251041, 251133, 251329, 251330, 251338, 251874, 252299, 252349, 252350, 252538, 252539, 252719, 252722, 254178, 254226, 254412, 254414, 254693, 254694, 254695, 254696, 258127, 258128, 258499, 258796, 258801, 258804, 258805, 259894, 260039, 260516, 260542, 260820, 260910, 264057, 264454, 264616, 264655, 265628, 265677, 265678, 265720, 265721, 265722, 265742, 265927, 266043, 266056, 266127, 266167, 267245, 267357, 267381, 268848, 268870, 269024, 269123, 269578, 270374    
Bug Blocks:    

Description Asumu Takikawa 2022-11-02 17:12:30 PDT
This is an umbrella bug for tracking the implementation of the Wasm GC proposal.

Proposal link: https://github.com/WebAssembly/gc/
Comment 1 Radar WebKit Bug Importer 2022-11-09 16:13:17 PST
<rdar://problem/102165851>
Comment 2 Asumu Takikawa 2023-03-29 15:07:22 PDT
The patch in https://github.com/WebKit/WebKit/pull/12135 is the last one that I have written for Wasm GC. Unfortunately I can't work on further patches at the moment. In this comment I'll document the other pieces that are needed to complete support for Wasm GC.

  * Semantics
    - Support final attribute for types, this should be pretty simple to implement (https://bugs.webkit.org/show_bug.cgi?id=250107)
    - Support GC types in globals, with suitable JS API conversions by calling extern.internalize & ref.cast (https://bugs.webkit.org/show_bug.cgi?id=252349)
    - Implement packed types (i8, i16) for structs (https://bugs.webkit.org/show_bug.cgi?id=246981)
    - Update element segments and any other table-related sections for GC & typed funcrefs (https://bugs.webkit.org/show_bug.cgi?id=251874)
    - Implement GC bulk array operations if they are added to the spec (https://github.com/WebAssembly/gc/pull/363)
    - Adjust ref.cast validation for upcoming spec changes (https://github.com/WebAssembly/gc/pull/359)
    - Implement br_on_cast and br_on_cast_fail (https://bugs.webkit.org/show_bug.cgi?id=254694)
    - Implement JS API casts at Wasm<->JS function call boundaries (https://bugs.webkit.org/show_bug.cgi?id=254693)
    - Add `nullexternref` and `nullfuncref` types (https://bugs.webkit.org/show_bug.cgi?id=254695)
    - Add new constant expressions that the GC proposal adds (https://bugs.webkit.org/show_bug.cgi?id=254696)
    - Align JSC with new implementation limits: https://github.com/WebAssembly/gc/pull/360

  * Optimization
    - Inline array access & allocation in JIT paths (https://bugs.webkit.org/show_bug.cgi?id=245405)
    - Inline struct allocations in JIT (https://bugs.webkit.org/show_bug.cgi?id=244388)
    - Explore optimizing space usage by putting struct/array data inside the JSObject butterfly
    - BBQJIT tier support

More generally, the proposal will likely do an opcode refactoring and renumbering before it is finalized and reaches stage 4, so that will require changes as well. Currently there is some divergence between the spec and implementations in terms of supported opcodes, so it may be necessary to temporarily support other opcodes to be able to run example Wasm GC code produced by toolchains.

Only a subset of GC spec tests are imported into JSC tests currently, as there are tests that depend on some of the open bugs above (e.g., array tests depend on array allocation constant expressions for globals).
Comment 3 Tim Chevalier 2023-03-30 11:22:30 PDT
Bug 253029 tracks specifically which open issues have to be fixed in order to import the array spec tests. (Maybe it's worth creating similar bugs for the other GC spec tests.)
Comment 4 bashorov 2023-05-27 14:02:21 PDT
Hi, everyone!

In about a week, there will be a Web Engines Hackfest. 
I'm trying to organize there a Breakout Session about Wasm GC in JavaScriptCore. 

Honestly, my knowledge of JavaScriptCore is minimal, but I'd love to know more about JSC and contribute some things. I believe I'm not alone. So I'm looking for help with organizing the session.

## Breakout Session

Preparation:
Since we are limited in time, ask participants to do a few things in advance:
* Read or watch materials about Wasm GC to become familiar.
  * TODO ASAP: collect materials.
* Check out and build JSC
  * TODO ASAP: instruction, likely instruction inside WebKit repo is enough.
* Something to read about JSC internals?
* Prepare a list of simple issues to look at during the session, preferably around Wasm GC

Agenda:
* Overview of Wasm implementation in JSC.
* Overview of Wasm GC (and related proposals) implementation details in JSC.
* Try to fix something simple, preferably around Wasm GC. (All together or in groups, or individually)
   * Make sure everyone built it in advance.
--

What do you think?
Do you think it's feasible?
Would you like to help with technical parts? (offline or online)

Any thoughts and suggestions are welcome. 
Thanks!

You can find my contacts at zal.im
--
Zalim