-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Wasm-GC] Fix missing write barrier in BBQJIT struct.set
https://bugs.webkit.org/show_bug.cgi?id=266043 Reviewed by Yusuke Suzuki. Adds a missing write barrier for struct.set in BBQJIT. Also optimize how struct mutation is done for initialization (e.g., struct.new), because the old approach was compiling duplicate loads for the payload pointer. * JSTests/wasm/gc/bug266043.js: Added. * Source/JavaScriptCore/wasm/WasmBBQJIT.cpp: (JSC::Wasm::BBQJIT::emitStructSet): (JSC::Wasm::BBQJIT::emitStructPayloadSet): (JSC::Wasm::BBQJIT::addStructNewDefault): (JSC::Wasm::BBQJIT::addStructNew): Canonical link: https://commits.webkit.org/271740@main
- Loading branch information
Showing
2 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//@ 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))) | ||
) | ||
`); | ||
|
||
// GC to ensure struct is an old object. | ||
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)))) | ||
) | ||
`); | ||
|
||
// Do an eden GC for the new struct allocated in m2. Write barriers | ||
// should ensure that the object will be kept live. | ||
m2.exports.g(struct); | ||
edenGC(); | ||
assert.eq(m2.exports.h(struct), 42); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters