Bug 266043

Summary: [Wasm-GC] Fix missing write barrier in BBQJIT struct.set
Product: WebKit Reporter: Asumu Takikawa <asumu>
Component: WebAssemblyAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 247394    

Description Asumu Takikawa 2023-12-07 17:02:39 PST
The following test crashes in the BBQJIT tier:

```
//@ runWebAssemblySuite("--useWebAssemblyTypedFunctionReferences=true", "--useWebAssemblyGC=true")

import * as assert from "../assert.js";
import { compile, instantiate } from "./wast-wrapper.js";

const m1 = instantiate(`
  (module
    (type (struct (field i32)))
    (type (struct (field (mut (ref null 0)))))
    (func (export "f") (result (ref any))
      (struct.new 1 (ref.null 0)))
  )
`);

const struct = m1.exports.f()
gc();

const m2 = instantiate(`
  (module
    (type (struct (field i32)))
    (type (struct (field (mut (ref null 0)))))
    (func (export "g") (param (ref 1))
      (struct.set 1 0 (local.get 0) (struct.new 0 (i32.const 42))))
    (func (export "h") (param (ref 1)) (result i32)
      (struct.get 0 0 (struct.get 1 0 (local.get 0))))
  )
`);

m2.exports.g(struct);
edenGC();
assert.equals(m2.exports.h(struct), 42);
```
This is due to a missing write barrier, ensuring that the old object from module m1 has a reference to a new object in module m2 that will be traced.
Comment 1 Asumu Takikawa 2023-12-07 17:33:34 PST
Pull request: https://github.com/WebKit/WebKit/pull/21484
Comment 2 EWS 2023-12-08 09:45:41 PST
Committed 271740@main (50def56d3557): <https://commits.webkit.org/271740@main>

Reviewed commits have been landed. Closing PR #21484 and removing active labels.
Comment 3 Radar WebKit Bug Importer 2023-12-08 09:46:15 PST
<rdar://problem/119382549>