-
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 write barrier bug in BBQ array.set
https://bugs.webkit.org/show_bug.cgi?id=267381 Reviewed by Justin Michaud. Fixes a bug in the patch for bug245405. The write barriers in these cases were in the right place, but the condition to check for them was wrong (because BBQ values use I64 type kind for Ref types). The condition now uses the type index to look up the type. * JSTests/wasm/gc/bug267381.js: Added. (i.assert.eq.m2.exports): * Source/JavaScriptCore/wasm/WasmBBQJIT.cpp: (JSC::Wasm::BBQJIT::addArrayNewFixed): (JSC::Wasm::BBQJIT::addArraySet): Canonical link: https://commits.webkit.org/272923@main
- Loading branch information
Showing
2 changed files
with
62 additions
and
6 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,57 @@ | ||
//@ runWebAssemblySuite("--useWebAssemblyTypedFunctionReferences=true", "--useWebAssemblyGC=true", "--useWebAssemblyExtendedConstantExpressions=true") | ||
|
||
import * as assert from "../assert.js"; | ||
import { instantiate } from "./wast-wrapper.js"; | ||
|
||
{ | ||
const m1 = instantiate(` | ||
(module | ||
(type (struct (field i32))) | ||
(type (array (mut (ref null 0)))) | ||
(func (export "maker") (result (ref 1)) | ||
(array.new_default 1 (i32.const 5)))) | ||
`); | ||
|
||
const arr = m1.exports.maker(); | ||
assert.isObject(arr); | ||
|
||
// Do a GC to ensure the array is an old object. | ||
gc(); | ||
|
||
const m2 = instantiate(` | ||
(module | ||
(type (struct (field i32))) | ||
(type (array (mut (ref null 0)))) | ||
(func (export "set") (param (ref 1) i32) | ||
(array.set 1 (local.get 0) (local.get 1) (struct.new 0 (i32.const 42)))) | ||
(func (export "get") (param (ref 1) i32) (result i32) | ||
(struct.get 0 0 (array.get 1 (local.get 0) (local.get 1))))) | ||
`); | ||
|
||
for (var i = 0; i < 5; i++) | ||
m2.exports.set(arr, i); | ||
|
||
// Do an eden GC to test write barriers. | ||
edenGC(); | ||
|
||
for (var i = 0; i < 5; i++) | ||
assert.eq(m2.exports.get(arr, i), 42); | ||
} | ||
|
||
// Test array.new_fixed case. | ||
{ | ||
const m = instantiate(` | ||
(module | ||
(type (struct (field i32))) | ||
(type (array (mut (ref null 0)))) | ||
(func (export "maker") (result (ref 1)) | ||
(array.new_fixed 1 2 (struct.new 0 (i32.const 42)) (struct.new 0 (i32.const 42)))) | ||
(func (export "get") (param (ref 1) i32) (result i32) | ||
(struct.get 0 0 (array.get 1 (local.get 0) (local.get 1))))) | ||
`); | ||
|
||
const arr = m.exports.maker(); | ||
gc(); | ||
assert.eq(m.exports.get(arr, 0), 42); | ||
assert.eq(m.exports.get(arr, 1), 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