diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /js/src/jit-test/tests/wasm/function-references/non-nullable-table.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/function-references/non-nullable-table.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/function-references/non-nullable-table.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/js/src/jit-test/tests/wasm/function-references/non-nullable-table.js b/js/src/jit-test/tests/wasm/function-references/non-nullable-table.js index 97ab04713c..4efdfcd642 100644 --- a/js/src/jit-test/tests/wasm/function-references/non-nullable-table.js +++ b/js/src/jit-test/tests/wasm/function-references/non-nullable-table.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // non-null table initialization var { get1, get2, get3, get4 } = wasmEvalText(`(module @@ -40,25 +40,33 @@ for (let i of [ )`, /(type mismatch|table with non-nullable references requires initializer)/); } -var t1 = new WebAssembly.Table({initial: 10, element: {ref: 'func', nullable: false }}, sampleWasmFunction); +let values = "10 funcref (ref.func $dummy)"; +let t1 = new wasmEvalText(`(module (func $dummy) (table (export "t1") ${values}))`).exports.t1; assertEq(t1.get(2) != null, true); -assertThrows(() => { - new WebAssembly.Table({initial: 10, element: {ref: 'func', nullable: false }}); -}); -assertThrows(() => { - new WebAssembly.Table({initial: 10, element: {ref: 'func', nullable: false }}, null); -}); -var t2 = new WebAssembly.Table({initial: 6, maximum: 20, element: {ref: 'extern', nullable: false }}, {foo: "bar"}); -assertEq(t2.get(1).foo, "bar"); +wasmFailValidateText(`(module + (table $t 10 (ref func)) +)`, /table with non-nullable references requires initializer/); + +wasmFailValidateText(` +(module + (func $dummy) + (table (export "t") 10 funcref (ref.null none)) +)`, /type mismatch/); + +const foo = "bar"; +const { t2, get } = wasmEvalText(` +(module + (global (import "" "foo") externref) + (table (export "t2") 6 20 externref (global.get 0)) +)`, { "": { "foo": foo } }).exports; + +assertEq(t2.get(5), "bar"); assertThrows(() => { t2.get(7) }); -assertThrows(() => { t2.grow(9, null) }); +assertThrows(() => { t2.grow(30, null) }); t2.grow(8, {t: "test"}); -assertEq(t2.get(3).foo, "bar"); +assertEq(t2.get(3), "bar"); assertEq(t2.get(7).t, "test"); -assertThrows(() => { - new WebAssembly.Table({initial: 10, element: {ref: 'extern', nullable: false }}, null); -}); // Fail because tables come before globals in the binary format, so tables // cannot refer to globals. |