From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/wasm/gc/tables-generalized-struct.js | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 js/src/jit-test/tests/wasm/gc/tables-generalized-struct.js (limited to 'js/src/jit-test/tests/wasm/gc/tables-generalized-struct.js') diff --git a/js/src/jit-test/tests/wasm/gc/tables-generalized-struct.js b/js/src/jit-test/tests/wasm/gc/tables-generalized-struct.js new file mode 100644 index 0000000000..b0bd964027 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/tables-generalized-struct.js @@ -0,0 +1,48 @@ +// |jit-test| skip-if: !wasmGcEnabled() + +// table.set in bounds with i32 x eqref - works, no value generated +// table.set with (ref null T) - works +// table.set with null - works +// table.set out of bounds - fails + +{ + let ins = wasmEvalText( + `(module + (table (export "t") 10 eqref) + (type $dummy (struct (field i32))) + (func (export "set_eqref") (param i32) (param eqref) + (table.set (local.get 0) (local.get 1))) + (func (export "set_null") (param i32) + (table.set (local.get 0) (ref.null eq))) + (func (export "set_ref") (param i32) (param eqref) + (table.set (local.get 0) (ref.cast (ref null $dummy) (local.get 1)))) + (func (export "make_struct") (result eqref) + (struct.new $dummy (i32.const 37))))`); + let a = ins.exports.make_struct(); + ins.exports.set_eqref(3, a); + assertEq(ins.exports.t.get(3), a); + ins.exports.set_null(3); + assertEq(ins.exports.t.get(3), null); + let b = ins.exports.make_struct(); + ins.exports.set_ref(5, b); + assertEq(ins.exports.t.get(5), b); + + assertErrorMessage(() => ins.exports.set_eqref(10, a), WebAssembly.RuntimeError, /index out of bounds/); + assertErrorMessage(() => ins.exports.set_eqref(-1, a), WebAssembly.RuntimeError, /index out of bounds/); +} + +// table.grow on table of eqref with non-null ref value + +{ + let ins = wasmEvalText( + `(module + (type $S (struct (field i32) (field f64))) + (table (export "t") 2 eqref) + (func (export "f") (result i32) + (table.grow (struct.new $S (i32.const 0) (f64.const 3.14)) (i32.const 1))))`); + assertEq(ins.exports.t.length, 2); + assertEq(ins.exports.f(), 2); + assertEq(ins.exports.t.length, 3); + assertEq(typeof ins.exports.t.get(2), "object"); +} + -- cgit v1.2.3