From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/wasm/binary.js | 8 +- js/src/jit-test/tests/wasm/bug1858423.js | 2 +- .../builtin-modules/integer-gemm/directives.txt | 2 +- .../tests/wasm/builtin-modules/js-string/basic.js | 158 ++++++++++++++------- .../wasm/builtin-modules/js-string/directives.txt | 2 +- .../tests/wasm/builtin-modules/oom-test.js | 2 - .../tests/wasm/directiveless/bug1877358.js | 2 +- js/src/jit-test/tests/wasm/directives.txt | 2 +- .../jit-test/tests/wasm/exceptions/bug-1751699.js | 2 - .../jit-test/tests/wasm/exceptions/bug-1788213.js | 2 - .../jit-test/tests/wasm/exceptions/bug-1791361.js | 2 - .../jit-test/tests/wasm/exceptions/directives.txt | 2 +- .../tests/wasm/exceptions/oom-construct-message.js | 2 - .../wasm/exceptions/oom-create-exception-data.js | 2 - .../jit-test/tests/wasm/exceptions/unreachable.js | 2 +- js/src/jit-test/tests/wasm/exnref/bug1883865.js | 25 ++++ js/src/jit-test/tests/wasm/exnref/directives.txt | 2 +- js/src/jit-test/tests/wasm/extended-const/basic.js | 2 - .../tests/wasm/extended-const/directives.txt | 2 +- .../jit-test/tests/wasm/extended-const/disabled.js | 22 --- .../tests/wasm/extended-const/pathological.js | 2 - js/src/jit-test/tests/wasm/features.js | 24 +--- .../tests/wasm/function-references/as-non-null.js | 2 +- .../tests/wasm/function-references/binary.js | 2 +- .../tests/wasm/function-references/br-non-null.js | 2 +- .../tests/wasm/function-references/br-null.js | 2 +- .../tests/wasm/function-references/call_ref.js | 2 +- .../tests/wasm/function-references/directives.txt | 2 +- .../tests/wasm/function-references/disabled.js | 4 +- .../tests/wasm/function-references/nnl-test.js | 2 +- .../wasm/function-references/non-nullable-table.js | 38 +++-- .../tests/wasm/function-references/non-nullable.js | 2 +- .../wasm/function-references/reftype-parse.js | 32 +---- js/src/jit-test/tests/wasm/gc/arrays.js | 143 +++++++++++++++++++ js/src/jit-test/tests/wasm/gc/binary.js | 16 ++- js/src/jit-test/tests/wasm/gc/bug-1843295.js | 2 +- js/src/jit-test/tests/wasm/gc/bug-1845436.js | 2 +- js/src/jit-test/tests/wasm/gc/bug-1854007.js | 2 +- js/src/jit-test/tests/wasm/gc/bug-1879096.js | 65 +++++++++ .../tests/wasm/gc/call-indirect-subtyping.js | 2 +- js/src/jit-test/tests/wasm/gc/directives.txt | 2 +- js/src/jit-test/tests/wasm/gc/disabled.js | 2 +- js/src/jit-test/tests/wasm/gc/ion-and-baseline.js | 2 +- js/src/jit-test/tests/wasm/gc/limits.js | 69 --------- .../tests/wasm/gc/limits/array-new-fixed.js | 9 ++ js/src/jit-test/tests/wasm/gc/limits/load-mod.js | 5 + .../jit-test/tests/wasm/gc/limits/rec-groups-1.js | 6 + .../jit-test/tests/wasm/gc/limits/rec-groups-2.js | 6 + .../jit-test/tests/wasm/gc/limits/struct-fields.js | 11 ++ .../tests/wasm/gc/limits/subtyping-depth.js | 13 ++ js/src/jit-test/tests/wasm/gc/limits/types-1.js | 6 + js/src/jit-test/tests/wasm/gc/limits/types-2.js | 6 + js/src/jit-test/tests/wasm/gc/limits/types-3.js | 6 + js/src/jit-test/tests/wasm/gc/limits/types-4.js | 6 + js/src/jit-test/tests/wasm/gc/ref.js | 2 +- js/src/jit-test/tests/wasm/gc/regress-1754701.js | 2 +- js/src/jit-test/tests/wasm/gc/regress-1884767.js | 13 ++ js/src/jit-test/tests/wasm/gc/structs.js | 40 ------ js/src/jit-test/tests/wasm/globals.js | 117 ++++++++------- js/src/jit-test/tests/wasm/import-export.js | 7 +- .../tests/wasm/memory-control/directives.txt | 2 +- .../tests/wasm/memory-control/memory-discard.js | 2 +- js/src/jit-test/tests/wasm/memory64/directives.txt | 2 +- .../tests/wasm/multi-memory/directives.txt | 2 +- .../jit-test/tests/wasm/multi-value/directives.txt | 2 +- js/src/jit-test/tests/wasm/oom/breakpoints.js | 2 - js/src/jit-test/tests/wasm/oom/exports.js | 2 - js/src/jit-test/tests/wasm/oom/jsapi-prototype.js | 2 - .../jit-test/tests/wasm/ref-types/directives.txt | 2 +- js/src/jit-test/tests/wasm/regress/bug1708124.js | 1 - js/src/jit-test/tests/wasm/regress/bug1839065.js | 2 +- js/src/jit-test/tests/wasm/regress/bug1839142.js | 2 +- js/src/jit-test/tests/wasm/regress/bug1856733.js | 2 +- js/src/jit-test/tests/wasm/regress/bug1857829.js | 2 +- js/src/jit-test/tests/wasm/regress/bug1858982.js | 2 +- js/src/jit-test/tests/wasm/regress/bug1878673.js | 13 ++ js/src/jit-test/tests/wasm/regress/bug1880770.js | 20 +++ js/src/jit-test/tests/wasm/regress/oom-eval.js | 2 +- js/src/jit-test/tests/wasm/regress/oom-init.js | 2 +- .../tests/wasm/regress/oom-masm-baseline.js | 2 +- .../tests/wasm/regress/oom-wasm-streaming.js | 2 - .../wasm/regress/oom-wasmtexttobinary-block.js | 2 - .../oom-wrong-argument-number-for-import-call.js | 2 - js/src/jit-test/tests/wasm/simd/directives.txt | 2 +- js/src/jit-test/tests/wasm/simd/experimental.js | 36 ++--- .../wasm/spec/exception-handling/directives.txt | 2 +- .../tests/wasm/spec/extended-const/directives.txt | 2 +- .../wasm/spec/function-references/directives.txt | 2 +- .../function-references/return_call_ref.wast.js | 2 +- js/src/jit-test/tests/wasm/spec/gc/directives.txt | 2 +- .../tests/wasm/spec/memory64/directives.txt | 2 +- .../tests/wasm/spec/memory64/memory64.wast.js | 24 ++-- .../tests/wasm/spec/multi-memory/directives.txt | 2 +- .../wasm/spec/multi-memory/harness/harness.js | 9 ++ .../wasm/spec/multi-memory/memory_trap1.wast.js | 36 +++-- .../tests/wasm/spec/relaxed-simd/directives.txt | 2 +- .../jit-test/tests/wasm/spec/spec/directives.txt | 2 +- .../jit-test/tests/wasm/spec/spec/global.wast.js | 2 +- .../jit-test/tests/wasm/spec/spec/memory.wast.js | 18 +-- .../tests/wasm/spec/tail-call/directives.txt | 2 +- .../jit-test/tests/wasm/tail-calls/bug1862473.js | 2 +- .../jit-test/tests/wasm/tail-calls/bug1865044.js | 2 +- .../jit-test/tests/wasm/tail-calls/bug1871605.js | 2 +- .../jit-test/tests/wasm/tail-calls/bug1871606.js | 2 +- .../jit-test/tests/wasm/tail-calls/bug1871951.js | 2 +- .../jit-test/tests/wasm/tail-calls/directives.txt | 2 +- .../jit-test/tests/wasm/tail-calls/exceptions.js | 2 - js/src/jit-test/tests/wasm/tail-calls/gc.js | 2 +- js/src/jit-test/tests/wasm/tail-calls/litmus3.js | 2 +- js/src/jit-test/tests/wasm/tail-calls/litmus4.js | 2 +- js/src/jit-test/tests/wasm/tail-calls/litmus8.js | 2 +- js/src/jit-test/tests/wasm/tail-calls/litmus9.js | 2 +- .../tests/wasm/tail-calls/return_call_ref.js | 2 +- js/src/jit-test/tests/wasm/testing/directives.txt | 1 + .../tests/wasm/testing/global-lossless-invoke.js | 13 ++ 115 files changed, 719 insertions(+), 465 deletions(-) create mode 100644 js/src/jit-test/tests/wasm/exnref/bug1883865.js delete mode 100644 js/src/jit-test/tests/wasm/extended-const/disabled.js create mode 100644 js/src/jit-test/tests/wasm/gc/bug-1879096.js delete mode 100644 js/src/jit-test/tests/wasm/gc/limits.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/array-new-fixed.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/load-mod.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/rec-groups-1.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/rec-groups-2.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/struct-fields.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/subtyping-depth.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/types-1.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/types-2.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/types-3.js create mode 100644 js/src/jit-test/tests/wasm/gc/limits/types-4.js create mode 100644 js/src/jit-test/tests/wasm/gc/regress-1884767.js create mode 100644 js/src/jit-test/tests/wasm/regress/bug1878673.js create mode 100644 js/src/jit-test/tests/wasm/regress/bug1880770.js create mode 100644 js/src/jit-test/tests/wasm/testing/directives.txt create mode 100644 js/src/jit-test/tests/wasm/testing/global-lossless-invoke.js (limited to 'js/src/jit-test/tests/wasm') diff --git a/js/src/jit-test/tests/wasm/binary.js b/js/src/jit-test/tests/wasm/binary.js index 5a59330768..f7d60a56ce 100644 --- a/js/src/jit-test/tests/wasm/binary.js +++ b/js/src/jit-test/tests/wasm/binary.js @@ -119,7 +119,7 @@ wasmEval(moduleWithSections([tableSection0()])); wasmEval(moduleWithSections([memorySection(0)])); -function invalidMemorySection2() { +function memorySection2() { var body = []; body.push(...varU32(2)); // number of memories body.push(...varU32(0x0)); @@ -130,7 +130,11 @@ function invalidMemorySection2() { } wasmEval(moduleWithSections([memorySection0()])); -assertErrorMessage(() => wasmEval(moduleWithSections([invalidMemorySection2()])), CompileError, /number of memories must be at most one/); +if (wasmMultiMemoryEnabled()) { + wasmEval(moduleWithSections([memorySection2()])); +} else { + assertErrorMessage(() => wasmEval(moduleWithSections([memorySection2()])), CompileError, /number of memories must be at most one/); +} // Test early 'end' const bodyMismatch = /(function body length mismatch)|(operators remaining after end of function)/; diff --git a/js/src/jit-test/tests/wasm/bug1858423.js b/js/src/jit-test/tests/wasm/bug1858423.js index a90d308906..f6296c03d9 100644 --- a/js/src/jit-test/tests/wasm/bug1858423.js +++ b/js/src/jit-test/tests/wasm/bug1858423.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; skip-if: !wasmCachingEnabled() || !wasmGcEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmCachingEnabled() || !wasmGcEnabled() const code = wasmTextToBinary(`(module (type $t (struct (field i32) (field anyref))) diff --git a/js/src/jit-test/tests/wasm/builtin-modules/integer-gemm/directives.txt b/js/src/jit-test/tests/wasm/builtin-modules/integer-gemm/directives.txt index 46c9c504f4..7c458ede07 100644 --- a/js/src/jit-test/tests/wasm/builtin-modules/integer-gemm/directives.txt +++ b/js/src/jit-test/tests/wasm/builtin-modules/integer-gemm/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-moz-intgemm; skip-if: (!getBuildConfiguration("x64") && !getBuildConfiguration("x86") && !getBuildConfiguration("arm64")) || getBuildConfiguration("simulator") || !wasmMozIntGemmEnabled() +|jit-test| --setpref=wasm_moz_intgemm=true; skip-if: (!getBuildConfiguration("x64") && !getBuildConfiguration("x86") && !getBuildConfiguration("arm64")) || getBuildConfiguration("simulator") || !wasmMozIntGemmEnabled() diff --git a/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js b/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js index dce6204fee..2c0ecb89c5 100644 --- a/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js +++ b/js/src/jit-test/tests/wasm/builtin-modules/js-string/basic.js @@ -1,110 +1,126 @@ // |jit-test| skip-if: !wasmJSStringBuiltinsEnabled(); -let testModule = wasmTextToBinary(`(module +let testModule = `(module + (type $arrayMutI16 (array (mut i16))) + (func - (import "wasm:js-string" "fromWTF16Array") - (param anyref i32 i32) - (result externref) + (import "wasm:js-string" "test") + (param externref) + (result i32) + ) + (export "test" (func 0)) + + (func + (import "wasm:js-string" "cast") + (param externref) + (result (ref extern)) + ) + (export "cast" (func 1)) + + (func + (import "wasm:js-string" "fromCharCodeArray") + (param (ref null $arrayMutI16) i32 i32) + (result (ref extern)) ) - (export "fromWTF16Array" (func 0)) + (export "fromCharCodeArray" (func 2)) (func - (import "wasm:js-string" "toWTF16Array") - (param externref anyref i32) + (import "wasm:js-string" "intoCharCodeArray") + (param externref (ref null $arrayMutI16) i32) (result i32) ) - (export "toWTF16Array" (func 1)) + (export "intoCharCodeArray" (func 3)) (func (import "wasm:js-string" "fromCharCode") (param i32) (result externref) ) - (export "fromCharCode" (func 2)) + (export "fromCharCode" (func 4)) (func (import "wasm:js-string" "fromCodePoint") (param i32) (result externref) ) - (export "fromCodePoint" (func 3)) + (export "fromCodePoint" (func 5)) (func (import "wasm:js-string" "charCodeAt") (param externref i32) (result i32) ) - (export "charCodeAt" (func 4)) + (export "charCodeAt" (func 6)) (func (import "wasm:js-string" "codePointAt") (param externref i32) (result i32) ) - (export "codePointAt" (func 5)) + (export "codePointAt" (func 7)) (func (import "wasm:js-string" "length") (param externref) (result i32) ) - (export "length" (func 6)) + (export "length" (func 8)) (func - (import "wasm:js-string" "concatenate") + (import "wasm:js-string" "concat") (param externref externref) (result externref) ) - (export "concatenate" (func 7)) + (export "concat" (func 9)) (func (import "wasm:js-string" "substring") (param externref i32 i32) (result externref) ) - (export "substring" (func 8)) + (export "substring" (func 10)) (func (import "wasm:js-string" "equals") (param externref externref) (result i32) ) - (export "equals" (func 9)) + (export "equals" (func 11)) (func (import "wasm:js-string" "compare") (param externref externref) (result i32) ) - (export "compare" (func 10)) -)`); + (export "compare" (func 12)) +)`; let { - createArray, + createArrayMutI16, arrayLength, arraySet, arrayGet } = wasmEvalText(`(module - (type $i16Array (array (mut i16))) - (func (export "createArray") (param i32) (result anyref) + (type $arrayMutI16 (array (mut i16))) + (func (export "createArrayMutI16") (param i32) (result anyref) i32.const 0 local.get 0 - array.new $i16Array + array.new $arrayMutI16 ) (func (export "arrayLength") (param arrayref) (result i32) local.get 0 array.len ) - (func (export "arraySet") (param (ref $i16Array) i32 i32) + (func (export "arraySet") (param (ref $arrayMutI16) i32 i32) local.get 0 local.get 1 local.get 2 - array.set $i16Array + array.set $arrayMutI16 ) - (func (export "arrayGet") (param (ref $i16Array) i32) (result i32) + (func (export "arrayGet") (param (ref $arrayMutI16) i32) (result i32) local.get 0 local.get 1 - array.get_u $i16Array + array.get_u $arrayMutI16 ) )`).exports; @@ -114,9 +130,23 @@ function throwIfNotString(a) { } } let polyFillImports = { - fromWTF16Array: (array, arrayStart, arrayCount) => { - arrayStart |= 0; - arrayCount |= 0; + test: (string) => { + if (string === null || + typeof string !== "string") { + return 0; + } + return 1; + }, + cast: (string) => { + if (string === null || + typeof string !== "string") { + throw new WebAssembly.RuntimeError(); + } + return string; + }, + fromCharCodeArray: (array, arrayStart, arrayCount) => { + arrayStart >>>= 0; + arrayCount >>>= 0; let length = arrayLength(array); if (BigInt(arrayStart) + BigInt(arrayCount) > BigInt(length)) { throw new WebAssembly.RuntimeError(); @@ -127,8 +157,8 @@ let polyFillImports = { } return result; }, - toWTF16Array: (string, arr, arrayStart) => { - arrayStart |= 0; + intoCharCodeArray: (string, arr, arrayStart) => { + arrayStart >>>= 0; throwIfNotString(string); let arrLength = arrayLength(arr); let stringLength = string.length; @@ -141,22 +171,22 @@ let polyFillImports = { return stringLength; }, fromCharCode: (charCode) => { - charCode |= 0; + charCode >>>= 0; return String.fromCharCode(charCode); }, fromCodePoint: (codePoint) => { - codePoint |= 0; + codePoint >>>= 0; return String.fromCodePoint(codePoint); }, charCodeAt: (string, stringIndex) => { - stringIndex |= 0; + stringIndex >>>= 0; throwIfNotString(string); if (stringIndex >= string.length) throw new WebAssembly.RuntimeError(); return string.charCodeAt(stringIndex); }, codePointAt: (string, stringIndex) => { - stringIndex |= 0; + stringIndex >>>= 0; throwIfNotString(string); if (stringIndex >= string.length) throw new WebAssembly.RuntimeError(); @@ -166,14 +196,14 @@ let polyFillImports = { throwIfNotString(string); return string.length; }, - concatenate: (stringA, stringB) => { + concat: (stringA, stringB) => { throwIfNotString(stringA); throwIfNotString(stringB); return stringA + stringB; }, substring: (string, startIndex, endIndex) => { - startIndex |= 0; - endIndex |= 0; + startIndex >>>= 0; + endIndex >>>= 0; throwIfNotString(string); if (startIndex > string.length, endIndex > string.length, @@ -217,7 +247,6 @@ function assertSameBehavior(funcA, funcB, ...params) { if (errA || errB) { assertEq(errA === null, errB === null, errA ? errA.message : errB.message); assertEq(Object.getPrototypeOf(errA), Object.getPrototypeOf(errB)); - assertEq(errA.message, errB.message); } assertEq(resultA, resultB); @@ -227,13 +256,30 @@ function assertSameBehavior(funcA, funcB, ...params) { return resultA; } -let builtinExports = new WebAssembly.Instance(new WebAssembly.Module(testModule, {builtins: ["js-string"]}), {}).exports; -let polyfillExports = new WebAssembly.Instance(new WebAssembly.Module(testModule), { 'wasm:js-string': polyFillImports }).exports; +let builtinExports = wasmEvalText(testModule, {}, {builtins: ["js-string"]}).exports; +let polyfillExports = wasmEvalText(testModule, { 'wasm:js-string': polyFillImports }).exports; let testStrings = ["", "a", "1", "ab", "hello, world", "\n", "☺", "☺smiley", String.fromCodePoint(0x10000, 0x10001)]; let testCharCodes = [1, 2, 3, 10, 0x7f, 0xff, 0xfffe, 0xffff]; let testCodePoints = [1, 2, 3, 10, 0x7f, 0xff, 0xfffe, 0xffff, 0x10000, 0x10001]; +for (let a of WasmExternrefValues) { + assertSameBehavior( + builtinExports['test'], + polyfillExports['test'], + a + ); + try { + assertSameBehavior( + builtinExports['cast'], + polyfillExports['cast'], + a + ); + } catch (err) { + assertEq(err instanceof WebAssembly.RuntimeError, true); + } +} + for (let a of testCharCodes) { assertSameBehavior( builtinExports['fromCharCode'], @@ -272,16 +318,16 @@ for (let a of testStrings) { ); } - let array = createArray(length); + let arrayMutI16 = createArrayMutI16(length); assertSameBehavior( - builtinExports['toWTF16Array'], - polyfillExports['toWTF16Array'], - a, array, 0 + builtinExports['intoCharCodeArray'], + polyfillExports['intoCharCodeArray'], + a, arrayMutI16, 0 ); assertSameBehavior( - builtinExports['fromWTF16Array'], - polyfillExports['fromWTF16Array'], - array, 0, length + builtinExports['fromCharCodeArray'], + polyfillExports['fromCharCodeArray'], + arrayMutI16, 0, length ); for (let i = 0; i < length; i++) { @@ -298,8 +344,8 @@ for (let a of testStrings) { for (let a of testStrings) { for (let b of testStrings) { assertSameBehavior( - builtinExports['concatenate'], - polyfillExports['concatenate'], + builtinExports['concat'], + polyfillExports['concat'], a, b ); assertSameBehavior( @@ -314,3 +360,13 @@ for (let a of testStrings) { ); } } + +// fromCharCodeArray length is an unsigned integer +{ + let arrayMutI16 = createArrayMutI16(1); + assertErrorMessage(() => assertSameBehavior( + builtinExports['fromCharCodeArray'], + polyfillExports['fromCharCodeArray'], + arrayMutI16, 1, -1 + ), WebAssembly.RuntimeError, /./); +} diff --git a/js/src/jit-test/tests/wasm/builtin-modules/js-string/directives.txt b/js/src/jit-test/tests/wasm/builtin-modules/js-string/directives.txt index 8c5e6882eb..408d4dd01a 100644 --- a/js/src/jit-test/tests/wasm/builtin-modules/js-string/directives.txt +++ b/js/src/jit-test/tests/wasm/builtin-modules/js-string/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-gc; --wasm-js-string-builtins; test-also=--wasm-compiler=optimizing; include:wasm.js +|jit-test| --setpref=wasm_js_string_builtins=true; test-also=--wasm-compiler=optimizing; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/builtin-modules/oom-test.js b/js/src/jit-test/tests/wasm/builtin-modules/oom-test.js index 32aa1b2515..aaf8d1e5c3 100644 --- a/js/src/jit-test/tests/wasm/builtin-modules/oom-test.js +++ b/js/src/jit-test/tests/wasm/builtin-modules/oom-test.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { const module = wasmBuiltinI8VecMul(); WebAssembly.Module.imports(module); diff --git a/js/src/jit-test/tests/wasm/directiveless/bug1877358.js b/js/src/jit-test/tests/wasm/directiveless/bug1877358.js index 1f8fad0e43..10cb54398a 100644 --- a/js/src/jit-test/tests/wasm/directiveless/bug1877358.js +++ b/js/src/jit-test/tests/wasm/directiveless/bug1877358.js @@ -1,4 +1,4 @@ -// |jit-test| --no-wasm-exceptions; include:wasm.js +// |jit-test| -P wasm_exceptions=false; include:wasm.js let {test} = wasmEvalText(`(module (func $m (import "" "m")) diff --git a/js/src/jit-test/tests/wasm/directives.txt b/js/src/jit-test/tests/wasm/directives.txt index 15c7511171..4a2413125a 100644 --- a/js/src/jit-test/tests/wasm/directives.txt +++ b/js/src/jit-test/tests/wasm/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); test-also=--wasm-test-serialization; test-also=--wasm-compiler=optimizing --no-avx; skip-variant-if: --wasm-compiler=optimizing --no-avx, !getBuildConfiguration("x86") && !getBuildConfiguration("x64") || getBuildConfiguration("simulator"); include:wasm.js +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); test-also=--setpref=wasm_test_serialization=true; test-also=--wasm-compiler=optimizing --no-avx; skip-variant-if: --wasm-compiler=optimizing --no-avx, !getBuildConfiguration("x86") && !getBuildConfiguration("x64") || getBuildConfiguration("simulator"); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/exceptions/bug-1751699.js b/js/src/jit-test/tests/wasm/exceptions/bug-1751699.js index 38268e7905..c60a94a8ed 100644 --- a/js/src/jit-test/tests/wasm/exceptions/bug-1751699.js +++ b/js/src/jit-test/tests/wasm/exceptions/bug-1751699.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { wasmEvalText(` (import "" "" (func $d)) diff --git a/js/src/jit-test/tests/wasm/exceptions/bug-1788213.js b/js/src/jit-test/tests/wasm/exceptions/bug-1788213.js index 4d0b4abcdc..7c0710c117 100644 --- a/js/src/jit-test/tests/wasm/exceptions/bug-1788213.js +++ b/js/src/jit-test/tests/wasm/exceptions/bug-1788213.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { wasmEvalText(`(import "" "" (tag $undef)) (func throw 0) (func (try (do)))`); }); diff --git a/js/src/jit-test/tests/wasm/exceptions/bug-1791361.js b/js/src/jit-test/tests/wasm/exceptions/bug-1791361.js index 9c4432de91..0e09a8a746 100644 --- a/js/src/jit-test/tests/wasm/exceptions/bug-1791361.js +++ b/js/src/jit-test/tests/wasm/exceptions/bug-1791361.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { wasmEvalText(` (tag $d) diff --git a/js/src/jit-test/tests/wasm/exceptions/directives.txt b/js/src/jit-test/tests/wasm/exceptions/directives.txt index 84f10ac2b3..c9c2613039 100644 --- a/js/src/jit-test/tests/wasm/exceptions/directives.txt +++ b/js/src/jit-test/tests/wasm/exceptions/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-exceptions; test-also=--wasm-exnref; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmExceptionsEnabled() +|jit-test| test-also=--setpref=wasm_exnref=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/exceptions/oom-construct-message.js b/js/src/jit-test/tests/wasm/exceptions/oom-construct-message.js index a7820876bc..8eb515ea9b 100644 --- a/js/src/jit-test/tests/wasm/exceptions/oom-construct-message.js +++ b/js/src/jit-test/tests/wasm/exceptions/oom-construct-message.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - const tag = new WebAssembly.Tag({ parameters: ["i32"] }); oomTest(() => { new WebAssembly.Exception(tag, []); diff --git a/js/src/jit-test/tests/wasm/exceptions/oom-create-exception-data.js b/js/src/jit-test/tests/wasm/exceptions/oom-create-exception-data.js index 0aa1e75698..51d4558da8 100644 --- a/js/src/jit-test/tests/wasm/exceptions/oom-create-exception-data.js +++ b/js/src/jit-test/tests/wasm/exceptions/oom-create-exception-data.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - const tag = new WebAssembly.Tag({ parameters: ["i32", "i32", "i32", "i32"] }); const params = [0, 0, 0, 0]; oomTest(() => { diff --git a/js/src/jit-test/tests/wasm/exceptions/unreachable.js b/js/src/jit-test/tests/wasm/exceptions/unreachable.js index f0091bc617..2dc2c8b3b1 100644 --- a/js/src/jit-test/tests/wasm/exceptions/unreachable.js +++ b/js/src/jit-test/tests/wasm/exceptions/unreachable.js @@ -1,4 +1,4 @@ -// |jit-test| test-also=--wasm-function-references --wasm-gc --wasm-compiler=optimizing; test-also=--wasm-function-references --wasm-gc --wasm-compiler=baseline; +// |jit-test| test-also=--setpref=wasm_gc=true --wasm-compiler=optimizing; test-also=--setpref=wasm_gc=true --wasm-compiler=baseline; wasmFailValidateText(`(module (tag) diff --git a/js/src/jit-test/tests/wasm/exnref/bug1883865.js b/js/src/jit-test/tests/wasm/exnref/bug1883865.js new file mode 100644 index 0000000000..d6418d1285 --- /dev/null +++ b/js/src/jit-test/tests/wasm/exnref/bug1883865.js @@ -0,0 +1,25 @@ +// Checks proper padding for nested tryNotes. + +new WebAssembly.Module(wasmTextToBinary(`(module + (func + try_table $l3 + try_table $l4 + try_table $l5 + end + end + end + ) +)`)); + +new WebAssembly.Module(wasmTextToBinary(`(module + (func + try_table $l3 + try_table $l4 + try_table $l5 + end + try_table $l5a + end + end + end + ) +)`)); diff --git a/js/src/jit-test/tests/wasm/exnref/directives.txt b/js/src/jit-test/tests/wasm/exnref/directives.txt index bc17009ea8..b993dbd1d5 100644 --- a/js/src/jit-test/tests/wasm/exnref/directives.txt +++ b/js/src/jit-test/tests/wasm/exnref/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-exnref; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmExnRefEnabled() +|jit-test| --setpref=wasm_exnref=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmExnRefEnabled() diff --git a/js/src/jit-test/tests/wasm/extended-const/basic.js b/js/src/jit-test/tests/wasm/extended-const/basic.js index bf0ce460d5..6b71385cb6 100644 --- a/js/src/jit-test/tests/wasm/extended-const/basic.js +++ b/js/src/jit-test/tests/wasm/extended-const/basic.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !wasmExtendedConstEnabled() - function testPrivateGlobal(valtype, expr, result) { // Immutable private globals have a single cell for wasm. let { get } = wasmEvalText(`(module diff --git a/js/src/jit-test/tests/wasm/extended-const/directives.txt b/js/src/jit-test/tests/wasm/extended-const/directives.txt index 0d16de6524..c4b5e420f1 100644 --- a/js/src/jit-test/tests/wasm/extended-const/directives.txt +++ b/js/src/jit-test/tests/wasm/extended-const/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-extended-const; test-also=--wasm-compiler=optimizing; test-also=--wasm-test-serialization; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--setpref=wasm_test_serialization=true; test-also=--wasm-compiler=baseline; test-also=--test-wasm-await-tier2; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/extended-const/disabled.js b/js/src/jit-test/tests/wasm/extended-const/disabled.js deleted file mode 100644 index 01e64f6c44..0000000000 --- a/js/src/jit-test/tests/wasm/extended-const/disabled.js +++ /dev/null @@ -1,22 +0,0 @@ -// |jit-test| skip-if: wasmExtendedConstEnabled() - -const { CompileError, validate } = WebAssembly; - -const DISABLED = /extended constant expressions not enabled|unrecognized opcode/; - -let tests = [ - "(module (global i32 i32.const 0 i32.const 0 i32.add))", - "(module (global i32 i32.const 0 i32.const 0 i32.sub))", - "(module (global i32 i32.const 0 i32.const 0 i32.mul))", - "(module (global i64 i64.const 0 i64.const 0 i64.add))", - "(module (global i64 i64.const 0 i64.const 0 i64.sub))", - "(module (global i64 i64.const 0 i64.const 0 i64.mul))", -]; - -// Test that use of extended constants fails when disabled. - -for (let src of tests) { - let bin = wasmTextToBinary(src); - assertEq(validate(bin), false); - wasmCompilationShouldFail(bin, DISABLED); -} diff --git a/js/src/jit-test/tests/wasm/extended-const/pathological.js b/js/src/jit-test/tests/wasm/extended-const/pathological.js index e3695f3625..8a87b25be4 100644 --- a/js/src/jit-test/tests/wasm/extended-const/pathological.js +++ b/js/src/jit-test/tests/wasm/extended-const/pathological.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !wasmExtendedConstEnabled() - // Let's calculate zero in some elaborate ways. function testFancyZeroOffset(fancyZero, memType = 'i32') { try { diff --git a/js/src/jit-test/tests/wasm/features.js b/js/src/jit-test/tests/wasm/features.js index 904dd03e76..3292334ee6 100644 --- a/js/src/jit-test/tests/wasm/features.js +++ b/js/src/jit-test/tests/wasm/features.js @@ -1,5 +1,3 @@ -// |jit-test| test-also=--wasm-extended-const; test-also=--wasm-exceptions; - // Test that if a feature is 'experimental' then we must be in a nightly build, // and if a feature is 'released' then it must be enabled on release and beta. // @@ -67,27 +65,17 @@ for (let [name, enabled, test] of releasedFeaturesMaybeDisabledAnyway) { let releasedFeatures = [ ['threads', wasmThreadsEnabled(), `(module (memory 1 1 shared))`], - [ - 'exceptions', - wasmExceptionsEnabled(), - `(module (type (func)) (tag (type 0)))` - ], - [ - 'extended-const', - wasmExtendedConstEnabled(), - `(module - (global i32 - i32.const 0 - i32.const 0 - i32.add - ) - )` - ], [ 'tail-calls', wasmTailCallsEnabled(), `(module (func) (func (return_call 0)))` ], + ['gc', wasmGcEnabled(), `(module (type (struct)))`], + [ + 'multi-memory', + wasmMultiMemoryEnabled(), + `(module (memory 0) (memory 0))`, + ], ]; for (let [name, enabled, test] of releasedFeatures) { diff --git a/js/src/jit-test/tests/wasm/function-references/as-non-null.js b/js/src/jit-test/tests/wasm/function-references/as-non-null.js index 1280c8ee06..6fd02d61ac 100644 --- a/js/src/jit-test/tests/wasm/function-references/as-non-null.js +++ b/js/src/jit-test/tests/wasm/function-references/as-non-null.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() let {checkNonNull} = wasmEvalText(`(module (func (export "checkNonNull") (param externref) (result (ref extern)) diff --git a/js/src/jit-test/tests/wasm/function-references/binary.js b/js/src/jit-test/tests/wasm/function-references/binary.js index 91cf807dc4..0e64f0723e 100644 --- a/js/src/jit-test/tests/wasm/function-references/binary.js +++ b/js/src/jit-test/tests/wasm/function-references/binary.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() load(libdir + "wasm-binary.js"); diff --git a/js/src/jit-test/tests/wasm/function-references/br-non-null.js b/js/src/jit-test/tests/wasm/function-references/br-non-null.js index 371cdaa40a..6d359105fb 100644 --- a/js/src/jit-test/tests/wasm/function-references/br-non-null.js +++ b/js/src/jit-test/tests/wasm/function-references/br-non-null.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // br_on_non_null from constant wasmValidateText(`(module diff --git a/js/src/jit-test/tests/wasm/function-references/br-null.js b/js/src/jit-test/tests/wasm/function-references/br-null.js index 26d1013de2..08728a3644 100644 --- a/js/src/jit-test/tests/wasm/function-references/br-null.js +++ b/js/src/jit-test/tests/wasm/function-references/br-null.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // br_on_null from constant wasmValidateText(`(module diff --git a/js/src/jit-test/tests/wasm/function-references/call_ref.js b/js/src/jit-test/tests/wasm/function-references/call_ref.js index 514c3145d6..50bdfb6441 100644 --- a/js/src/jit-test/tests/wasm/function-references/call_ref.js +++ b/js/src/jit-test/tests/wasm/function-references/call_ref.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() let { plusOne } = wasmEvalText(`(module (; forward declaration so that ref.func works ;) diff --git a/js/src/jit-test/tests/wasm/function-references/directives.txt b/js/src/jit-test/tests/wasm/function-references/directives.txt index f7d2135421..293724e57a 100644 --- a/js/src/jit-test/tests/wasm/function-references/directives.txt +++ b/js/src/jit-test/tests/wasm/function-references/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing --wasm-function-references; test-also=--wasm-compiler=baseline --wasm-function-references; include:wasm.js +|jit-test| test-also=--setpref=wasm_gc=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/function-references/disabled.js b/js/src/jit-test/tests/wasm/function-references/disabled.js index 70a66a937d..6e67d2ce7f 100644 --- a/js/src/jit-test/tests/wasm/function-references/disabled.js +++ b/js/src/jit-test/tests/wasm/function-references/disabled.js @@ -1,8 +1,8 @@ -// |jit-test| skip-if: wasmFunctionReferencesEnabled() +// |jit-test| skip-if: wasmGcEnabled() const { CompileError, validate } = WebAssembly; -const UNRECOGNIZED_OPCODE_OR_BAD_TYPE = /unrecognized opcode|bad type|\(ref T\) types not enabled/; +const UNRECOGNIZED_OPCODE_OR_BAD_TYPE = /unrecognized opcode|bad type|gc not enabled/; let simpleTests = [ `(module (func (param (ref 0)) (unreachable)))`, diff --git a/js/src/jit-test/tests/wasm/function-references/nnl-test.js b/js/src/jit-test/tests/wasm/function-references/nnl-test.js index 9436b970d5..df79a748a9 100644 --- a/js/src/jit-test/tests/wasm/function-references/nnl-test.js +++ b/js/src/jit-test/tests/wasm/function-references/nnl-test.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // Generates combinations of different block types and operations for // non-defaultable locals (local.set / .tee / .get). 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. diff --git a/js/src/jit-test/tests/wasm/function-references/non-nullable.js b/js/src/jit-test/tests/wasm/function-references/non-nullable.js index afe1d3cb43..653bbe7ab6 100644 --- a/js/src/jit-test/tests/wasm/function-references/non-nullable.js +++ b/js/src/jit-test/tests/wasm/function-references/non-nullable.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // non-null values are subtype of null values wasmValidateText(`(module diff --git a/js/src/jit-test/tests/wasm/function-references/reftype-parse.js b/js/src/jit-test/tests/wasm/function-references/reftype-parse.js index 643f753ec8..f4cca7cb74 100644 --- a/js/src/jit-test/tests/wasm/function-references/reftype-parse.js +++ b/js/src/jit-test/tests/wasm/function-references/reftype-parse.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmFunctionReferencesEnabled() +// |jit-test| skip-if: !wasmGcEnabled() // RefType/ValueType as a simple string const t01 = new WebAssembly.Table({element: 'funcref', initial: 3}); @@ -16,36 +16,6 @@ assertErrorMessage( assertErrorMessage( () => new WebAssembly.Table({element: true, initial: 1}), TypeError, /bad value type/); - -// RefType/ValueType can be specified as an {ref: 'func', ...} object -const t11 = new WebAssembly.Table({element: {ref: 'func', nullable: true}, initial: 3}); -const t12 = new WebAssembly.Table({element: {ref: 'extern', nullable: true}, initial: 3}); -const t13 = new WebAssembly.Table({element: {ref: 'extern', nullable: false}, initial: 3}, {}); - -assertErrorMessage( - () => new WebAssembly.Table({element: {ref: 'func', nullable: false}, initial: 1}, null), - TypeError, /cannot pass null to non-nullable WebAssembly reference/); -assertErrorMessage( - () => new WebAssembly.Table({element: {ref: 'extern', nullable: false}, initial: 1}, null), - TypeError, /cannot pass null to non-nullable WebAssembly reference/); - -assertErrorMessage( - () => new WebAssembly.Table({element: {ref: 'bar', nullable: true}, initial: 1}), - TypeError, /bad value type/); - -const g11 = new WebAssembly.Global({value: {ref: 'func', nullable: true}, mutable: true}); -const g12 = new WebAssembly.Global({value: {ref: 'extern', nullable: true}, mutable: true}); -const g13 = new WebAssembly.Global({value: {ref: 'extern', nullable: false}, mutable: true}, {}); -const g14 = new WebAssembly.Global({value: {ref: 'extern', nullable: false}, mutable: true}); -const g15 = new WebAssembly.Global({value: {ref: 'extern', nullable: false}, mutable: true}, void 0); - -assertErrorMessage( - () => new WebAssembly.Global({value: {ref: 'func', nullable: false}, mutable: true}), - TypeError, /cannot pass null to non-nullable WebAssembly reference/); -assertErrorMessage( - () => new WebAssembly.Global({value: {ref: 'extern', nullable: false}, mutable: true}, null), - TypeError, /cannot pass null to non-nullable WebAssembly reference/); - assertErrorMessage( () => new WebAssembly.Global({value: {ref: 'bar', nullable: true}, mutable: true}), TypeError, /bad value type/); diff --git a/js/src/jit-test/tests/wasm/gc/arrays.js b/js/src/jit-test/tests/wasm/gc/arrays.js index b3f03151bb..cb61bb1b07 100644 --- a/js/src/jit-test/tests/wasm/gc/arrays.js +++ b/js/src/jit-test/tests/wasm/gc/arrays.js @@ -604,6 +604,51 @@ assertErrorMessage(() => wasmEvalText(`(module },WebAssembly.RuntimeError, /index out of bounds/); } +// run: zero-length copies are allowed +{ + let { newData } = wasmEvalText(`(module + (type $a (array i8)) + (data $d "1337") + (func (export "newData") (result eqref) + (; offset=0 into data ;) i32.const 0 + (; size=0 into data ;) i32.const 0 + array.new_data $a $d + ) + )`).exports; + let arr = newData(); + assertEq(wasmGcArrayLength(arr), 0); +} + +// run: a zero-length copy from the end is allowed +{ + let { newData } = wasmEvalText(`(module + (type $a (array i8)) + (data $d "1337") + (func (export "newData") (result eqref) + (; offset=4 into data ;) i32.const 4 + (; size=0 into data ;) i32.const 0 + array.new_data $a $d + ) + )`).exports; + let arr = newData(); + assertEq(wasmGcArrayLength(arr), 0); +} + +// run: even empty data segments are allowed +{ + let { newData } = wasmEvalText(`(module + (type $a (array i8)) + (data $d "") + (func (export "newData") (result eqref) + (; offset=0 into data ;) i32.const 0 + (; size=0 into data ;) i32.const 0 + array.new_data $a $d + ) + )`).exports; + let arr = newData(); + assertEq(wasmGcArrayLength(arr), 0); +} + // run: resulting array is as expected { let { newData } = wasmEvalText(`(module @@ -802,6 +847,59 @@ assertErrorMessage(() => wasmEvalText(`(module },WebAssembly.RuntimeError, /index out of bounds/); } +// run: zero-length copies are allowed +{ + let { newElem, f1, f2, f3, f4 } = wasmEvalText(`(module + (type $a (array funcref)) + (elem $e func $f1 $f2 $f3 $f4) + (func $f1 (export "f1")) + (func $f2 (export "f2")) + (func $f3 (export "f3")) + (func $f4 (export "f4")) + (func (export "newElem") (result eqref) + (; offset=0 into elem ;) i32.const 0 + (; size=0 into elem ;) i32.const 0 + array.new_elem $a $e + ) + )`).exports; + let arr = newElem(); + assertEq(wasmGcArrayLength(arr), 0); +} + +// run: a zero-length copy from the end is allowed +{ + let { newElem, f1, f2, f3, f4 } = wasmEvalText(`(module + (type $a (array funcref)) + (elem $e func $f1 $f2 $f3 $f4) + (func $f1 (export "f1")) + (func $f2 (export "f2")) + (func $f3 (export "f3")) + (func $f4 (export "f4")) + (func (export "newElem") (result eqref) + (; offset=4 into elem ;) i32.const 4 + (; size=0 into elem ;) i32.const 0 + array.new_elem $a $e + ) + )`).exports; + let arr = newElem(); + assertEq(wasmGcArrayLength(arr), 0); +} + +// run: even empty elem segments are allowed +{ + let { newElem, f1, f2, f3, f4 } = wasmEvalText(`(module + (type $a (array funcref)) + (elem $e func) + (func (export "newElem") (result eqref) + (; offset=0 into elem ;) i32.const 0 + (; size=0 into elem ;) i32.const 0 + array.new_elem $a $e + ) + )`).exports; + let arr = newElem(); + assertEq(wasmGcArrayLength(arr), 0); +} + // run: resulting array is as expected { let { newElem, f1, f2, f3, f4 } = wasmEvalText(`(module @@ -1130,6 +1228,29 @@ assertErrorMessage(() => wasmEvalText(`(module },WebAssembly.RuntimeError, /index out of bounds/); } +// run: zeroes everywhere +{ + let { initData } = wasmEvalText(`(module + (type $a (array (mut i8))) + (data $d "") + (func (export "initData") (result eqref) + (local $arr (ref $a)) + (local.set $arr (array.new_default $a (i32.const 0))) + + (; array to init ;) local.get $arr + (; offset=0 into array ;) i32.const 0 + (; offset=0 into data ;) i32.const 0 + (; size=0 elements ;) i32.const 0 + array.init_data $a $d + + local.get $arr + ) + (func data.drop 0) ;; force write of data count section, see https://github.com/bytecodealliance/wasm-tools/pull/1194 + )`).exports; + let arr = initData(); + assertEq(wasmGcArrayLength(arr), 0); +} + // run: resulting array is as expected { let { initData } = wasmEvalText(`(module @@ -1488,6 +1609,28 @@ assertErrorMessage(() => wasmEvalText(`(module },WebAssembly.RuntimeError, /index out of bounds/); } +// run: zeroes everywhere +{ + let { initElem, f1, f2, f3, f4 } = wasmEvalText(`(module + (type $a (array (mut funcref))) + (elem $e func) + (func (export "initElem") (result eqref) + (local $arr (ref $a)) + (local.set $arr (array.new_default $a (i32.const 0))) + + (; array to init ;) local.get $arr + (; offset=0 into array ;) i32.const 0 + (; offset=0 into elem ;) i32.const 0 + (; size=0 into elem ;) i32.const 0 + array.init_elem $a $e + + local.get $arr + ) + )`).exports; + let arr = initElem(); + assertEq(wasmGcArrayLength(arr), 0); +} + // run: resulting array is as expected { let { initElem, f1, f2, f3, f4 } = wasmEvalText(`(module diff --git a/js/src/jit-test/tests/wasm/gc/binary.js b/js/src/jit-test/tests/wasm/gc/binary.js index 1ef4a586a8..e16af2bfbf 100644 --- a/js/src/jit-test/tests/wasm/gc/binary.js +++ b/js/src/jit-test/tests/wasm/gc/binary.js @@ -2,14 +2,16 @@ load(libdir + "wasm-binary.js"); -const v2vSig = {args:[], ret:VoidCode}; -const v2vSigSection = sigSection([v2vSig]); - function checkInvalid(body, errorMessage) { assertErrorMessage(() => new WebAssembly.Module( - moduleWithSections([v2vSigSection, declSection([0]), bodySection([body])])), - WebAssembly.CompileError, - errorMessage); + moduleWithSections([ + typeSection([ + { kind: FuncCode, args: [], ret: [] }, + ]), + declSection([0]), + bodySection([body]), + ]) + ), WebAssembly.CompileError, errorMessage); } const invalidRefBlockType = funcBody({locals:[], body:[ @@ -23,7 +25,7 @@ checkInvalid(invalidRefBlockType, /heap type/); const invalidTooBigRefType = funcBody({locals:[], body:[ BlockCode, OptRefCode, - varU32(1000000), + ...varU32(1000000), EndCode, ]}); checkInvalid(invalidTooBigRefType, /heap type/); diff --git a/js/src/jit-test/tests/wasm/gc/bug-1843295.js b/js/src/jit-test/tests/wasm/gc/bug-1843295.js index 19a32263f6..765a9000a1 100644 --- a/js/src/jit-test/tests/wasm/gc/bug-1843295.js +++ b/js/src/jit-test/tests/wasm/gc/bug-1843295.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmGcEnabled(); --wasm-test-serialization +// |jit-test| skip-if: !wasmGcEnabled(); --setpref=wasm_test_serialization=true wasmEvalText(`(module (type (sub (array (mut i32)))) diff --git a/js/src/jit-test/tests/wasm/gc/bug-1845436.js b/js/src/jit-test/tests/wasm/gc/bug-1845436.js index a79c22d9a1..6ea8070f4d 100644 --- a/js/src/jit-test/tests/wasm/gc/bug-1845436.js +++ b/js/src/jit-test/tests/wasm/gc/bug-1845436.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmGcEnabled(); --wasm-test-serialization +// |jit-test| skip-if: !wasmGcEnabled(); --setpref=wasm_test_serialization=true // Test that serialization doesn't create a forward reference to the third // struct when serializing the reference to the first struct, which is diff --git a/js/src/jit-test/tests/wasm/gc/bug-1854007.js b/js/src/jit-test/tests/wasm/gc/bug-1854007.js index c9d6b25369..d3e5afa9cd 100644 --- a/js/src/jit-test/tests/wasm/gc/bug-1854007.js +++ b/js/src/jit-test/tests/wasm/gc/bug-1854007.js @@ -1,4 +1,4 @@ -// |jit-test| test-also=--wasm-test-serialization; skip-if: !wasmGcEnabled() +// |jit-test| test-also=--setpref=wasm_test_serialization=true; skip-if: !wasmGcEnabled() let {run} = wasmEvalText(`(module (rec (type $$t1 (func (result (ref null $$t1))))) diff --git a/js/src/jit-test/tests/wasm/gc/bug-1879096.js b/js/src/jit-test/tests/wasm/gc/bug-1879096.js new file mode 100644 index 0000000000..e71d2bac27 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/bug-1879096.js @@ -0,0 +1,65 @@ +// |jit-test| test-also=--setpref=wasm_test_serialization; skip-if: !wasmGcEnabled() + +// Conditional branch instructions need to rewrite their stack types according +// to the destination label types. This loses information but is mandated by +// the spec. + +// br_if +wasmFailValidateText(`(module + (func (result anyref) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + i32.const 0 ;; stack: [arrayref structref i32] + br_if 0 ;; stack: [arrayref anyref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_null +wasmFailValidateText(`(module + (func (param externref) (result anyref) + ref.null array ;; stack: [arrayref] + local.get 0 ;; stack: [arrayref externref] + br_on_null 0 ;; stack: [anyref (ref extern)] + drop ;; stack: [anyref] + array.len ;; should fail + unreachable + ) +)`, /type mismatch: expression has type anyref but expected arrayref/); + +// br_on_non_null +wasmFailValidateText(`(module + (func (param externref) (result anyref (ref extern)) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + local.get 0 ;; stack: [arrayref structref externref] + br_on_non_null 0 ;; stack: [arrayref anyref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_cast +wasmFailValidateText(`(module + (type $s (struct)) + (func (result anyref (ref $s)) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + br_on_cast 0 structref (ref $s) ;; stack: [anyref structref] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); + +// br_on_cast_fail +wasmFailValidateText(`(module + (type $s (struct)) + (func (result anyref anyref) + ref.null array ;; stack: [arrayref] + ref.null struct ;; stack: [arrayref structref] + br_on_cast_fail 0 structref (ref $s) ;; stack: [anyref (ref $s)] + ref.eq ;; should fail (anyref is not eq) + unreachable + ) +)`, /type mismatch: expression has type anyref but expected eqref/); diff --git a/js/src/jit-test/tests/wasm/gc/call-indirect-subtyping.js b/js/src/jit-test/tests/wasm/gc/call-indirect-subtyping.js index 4301621a8c..d83f2ed624 100644 --- a/js/src/jit-test/tests/wasm/gc/call-indirect-subtyping.js +++ b/js/src/jit-test/tests/wasm/gc/call-indirect-subtyping.js @@ -1,4 +1,4 @@ -// |jit-test| test-also=--wasm-tail-calls; skip-if: !wasmGcEnabled() +// |jit-test| test-also=--setpref=wasm_tail_calls=true; skip-if: !wasmGcEnabled() // Test that call_indirect will respect subtyping by defining a bunch of types // and checking every combination of (expected, actual) type. diff --git a/js/src/jit-test/tests/wasm/gc/directives.txt b/js/src/jit-test/tests/wasm/gc/directives.txt index e6d978cc44..293724e57a 100644 --- a/js/src/jit-test/tests/wasm/gc/directives.txt +++ b/js/src/jit-test/tests/wasm/gc/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-gc; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js +|jit-test| test-also=--setpref=wasm_gc=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/gc/disabled.js b/js/src/jit-test/tests/wasm/gc/disabled.js index 791c6ff25e..206d32b1c4 100644 --- a/js/src/jit-test/tests/wasm/gc/disabled.js +++ b/js/src/jit-test/tests/wasm/gc/disabled.js @@ -2,7 +2,7 @@ const { CompileError, validate } = WebAssembly; -const UNRECOGNIZED_OPCODE_OR_BAD_TYPE = /unrecognized opcode|(Structure|reference|gc) types not enabled|invalid heap type|invalid inline block type|bad type|\(ref T\) types not enabled|Invalid type|invalid function type/; +const UNRECOGNIZED_OPCODE_OR_BAD_TYPE = /unrecognized opcode|gc not enabled|invalid heap type|invalid inline block type|bad type|Invalid type|invalid function type/; let simpleTests = [ "(module (func (drop (ref.null eq))))", diff --git a/js/src/jit-test/tests/wasm/gc/ion-and-baseline.js b/js/src/jit-test/tests/wasm/gc/ion-and-baseline.js index 5a4951c585..2c67bbce8b 100644 --- a/js/src/jit-test/tests/wasm/gc/ion-and-baseline.js +++ b/js/src/jit-test/tests/wasm/gc/ion-and-baseline.js @@ -10,7 +10,7 @@ // actually testing something here. // // Some logging with printf confirms that refmod is baseline-compiled and -// nonrefmod is ion-compiled at present, with --wasm-gc enabled. +// nonrefmod is ion-compiled at present, with --setpref=wasm_gc=true enabled. var refmod = new WebAssembly.Module(wasmTextToBinary( `(module diff --git a/js/src/jit-test/tests/wasm/gc/limits.js b/js/src/jit-test/tests/wasm/gc/limits.js deleted file mode 100644 index e6f21b5d6b..0000000000 --- a/js/src/jit-test/tests/wasm/gc/limits.js +++ /dev/null @@ -1,69 +0,0 @@ -// |jit-test| skip-if: !wasmGcEnabled() || getBuildConfiguration("tsan") - -// This test has a timeout on TSAN configurations due to the large -// allocations. - -// Limit of 1 million recursion groups -wasmValidateText(`(module - ${`(rec (type (func)))`.repeat(1_000_000)} - )`); -wasmFailValidateText(`(module - ${`(rec (type (func)))`.repeat(1_000_001)} - )`, /too many/); - -// Limit of 1 million types (across all recursion groups) -wasmValidateText(`(module - (rec ${`(type (func))`.repeat(1_000_000)}) - )`); -wasmValidateText(`(module - (rec ${`(type (func))`.repeat(500_000)}) - (rec ${`(type (func))`.repeat(500_000)}) - )`); -wasmFailValidateText(`(module - (rec ${`(type (func))`.repeat(1_000_001)}) - )`, /too many/); -wasmFailValidateText(`(module - (rec ${`(type (func))`.repeat(500_000)}) - (rec ${`(type (func))`.repeat(500_001)}) - )`, /too many/); - -// Limit of subtyping hierarchy 63 deep -function testSubtypingModule(depth) { - let types = '(type (sub (func)))'; - for (let i = 1; i <= depth; i++) { - types += `(type (sub ${i - 1} (func)))`; - } - return `(module - ${types} - )`; -} -wasmValidateText(testSubtypingModule(63)); -wasmFailValidateText(testSubtypingModule(64), /too deep/); - -// Limit of 10_000 struct fields -wasmFailValidateText(`(module - (type (struct ${'(field i64)'.repeat(10_001)})) -)`, /too many/); - -{ - let {makeLargeStructDefault, makeLargeStruct} = wasmEvalText(`(module - (type $s (struct ${'(field i64)'.repeat(10_000)})) - (func (export "makeLargeStructDefault") (result anyref) - struct.new_default $s - ) - (func (export "makeLargeStruct") (result anyref) - ${'i64.const 0 '.repeat(10_000)} - struct.new $s - ) - )`).exports; - let largeStructDefault = makeLargeStructDefault(); - let largeStruct = makeLargeStruct(); -} - -// array.new_fixed has limit of 10_000 operands -wasmFailValidateText(`(module - (type $a (array i32)) - (func - array.new_fixed $a 10001 - ) -)`, /too many/); diff --git a/js/src/jit-test/tests/wasm/gc/limits/array-new-fixed.js b/js/src/jit-test/tests/wasm/gc/limits/array-new-fixed.js new file mode 100644 index 0000000000..4b0600c724 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/array-new-fixed.js @@ -0,0 +1,9 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +// array.new_fixed has limit of 10_000 operands +wasmFailValidateText(`(module + (type $a (array i32)) + (func + array.new_fixed $a 10001 + ) +)`, /too many/); diff --git a/js/src/jit-test/tests/wasm/gc/limits/load-mod.js b/js/src/jit-test/tests/wasm/gc/limits/load-mod.js new file mode 100644 index 0000000000..cd972ceb65 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/load-mod.js @@ -0,0 +1,5 @@ +// Files for some of these tests are pre-generated and located in js/src/jit-test/lib/gen. +// There you will also find the script to update these files. +function loadMod(name) { + return decompressLZ4(os.file.readFile(libdir + "gen/" + name, "binary").buffer) +} diff --git a/js/src/jit-test/tests/wasm/gc/limits/rec-groups-1.js b/js/src/jit-test/tests/wasm/gc/limits/rec-groups-1.js new file mode 100644 index 0000000000..489bf89cd4 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/rec-groups-1.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million recursion groups +wasmValidateBinary(loadMod("wasm-gc-limits-r1M-t1.wasm")); diff --git a/js/src/jit-test/tests/wasm/gc/limits/rec-groups-2.js b/js/src/jit-test/tests/wasm/gc/limits/rec-groups-2.js new file mode 100644 index 0000000000..40c020c4b5 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/rec-groups-2.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million recursion groups +wasmFailValidateBinary(loadMod("wasm-gc-limits-r1M1-t1.wasm"), /too many/); diff --git a/js/src/jit-test/tests/wasm/gc/limits/struct-fields.js b/js/src/jit-test/tests/wasm/gc/limits/struct-fields.js new file mode 100644 index 0000000000..ae60f38d57 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/struct-fields.js @@ -0,0 +1,11 @@ +// |jit-test| --setpref=wasm_gc; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 10_000 struct fields +wasmFailValidateBinary(loadMod("wasm-gc-limits-s10K1.wasm"), /too many/); +{ + let {makeLargeStructDefault, makeLargeStruct} = wasmEvalBinary(loadMod("wasm-gc-limits-s10K.wasm")).exports; + let largeStructDefault = makeLargeStructDefault(); + let largeStruct = makeLargeStruct(); +} diff --git a/js/src/jit-test/tests/wasm/gc/limits/subtyping-depth.js b/js/src/jit-test/tests/wasm/gc/limits/subtyping-depth.js new file mode 100644 index 0000000000..2d70215ee9 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/subtyping-depth.js @@ -0,0 +1,13 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; include: wasm-binary.js; + +// Limit of subtyping hierarchy 63 deep +function moduleSubtypingDepth(depth) { + let types = []; + types.push({final: false, kind: FuncCode, args: [], ret: []}); + for (let i = 1; i <= depth; i++) { + types.push({final: false, sub: i - 1, kind: FuncCode, args: [], ret: []}); + } + return moduleWithSections([typeSection(types)]); +} +wasmValidateBinary(moduleSubtypingDepth(63)); +wasmFailValidateBinary(moduleSubtypingDepth(64), /too deep/); diff --git a/js/src/jit-test/tests/wasm/gc/limits/types-1.js b/js/src/jit-test/tests/wasm/gc/limits/types-1.js new file mode 100644 index 0000000000..c097907e79 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/types-1.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million types (across all recursion groups) +wasmValidateBinary(loadMod("wasm-gc-limits-r1-t1M.wasm")); diff --git a/js/src/jit-test/tests/wasm/gc/limits/types-2.js b/js/src/jit-test/tests/wasm/gc/limits/types-2.js new file mode 100644 index 0000000000..5e81bdf6ab --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/types-2.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million types (across all recursion groups) +wasmValidateBinary(loadMod("wasm-gc-limits-r2-t500K.wasm")); diff --git a/js/src/jit-test/tests/wasm/gc/limits/types-3.js b/js/src/jit-test/tests/wasm/gc/limits/types-3.js new file mode 100644 index 0000000000..e9effa4bfa --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/types-3.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million types (across all recursion groups) +wasmFailValidateBinary(loadMod("wasm-gc-limits-r1-t1M1.wasm"), /too many/); diff --git a/js/src/jit-test/tests/wasm/gc/limits/types-4.js b/js/src/jit-test/tests/wasm/gc/limits/types-4.js new file mode 100644 index 0000000000..dd413ed4e9 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/limits/types-4.js @@ -0,0 +1,6 @@ +// |jit-test| --setpref=wasm_gc; include:wasm.js; + +loadRelativeToScript("load-mod.js"); + +// Limit of 1 million types (across all recursion groups) +wasmFailValidateBinary(loadMod("wasm-gc-limits-r2-t500K1.wasm"), /too many/); diff --git a/js/src/jit-test/tests/wasm/gc/ref.js b/js/src/jit-test/tests/wasm/gc/ref.js index a55b0c8f02..2bf76daf52 100644 --- a/js/src/jit-test/tests/wasm/gc/ref.js +++ b/js/src/jit-test/tests/wasm/gc/ref.js @@ -173,7 +173,7 @@ assertErrorMessage(() => wasmEvalText(` `), WebAssembly.CompileError, /expression has type \(ref null.*\) but expected \(ref null.*\)/); -if (!wasmFunctionReferencesEnabled()) { +if (!wasmGcEnabled()) { // Ref type can't reference a function type assertErrorMessage(() => wasmEvalText(` diff --git a/js/src/jit-test/tests/wasm/gc/regress-1754701.js b/js/src/jit-test/tests/wasm/gc/regress-1754701.js index 656aa5d625..1a2307fa87 100644 --- a/js/src/jit-test/tests/wasm/gc/regress-1754701.js +++ b/js/src/jit-test/tests/wasm/gc/regress-1754701.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmGcEnabled() || !('oomTest' in this) +// |jit-test| skip-if: !wasmGcEnabled() let { testArray, testStructInline, testStructOutline } = wasmEvalText(` (module diff --git a/js/src/jit-test/tests/wasm/gc/regress-1884767.js b/js/src/jit-test/tests/wasm/gc/regress-1884767.js new file mode 100644 index 0000000000..54a168d657 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/regress-1884767.js @@ -0,0 +1,13 @@ +// |jit-test| skip-if: !wasmGcEnabled() + +const { test } = wasmEvalText(`(module + (type $a (array i32)) + (func (export "test") (result anyref) + try (result anyref) + (array.new_default $a (i32.const 999999999)) + catch_all + unreachable + end + ) +)`).exports; +assertErrorMessage(() => test(), WebAssembly.RuntimeError, /too many array elements/); diff --git a/js/src/jit-test/tests/wasm/gc/structs.js b/js/src/jit-test/tests/wasm/gc/structs.js index 0ff0cbd4b4..15dab873e9 100644 --- a/js/src/jit-test/tests/wasm/gc/structs.js +++ b/js/src/jit-test/tests/wasm/gc/structs.js @@ -665,46 +665,6 @@ assertErrorMessage(() => new WebAssembly.Module(bad), let exports = wasmEvalText(txt).exports; } -////////////////////////////////////////////////////////////////////////////// -// -// Checks for requests to create structs with more than MaxStructFields, where -// MaxStructFields == 1000. - -function structNewOfManyFields(numFields) { - let defString = "(type $s (struct "; - for (i = 0; i < numFields; i++) { - defString += "(field i32) "; - } - defString += "))"; - - let insnString = "(struct.new $s "; - for (i = 0; i < numFields; i++) { - insnString += "(i32.const 1337) "; - } - insnString += ")"; - - return "(module " + - defString + - " (func (export \"create\") (result eqref) " + - insnString + - "))"; -} - -{ - // 10_000 fields is allowable - let exports = wasmEvalText(structNewOfManyFields(10000)).exports; - let s = exports.create(); - assertEq(s, s); -} -{ - // but 10_001 is not - assertErrorMessage(() => wasmEvalText(structNewOfManyFields(10001)), - WebAssembly.CompileError, - /too many fields in struct/); -} - -// FIXME: also check struct.new_default, once it is available in both compilers. - // Exercise stack maps and GC { // Zeal will cause us to allocate structs via instance call, requiring live registers diff --git a/js/src/jit-test/tests/wasm/globals.js b/js/src/jit-test/tests/wasm/globals.js index 5a6d83e348..bbba095bb9 100644 --- a/js/src/jit-test/tests/wasm/globals.js +++ b/js/src/jit-test/tests/wasm/globals.js @@ -1,5 +1,3 @@ -// |jit-test| test-also=--wasm-extended-const; test-also=--no-wasm-extended-const - const { Instance, Module, LinkError } = WebAssembly; // Locally-defined globals @@ -44,68 +42,65 @@ testInner('i32', 13, 37, x => x|0); testInner('f32', 13.37, 0.1989, Math.fround); testInner('f64', 13.37, 0.1989, x => +x); -// Extended const stuff -if (wasmExtendedConstEnabled()) { - // Basic global shenanigans - { - const module = wasmEvalText(`(module - ;; -2 * (5 - (-10 + 20)) = 10 - (global i32 (i32.mul (i32.const -2) (i32.sub (i32.const 5) (i32.add (i32.const -10) (i32.const 20))))) - ;; ((1 + 2) - (3 * 4)) = -9 - (global i64 (i64.sub (i64.add (i64.const 1) (i64.const 2)) (i64.mul (i64.const 3) (i64.const 4)))) - - (func (export "get0") (result i32) global.get 0) - (func (export "get1") (result i64) global.get 1) - )`).exports; - - assertEq(module.get0(), 10); - assertEq(module.get1(), -9n); - } +// Basic global shenanigans +{ + const module = wasmEvalText(`(module + ;; -2 * (5 - (-10 + 20)) = 10 + (global i32 (i32.mul (i32.const -2) (i32.sub (i32.const 5) (i32.add (i32.const -10) (i32.const 20))))) + ;; ((1 + 2) - (3 * 4)) = -9 + (global i64 (i64.sub (i64.add (i64.const 1) (i64.const 2)) (i64.mul (i64.const 3) (i64.const 4)))) + + (func (export "get0") (result i32) global.get 0) + (func (export "get1") (result i64) global.get 1) + )`).exports; - // Example use of dynamic linking - { - // Make a memory for two dynamically-linked modules to share. Each module gets five pages. - const mem = new WebAssembly.Memory({ initial: 15, maximum: 15 }); - - const mod1 = new WebAssembly.Module(wasmTextToBinary(`(module - (memory (import "env" "memory") 15 15) - (global $memBase (import "env" "__memory_base") i32) - (data (offset (global.get $memBase)) "Hello from module 1.") - (data (offset (i32.add (global.get $memBase) (i32.const 65536))) "Goodbye from module 1.") - )`)); - const instance1 = new WebAssembly.Instance(mod1, { - env: { - memory: mem, - __memory_base: 65536 * 5, // this module's memory starts at page 5 - }, - }); - - const mod2 = new WebAssembly.Module(wasmTextToBinary(`(module - (memory (import "env" "memory") 15 15) - (global $memBase (import "env" "__memory_base") i32) - (data (offset (global.get $memBase)) "Hello from module 2.") - (data (offset (i32.add (global.get $memBase) (i32.const 65536))) "Goodbye from module 2.") - )`)); - const instance2 = new WebAssembly.Instance(mod2, { - env: { - memory: mem, - __memory_base: 65536 * 10, // this module's memory starts at page 10 - }, - }); - - // All four strings should now be present in the memory. - - function assertStringInMem(mem, str, addr) { - const bytes = new Uint8Array(mem.buffer).slice(addr, addr + str.length); - let memStr = String.fromCharCode(...bytes); - assertEq(memStr, str); - } + assertEq(module.get0(), 10); + assertEq(module.get1(), -9n); +} - assertStringInMem(mem, "Hello from module 1.", 65536 * 5); - assertStringInMem(mem, "Goodbye from module 1.", 65536 * 6); - assertStringInMem(mem, "Hello from module 2.", 65536 * 10); - assertStringInMem(mem, "Goodbye from module 2.", 65536 * 11); +// Example use of dynamic linking +{ + // Make a memory for two dynamically-linked modules to share. Each module gets five pages. + const mem = new WebAssembly.Memory({ initial: 15, maximum: 15 }); + + const mod1 = new WebAssembly.Module(wasmTextToBinary(`(module + (memory (import "env" "memory") 15 15) + (global $memBase (import "env" "__memory_base") i32) + (data (offset (global.get $memBase)) "Hello from module 1.") + (data (offset (i32.add (global.get $memBase) (i32.const 65536))) "Goodbye from module 1.") + )`)); + const instance1 = new WebAssembly.Instance(mod1, { + env: { + memory: mem, + __memory_base: 65536 * 5, // this module's memory starts at page 5 + }, + }); + + const mod2 = new WebAssembly.Module(wasmTextToBinary(`(module + (memory (import "env" "memory") 15 15) + (global $memBase (import "env" "__memory_base") i32) + (data (offset (global.get $memBase)) "Hello from module 2.") + (data (offset (i32.add (global.get $memBase) (i32.const 65536))) "Goodbye from module 2.") + )`)); + const instance2 = new WebAssembly.Instance(mod2, { + env: { + memory: mem, + __memory_base: 65536 * 10, // this module's memory starts at page 10 + }, + }); + + // All four strings should now be present in the memory. + + function assertStringInMem(mem, str, addr) { + const bytes = new Uint8Array(mem.buffer).slice(addr, addr + str.length); + let memStr = String.fromCharCode(...bytes); + assertEq(memStr, str); } + + assertStringInMem(mem, "Hello from module 1.", 65536 * 5); + assertStringInMem(mem, "Goodbye from module 1.", 65536 * 6); + assertStringInMem(mem, "Hello from module 2.", 65536 * 10); + assertStringInMem(mem, "Goodbye from module 2.", 65536 * 11); } // Semantic errors. diff --git a/js/src/jit-test/tests/wasm/import-export.js b/js/src/jit-test/tests/wasm/import-export.js index 4845269f24..ecd02ca143 100644 --- a/js/src/jit-test/tests/wasm/import-export.js +++ b/js/src/jit-test/tests/wasm/import-export.js @@ -401,9 +401,10 @@ wasmFailValidateText('(module (export "a" (memory 0)))', /exported memory index wasmFailValidateText('(module (export "a" (table 0)))', /exported table index out of bounds/); // Default memory/table rules - -wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (memory 1 1))', /already have default memory/); -wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (import "x" "y" (memory 2 2)))', /already have default memory/); +if (!wasmMultiMemoryEnabled()) { + wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (memory 1 1))', /already have default memory/); + wasmFailValidateText('(module (import "a" "b" (memory 1 1)) (import "x" "y" (memory 2 2)))', /already have default memory/); +} // Data segments on imports diff --git a/js/src/jit-test/tests/wasm/memory-control/directives.txt b/js/src/jit-test/tests/wasm/memory-control/directives.txt index 1092e20d8a..a3daf19d97 100644 --- a/js/src/jit-test/tests/wasm/memory-control/directives.txt +++ b/js/src/jit-test/tests/wasm/memory-control/directives.txt @@ -1 +1 @@ -|jit-test| include:wasm.js; test-also=--wasm-compiler=optimizing --wasm-memory-control; test-also=--wasm-compiler=baseline --wasm-memory-control; test-also=--wasm-compiler=optimizing --no-wasm-memory64 --wasm-memory-control; test-also=--wasm-compiler=baseline --no-wasm-memory64 --wasm-memory-control +|jit-test| include:wasm.js; test-also=--wasm-compiler=optimizing --setpref=wasm_memory_control=true; test-also=--wasm-compiler=baseline --setpref=wasm_memory_control=true; test-also=--wasm-compiler=optimizing --setpref=wasm_memory64=false --setpref=wasm_memory_control=true; test-also=--wasm-compiler=baseline --setpref=wasm_memory64=false --setpref=wasm_memory_control=true diff --git a/js/src/jit-test/tests/wasm/memory-control/memory-discard.js b/js/src/jit-test/tests/wasm/memory-control/memory-discard.js index 87f2ae625a..8d2c63ad8a 100644 --- a/js/src/jit-test/tests/wasm/memory-control/memory-discard.js +++ b/js/src/jit-test/tests/wasm/memory-control/memory-discard.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmMemoryControlEnabled(); test-also=--wasm-memory64; test-also=--no-wasm-memory64 +// |jit-test| skip-if: !wasmMemoryControlEnabled(); test-also=--setpref=wasm_memory64=true; test-also=--setpref=wasm_memory64=false // This tests memory.discard and WebAssembly.Memory.discard() by placing data // (the alphabet) halfway across a page boundary, then discarding the first diff --git a/js/src/jit-test/tests/wasm/memory64/directives.txt b/js/src/jit-test/tests/wasm/memory64/directives.txt index 98d92a7afc..5fc5acabf0 100644 --- a/js/src/jit-test/tests/wasm/memory64/directives.txt +++ b/js/src/jit-test/tests/wasm/memory64/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmMemory64Enabled() +|jit-test| test-also=--setpref=wasm_memory64=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; include:wasm.js; skip-if: !wasmMemory64Enabled() diff --git a/js/src/jit-test/tests/wasm/multi-memory/directives.txt b/js/src/jit-test/tests/wasm/multi-memory/directives.txt index 44374e8ceb..2ed5e3dd2a 100644 --- a/js/src/jit-test/tests/wasm/multi-memory/directives.txt +++ b/js/src/jit-test/tests/wasm/multi-memory/directives.txt @@ -1,2 +1,2 @@ -|jit-test| --wasm-multi-memory; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js; skip-if: !wasmMultiMemoryEnabled() +|jit-test| --setpref=wasm_multi_memory=true; test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; include:wasm.js; skip-if: !wasmMultiMemoryEnabled() diff --git a/js/src/jit-test/tests/wasm/multi-value/directives.txt b/js/src/jit-test/tests/wasm/multi-value/directives.txt index f636e648ec..b5a203297f 100644 --- a/js/src/jit-test/tests/wasm/multi-value/directives.txt +++ b/js/src/jit-test/tests/wasm/multi-value/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/oom/breakpoints.js b/js/src/jit-test/tests/wasm/oom/breakpoints.js index a90f97739a..eabb660e0f 100644 --- a/js/src/jit-test/tests/wasm/oom/breakpoints.js +++ b/js/src/jit-test/tests/wasm/oom/breakpoints.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - var dbgGlobal = newGlobal({newCompartment: true}); var dbg = new dbgGlobal.Debugger(); dbg.addDebuggee(this); diff --git a/js/src/jit-test/tests/wasm/oom/exports.js b/js/src/jit-test/tests/wasm/oom/exports.js index 391850fda7..f75ada6199 100644 --- a/js/src/jit-test/tests/wasm/oom/exports.js +++ b/js/src/jit-test/tests/wasm/oom/exports.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { let text = `(module (type (func (param i32) (result i32))) diff --git a/js/src/jit-test/tests/wasm/oom/jsapi-prototype.js b/js/src/jit-test/tests/wasm/oom/jsapi-prototype.js index 4888a70db0..f5f319a8c5 100644 --- a/js/src/jit-test/tests/wasm/oom/jsapi-prototype.js +++ b/js/src/jit-test/tests/wasm/oom/jsapi-prototype.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - oomTest(() => { let memory = new WebAssembly.Memory({initial: 0}); assertEq(Object.getPrototypeOf(memory), WebAssembly.Memory.prototype, "prototype"); diff --git a/js/src/jit-test/tests/wasm/ref-types/directives.txt b/js/src/jit-test/tests/wasm/ref-types/directives.txt index ed90b6bd5f..f9c573abef 100644 --- a/js/src/jit-test/tests/wasm/ref-types/directives.txt +++ b/js/src/jit-test/tests/wasm/ref-types/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); test-also=--wasm-test-serialization; include:wasm.js +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); test-also=--setpref=wasm_test_serialization=true; include:wasm.js diff --git a/js/src/jit-test/tests/wasm/regress/bug1708124.js b/js/src/jit-test/tests/wasm/regress/bug1708124.js index dc035b02e5..3cccd59dc0 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1708124.js +++ b/js/src/jit-test/tests/wasm/regress/bug1708124.js @@ -1,4 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) // Ensure that trap reporting mechanism doesn't crash under OOM conditions. oomTest( diff --git a/js/src/jit-test/tests/wasm/regress/bug1839065.js b/js/src/jit-test/tests/wasm/regress/bug1839065.js index ecc4c1b90c..e3d84589b6 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1839065.js +++ b/js/src/jit-test/tests/wasm/regress/bug1839065.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; --wasm-function-references; skip-if: !wasmGcEnabled() || !wasmFunctionReferencesEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || !wasmGcEnabled() function wasmEvalText(str, imports) { let binary = wasmTextToBinary(str); m = new WebAssembly.Module(binary); diff --git a/js/src/jit-test/tests/wasm/regress/bug1839142.js b/js/src/jit-test/tests/wasm/regress/bug1839142.js index 339c1d7cb9..49ca0117e9 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1839142.js +++ b/js/src/jit-test/tests/wasm/regress/bug1839142.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; --wasm-function-references; skip-if: !wasmSimdEnabled() || !wasmGcEnabled() || !wasmFunctionReferencesEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmSimdEnabled() || !wasmGcEnabled() || !wasmGcEnabled() var wasm_code = new Uint8Array([0,97,115,109,1,0,0,0,1,152,128,128,128,0,4,80,0,95,1,126,0,80,0,94,124,1,80,0,96,3,127,127,127,1,127,96,0,0,3,130,128,128,128,0,1,2,4,133,128,128,128,0,1,112,1,1,1,5,132,128,128,128,0,1,1,16,32,13,131,128,128,128,0,1,0,3,6,204,131,128,128,0,62,100,107,0,66,197,129,131,134,140,152,176,224,64,251,0,0,11,127,0,65,196,129,131,134,124,11,100,107,0,66,192,129,131,134,204,132,137,146,36,251,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,124,1,68,0,0,0,0,0,0,0,0,11,100,107,0,66,192,129,131,134,140,216,53,251,0,0,11,100,107,1,66,210,164,201,146,165,202,148,169,210,0,66,210,164,201,146,165,202,212,156,218,0,66,192,129,131,134,140,152,176,224,64,66,192,129,131,134,140,152,176,224,64,126,125,66,192,129,131,128,130,152,176,224,64,125,66,192,129,131,190,130,152,176,224,36,125,66,164,200,0,125,125,66,0,125,66,0,125,66,0,125,251,0,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,127,0,65,0,11,7,136,128,128,128,0,1,4,109,97,105,110,0,0,9,139,128,128,128,0,1,6,0,65,0,11,112,1,210,0,11,10,141,133,128,128,0,1,138,5,0,65,238,235,177,226,126,253,15,253,83,32,0,65,235,146,246,155,122,65,244,231,246,248,124,253,15,253,164,1,65,230,152,157,154,7,253,15,253,164,1,118,65,167,184,218,133,127,253,15,253,164,1,118,118,66,149,131,127,66,164,128,218,132,206,227,209,231,254,0,65,230,133,189,200,126,65,252,208,237,164,5,254,32,0,132,245,241,222,13,27,254,71,2,211,226,246,158,7,66,243,213,226,237,209,166,141,199,0,68,76,189,205,180,194,110,195,89,36,3,131,253,18,253,127,253,127,253,127,253,127,253,164,1,65,138,173,198,47,65,138,248,237,203,120,65,205,162,146,252,5,65,190,148,192,156,5,254,53,0,200,229,139,195,9,65,167,139,216,173,5,65,215,146,221,45,254,53,0,169,255,135,252,1,254,53,0,193,209,131,217,7,40,2,134,242,184,197,3,65,228,191,145,146,6,65,142,162,226,169,4,254,53,0,168,178,151,189,15,113,109,71,109,107,254,46,0,191,232,145,230,9,67,66,84,34,11,67,88,147,220,200,91,68,233,240,20,66,52,37,190,38,182,187,182,187,182,187,182,187,182,187,57,3,168,169,148,198,10,65,226,162,208,167,7,65,221,226,226,242,120,107,65,140,215,139,233,5,65,141,151,153,19,107,107,65,188,134,175,165,5,65,183,219,200,136,121,107,65,250,197,157,214,123,65,139,168,173,167,126,107,107,107,42,1,249,156,171,169,13,187,182,187,182,187,182,187,182,187,182,65,191,253,243,170,122,253,15,65,203,195,202,169,122,253,15,65,179,204,244,234,123,253,15,253,119,65,166,184,138,186,122,253,15,65,129,140,243,163,6,253,15,253,119,65,229,139,254,233,121,253,15,65,183,191,195,183,122,253,15,253,119,253,119,65,151,211,231,151,122,253,15,253,119,253,119,253,119,65,192,156,192,215,3,65,178,193,209,198,7,107,65,240,157,246,199,6,65,221,225,148,169,1,107,65,145,183,142,141,127,65,188,218,139,244,7,107,107,65,236,243,250,169,127,65,146,241,174,181,120,107,65,139,147,232,229,124,65,255,203,253,217,3,107,107,65,250,197,224,140,2,65,202,242,215,181,3,107,65,135,244,246,28,65,140,170,229,200,123,107,107,107,65,154,217,196,153,1,65,137,128,243,231,123,107,107,107,107,65,227,146,143,180,126,40,1,245,130,139,196,13,40,2,244,172,225,238,10,40,0,216,160,178,215,11,40,1,197,193,230,178,3,40,2,195,241,223,254,2,65,158,240,247,204,124,40,2,140,190,218,180,14,40,2,215,128,167,146,8,40,0,141,143,157,196,10,40,0,147,146,185,143,13,40,1,195,168,134,179,5,107,107,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,69,253,15,253,119,253,31,0,91,254,46,0,203,243,148,239,8,11]); var wasm_module = new WebAssembly.Module(wasm_code); var wasm_instance = new WebAssembly.Instance(wasm_module); diff --git a/js/src/jit-test/tests/wasm/regress/bug1856733.js b/js/src/jit-test/tests/wasm/regress/bug1856733.js index 0f3e59dcfe..57e1380780 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1856733.js +++ b/js/src/jit-test/tests/wasm/regress/bug1856733.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; skip-if: !wasmGcEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() // Validates if imported globals are accounted for in init expressions. diff --git a/js/src/jit-test/tests/wasm/regress/bug1857829.js b/js/src/jit-test/tests/wasm/regress/bug1857829.js index 037855a4b1..df0598f678 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1857829.js +++ b/js/src/jit-test/tests/wasm/regress/bug1857829.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; skip-if: !wasmGcEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() // Tests if i31ref global value is normalized. var ins = wasmEvalText(`(module diff --git a/js/src/jit-test/tests/wasm/regress/bug1858982.js b/js/src/jit-test/tests/wasm/regress/bug1858982.js index 574c4bfe24..c67ae317f1 100644 --- a/js/src/jit-test/tests/wasm/regress/bug1858982.js +++ b/js/src/jit-test/tests/wasm/regress/bug1858982.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-tail-calls; --wasm-gc; skip-if: !wasmGcEnabled() || !wasmTailCallsEnabled() +// |jit-test| --setpref=wasm_tail_calls=true; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || !wasmTailCallsEnabled() // Tests if instance registers were restored properly when call_ref is used // with tail calls. diff --git a/js/src/jit-test/tests/wasm/regress/bug1878673.js b/js/src/jit-test/tests/wasm/regress/bug1878673.js new file mode 100644 index 0000000000..edf2e67187 --- /dev/null +++ b/js/src/jit-test/tests/wasm/regress/bug1878673.js @@ -0,0 +1,13 @@ +// Check proper handling of OOM in SIMD loads. + +oomTest(function () { + let x = wasmTextToBinary(`(module + (memory 1 1) + (func + i32.const 16 + v128.load8x8_s + i16x8.abs + drop) + )`); + new WebAssembly.Module(x); +}); diff --git a/js/src/jit-test/tests/wasm/regress/bug1880770.js b/js/src/jit-test/tests/wasm/regress/bug1880770.js new file mode 100644 index 0000000000..0e748137d2 --- /dev/null +++ b/js/src/jit-test/tests/wasm/regress/bug1880770.js @@ -0,0 +1,20 @@ +// Check proper handling of OOM during segments creation. + +var x = {}; +Object.defineProperty(x, "", { + enumerable: true, + get: function () { + new WebAssembly.Instance( + new WebAssembly.Module( + wasmTextToBinary( + '(func $f (result f32) f32.const 0)(table (export "g") 1 funcref) (elem (i32.const 0) $f)' + ) + ) + ).exports.g + .get(0) + .type(WebAssembly, "", WebAssembly.Module, {}); + }, +}); +oomTest(function () { + Object.values(x); +}); diff --git a/js/src/jit-test/tests/wasm/regress/oom-eval.js b/js/src/jit-test/tests/wasm/regress/oom-eval.js index 1ce7c26df1..2f70bf8803 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-eval.js +++ b/js/src/jit-test/tests/wasm/regress/oom-eval.js @@ -1,4 +1,4 @@ -// |jit-test| slow; allow-oom; skip-if: !wasmIsSupported() || !('oomTest' in this) +// |jit-test| slow; allow-oom; skip-if: !wasmIsSupported() function foo() { var g = newGlobal({sameZoneAs: this}); diff --git a/js/src/jit-test/tests/wasm/regress/oom-init.js b/js/src/jit-test/tests/wasm/regress/oom-init.js index f08b088107..4c6d0206b6 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-init.js +++ b/js/src/jit-test/tests/wasm/regress/oom-init.js @@ -1,4 +1,4 @@ -// |jit-test| slow; allow-oom; skip-if: !wasmIsSupported() || !('oomTest' in this) +// |jit-test| slow; allow-oom; skip-if: !wasmIsSupported() || !hasFunction.oomTest Object.getOwnPropertyNames(this); s = newGlobal(); diff --git a/js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js b/js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js index 3f74666d0a..f2026a6788 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js +++ b/js/src/jit-test/tests/wasm/regress/oom-masm-baseline.js @@ -1,4 +1,4 @@ -// |jit-test| slow; skip-if: !('oomTest' in this) +// |jit-test| slow // Test baseline compiler only. if (typeof wasmCompileMode === 'undefined' || wasmCompileMode() != 'baseline') diff --git a/js/src/jit-test/tests/wasm/regress/oom-wasm-streaming.js b/js/src/jit-test/tests/wasm/regress/oom-wasm-streaming.js index 5d7e719912..8a3c8e65d4 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-wasm-streaming.js +++ b/js/src/jit-test/tests/wasm/regress/oom-wasm-streaming.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomAfterAllocations' in this) - ignoreUnhandledRejections(); try { diff --git a/js/src/jit-test/tests/wasm/regress/oom-wasmtexttobinary-block.js b/js/src/jit-test/tests/wasm/regress/oom-wasmtexttobinary-block.js index 6f3b666873..aaa7ff121f 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-wasmtexttobinary-block.js +++ b/js/src/jit-test/tests/wasm/regress/oom-wasmtexttobinary-block.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - try { oomTest((function () { wasmTextToBinary("(module(func(loop $label1 $label0)))"); diff --git a/js/src/jit-test/tests/wasm/regress/oom-wrong-argument-number-for-import-call.js b/js/src/jit-test/tests/wasm/regress/oom-wrong-argument-number-for-import-call.js index 2d41b466ea..d4eb2da5a3 100644 --- a/js/src/jit-test/tests/wasm/regress/oom-wrong-argument-number-for-import-call.js +++ b/js/src/jit-test/tests/wasm/regress/oom-wrong-argument-number-for-import-call.js @@ -1,5 +1,3 @@ -// |jit-test| skip-if: !('oomTest' in this) - function f() { // Too many results returned. return [52, 10, 0, 0]; diff --git a/js/src/jit-test/tests/wasm/simd/directives.txt b/js/src/jit-test/tests/wasm/simd/directives.txt index 651282ecb5..aced6c31a7 100644 --- a/js/src/jit-test/tests/wasm/simd/directives.txt +++ b/js/src/jit-test/tests/wasm/simd/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; test-also=--wasm-test-serialization; test-also=--wasm-compiler=optimizing --no-avx; skip-variant-if: --wasm-compiler=optimizing --no-avx, !getBuildConfiguration("x86") && !getBuildConfiguration("x64") || getBuildConfiguration("simulator"); include:wasm.js +|jit-test| test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=optimizing; test-also=--setpref=wasm_test_serialization=true; test-also=--wasm-compiler=optimizing --no-avx; skip-variant-if: --wasm-compiler=optimizing --no-avx, !getBuildConfiguration("x86") && !getBuildConfiguration("x64") || getBuildConfiguration("simulator"); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/simd/experimental.js b/js/src/jit-test/tests/wasm/simd/experimental.js index 3076cce80b..ded45928e6 100644 --- a/js/src/jit-test/tests/wasm/simd/experimental.js +++ b/js/src/jit-test/tests/wasm/simd/experimental.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-relaxed-simd; skip-if: !wasmRelaxedSimdEnabled() +// |jit-test| --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled() // Experimental opcodes. We have no text parsing support for these yet. The // tests will be cleaned up and moved into ad-hack.js if the opcodes are @@ -77,7 +77,7 @@ for ( let [opcode, xs, ys, as, operator] of [[F32x4RelaxedMaddCode, fxs, fys, fa body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), ...V128Load(48), - SimdPrefix, varU32(opcode)])]})])])); + SimdPrefix, ...varU32(opcode)])]})])])); var mem = new (k == 4 ? Float32Array : Float64Array)(ins.exports.mem.buffer); set(mem, k, xs); @@ -97,7 +97,7 @@ for ( let [opcode, xs, ys, as, operator] of [[F32x4RelaxedMaddCode, fxs, fys, fa funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(0), ...V128Load(0), - SimdPrefix, varU32(opcode)])]})])]))); + SimdPrefix, ...varU32(opcode)])]})])]))); } // Relaxed swizzle, https://github.com/WebAssembly/relaxed-simd/issues/22 @@ -112,7 +112,7 @@ var ins = wasmValidateAndEval(moduleWithSections([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), - SimdPrefix, varU32(I8x16RelaxedSwizzleCode)])]})])])); + SimdPrefix, ...varU32(I8x16RelaxedSwizzleCode)])]})])])); var mem = new Uint8Array(ins.exports.mem.buffer); var test = [1, 4, 3, 7, 123, 0, 8, 222]; set(mem, 16, test); @@ -134,7 +134,7 @@ assertEq(false, WebAssembly.validate(moduleWithSections([ bodySection([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), - SimdPrefix, varU32(I8x16RelaxedSwizzleCode)])]})])]))); + SimdPrefix, ...varU32(I8x16RelaxedSwizzleCode)])]})])]))); // Relaxed MIN/MAX, https://github.com/WebAssembly/relaxed-simd/issues/33 @@ -164,11 +164,11 @@ for (let k of [4, 2]) { funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), - SimdPrefix, varU32(minOpcode)])]}), + SimdPrefix, ...varU32(minOpcode)])]}), funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), - SimdPrefix, varU32(maxOpcode)])]})])])); + SimdPrefix, ...varU32(maxOpcode)])]})])])); for (let i = 0; i < minMaxTests.length; i++) { var Ty = k == 4 ? Float32Array : Float64Array; var mem = new Ty(ins.exports.mem.buffer); @@ -198,7 +198,7 @@ for (let k of [4, 2]) { bodySection([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(0), - SimdPrefix, varU32(op)])]})])]))); + SimdPrefix, ...varU32(op)])]})])]))); } } @@ -216,16 +216,16 @@ var ins = wasmValidateAndEval(moduleWithSections([ bodySection([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), - SimdPrefix, varU32(I32x4RelaxedTruncSSatF32x4Code)])]}), + SimdPrefix, ...varU32(I32x4RelaxedTruncSSatF32x4Code)])]}), funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), - SimdPrefix, varU32(I32x4RelaxedTruncUSatF32x4Code)])]}), + SimdPrefix, ...varU32(I32x4RelaxedTruncUSatF32x4Code)])]}), funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), - SimdPrefix, varU32(I32x4RelaxedTruncSatF64x2SZeroCode)])]}), + SimdPrefix, ...varU32(I32x4RelaxedTruncSatF64x2SZeroCode)])]}), funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), - SimdPrefix, varU32(I32x4RelaxedTruncSatF64x2UZeroCode)])]})])])); + SimdPrefix, ...varU32(I32x4RelaxedTruncSatF64x2UZeroCode)])]})])])); var mem = ins.exports.mem.buffer; set(new Float32Array(mem), 4, [0, 2.3, -3.4, 100000]); @@ -260,7 +260,7 @@ for (let op of [I32x4RelaxedTruncSSatF32x4Code, I32x4RelaxedTruncUSatF32x4Code, exportSection([]), bodySection([ funcBody({locals:[], - body: [...V128StoreExpr(0, [SimdPrefix, varU32(op)])]})])]))); + body: [...V128StoreExpr(0, [SimdPrefix, ...varU32(op)])]})])]))); } // Relaxed blend / laneselect, https://github.com/WebAssembly/relaxed-simd/issues/17 @@ -281,7 +281,7 @@ for (let [k, opcode, AT] of [[1, I8x16RelaxedLaneSelectCode, Int8Array], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), ...V128Load(48), - SimdPrefix, varU32(opcode)])]})])])); + SimdPrefix, ...varU32(opcode)])]})])])); var mem = ins.exports.mem.buffer; var mem8 = new Uint8Array(mem); @@ -310,7 +310,7 @@ for (let [k, opcode, AT] of [[1, I8x16RelaxedLaneSelectCode, Int8Array], funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(0), ...V128Load(0), - SimdPrefix, varU32(opcode)])]})])]))); + SimdPrefix, ...varU32(opcode)])]})])]))); } @@ -325,7 +325,7 @@ var ins = wasmValidateAndEval(moduleWithSections([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), - SimdPrefix, varU32(I16x8RelaxedQ15MulrSCode)])]})])])); + SimdPrefix, ...varU32(I16x8RelaxedQ15MulrSCode)])]})])])); var mem16 = new Int16Array(ins.exports.mem.buffer); for (let [as, bs] of cross([ @@ -355,7 +355,7 @@ var ins = wasmValidateAndEval(moduleWithSections([ funcBody({locals:[], body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), - SimdPrefix, varU32(I16x8DotI8x16I7x16SCode)])]})])])); + SimdPrefix, ...varU32(I16x8DotI8x16I7x16SCode)])]})])])); var mem8 = new Int8Array(ins.exports.mem.buffer); var mem16 = new Int16Array(ins.exports.mem.buffer); var test7bit = [1, 2, 3, 4, 5, 64, 65, 127, 127, 0, 0, @@ -385,7 +385,7 @@ var ins = wasmValidateAndEval(moduleWithSections([ body: [...V128StoreExpr(0, [...V128Load(16), ...V128Load(32), ...V128Load(48), - SimdPrefix, varU32(I32x4DotI8x16I7x16AddSCode)])]})])])); + SimdPrefix, ...varU32(I32x4DotI8x16I7x16AddSCode)])]})])])); var mem8 = new Int8Array(ins.exports.mem.buffer); var mem32 = new Int32Array(ins.exports.mem.buffer); var test7bit = [1, 2, 3, 4, 5, 64, 65, 127, 127, 0, 0, diff --git a/js/src/jit-test/tests/wasm/spec/exception-handling/directives.txt b/js/src/jit-test/tests/wasm/spec/exception-handling/directives.txt index 51f58354cb..77f4127908 100644 --- a/js/src/jit-test/tests/wasm/spec/exception-handling/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/exception-handling/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-exceptions; --wasm-exnref; skip-if: !wasmExceptionsEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_exnref=true; skip-if: !wasmExnRefEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/extended-const/directives.txt b/js/src/jit-test/tests/wasm/spec/extended-const/directives.txt index 5b3d5f6d83..e93d8c8df0 100644 --- a/js/src/jit-test/tests/wasm/spec/extended-const/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/extended-const/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-extended-const; --no-wasm-gc; skip-if: !wasmExtendedConstEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_gc=false \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/function-references/directives.txt b/js/src/jit-test/tests/wasm/spec/function-references/directives.txt index bb76560525..a9cf6401e1 100644 --- a/js/src/jit-test/tests/wasm/spec/function-references/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/function-references/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-function-references; skip-if: !wasmFunctionReferencesEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/function-references/return_call_ref.wast.js b/js/src/jit-test/tests/wasm/spec/function-references/return_call_ref.wast.js index 3ea51a8cb0..df24798146 100644 --- a/js/src/jit-test/tests/wasm/spec/function-references/return_call_ref.wast.js +++ b/js/src/jit-test/tests/wasm/spec/function-references/return_call_ref.wast.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-tail-calls; skip-if: !wasmTailCallsEnabled() +// |jit-test| --setpref=wasm_tail_calls=true; skip-if: !wasmTailCallsEnabled() /* Copyright 2021 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/js/src/jit-test/tests/wasm/spec/gc/directives.txt b/js/src/jit-test/tests/wasm/spec/gc/directives.txt index c071d8b980..a9cf6401e1 100644 --- a/js/src/jit-test/tests/wasm/spec/gc/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/gc/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-gc; skip-if: !wasmGcEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/memory64/directives.txt b/js/src/jit-test/tests/wasm/spec/memory64/directives.txt index bbc47fb788..740ef217b9 100644 --- a/js/src/jit-test/tests/wasm/spec/memory64/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/memory64/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; skip-if: !wasmMemory64Enabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_memory64=true; skip-if: !wasmMemory64Enabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js index 341742ab86..0af2f021bb 100644 --- a/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js +++ b/js/src/jit-test/tests/wasm/spec/memory64/memory64.wast.js @@ -27,17 +27,19 @@ let $2 = instantiate(`(module (memory i64 1 256))`); // ./test/core/memory64.wast:6 let $3 = instantiate(`(module (memory i64 0 65536))`); -// ./test/core/memory64.wast:8 -assert_invalid( - () => instantiate(`(module (memory i64 0) (memory i64 0))`), - `multiple memories`, -); - -// ./test/core/memory64.wast:9 -assert_invalid( - () => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`), - `multiple memories`, -); +if (!wasmMultiMemoryEnabled()) { + // ./test/core/memory64.wast:8 + assert_invalid( + () => instantiate(`(module (memory i64 0) (memory i64 0))`), + `multiple memories`, + ); + + // ./test/core/memory64.wast:9 + assert_invalid( + () => instantiate(`(module (memory (import "spectest" "memory") i64 0) (memory i64 0))`), + `multiple memories`, + ); +} // ./test/core/memory64.wast:11 let $4 = instantiate(`(module (memory i64 (data)) (func (export "memsize") (result i64) (memory.size)))`); diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/directives.txt b/js/src/jit-test/tests/wasm/spec/multi-memory/directives.txt index 9211583549..7c18d36751 100644 --- a/js/src/jit-test/tests/wasm/spec/multi-memory/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/multi-memory/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-multi-memory; skip-if: !wasmMultiMemoryEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_multi_memory=true; skip-if: !wasmMultiMemoryEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js b/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js index a96781e8ed..e03b3f35db 100644 --- a/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js +++ b/js/src/jit-test/tests/wasm/spec/multi-memory/harness/harness.js @@ -19,6 +19,15 @@ if (!wasmIsSupported()) { quit(); } +function partialOobWriteMayWritePartialData() { + let arm_native = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator"); + let arm64_native = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator"); + return arm_native || arm64_native; +} + +let native_arm = getBuildConfiguration("arm") && !getBuildConfiguration("arm-simulator"); +let native_arm64 = getBuildConfiguration("arm64") && !getBuildConfiguration("arm64-simulator"); + function bytes(type, bytes) { var typedBuffer = new Uint8Array(bytes); return wasmGlobalFromArrayBuffer(type, typedBuffer.buffer); diff --git a/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js b/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js index ef68a1c0ec..35b8bd5a80 100644 --- a/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js +++ b/js/src/jit-test/tests/wasm/spec/multi-memory/memory_trap1.wast.js @@ -562,11 +562,15 @@ assert_trap(() => invoke($0, `i64.load32_u`, [-3]), `out of bounds memory access // ./test/core/multi-memory/memory_trap1.wast:234 assert_trap(() => invoke($0, `i64.load32_u`, [-4]), `out of bounds memory access`); -// ./test/core/multi-memory/memory_trap1.wast:237 -assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 7523094288207667809n)]); +// Bug 1842293 - do not observe the partial store caused by bug 1666747 on +// some native platforms. +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/multi-memory/memory_trap1.wast:237 + assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 7523094288207667809n)]); -// ./test/core/multi-memory/memory_trap1.wast:238 -assert_return(() => invoke($0, `i64.load`, [0]), [value("i64", 7523094288207667809n)]); + // ./test/core/multi-memory/memory_trap1.wast:238 + assert_return(() => invoke($0, `i64.load`, [0]), [value("i64", 7523094288207667809n)]); +} // ./test/core/multi-memory/memory_trap1.wast:242 assert_return(() => invoke($0, `i64.store`, [65528, 0n]), []); @@ -574,14 +578,18 @@ assert_return(() => invoke($0, `i64.store`, [65528, 0n]), []); // ./test/core/multi-memory/memory_trap1.wast:243 assert_trap(() => invoke($0, `i32.store`, [65533, 305419896]), `out of bounds memory access`); -// ./test/core/multi-memory/memory_trap1.wast:244 -assert_return(() => invoke($0, `i32.load`, [65532]), [value("i32", 0)]); +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/multi-memory/memory_trap1.wast:244 + assert_return(() => invoke($0, `i32.load`, [65532]), [value("i32", 0)]); +} // ./test/core/multi-memory/memory_trap1.wast:245 assert_trap(() => invoke($0, `i64.store`, [65529, 1311768467294899695n]), `out of bounds memory access`); -// ./test/core/multi-memory/memory_trap1.wast:246 -assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 0n)]); +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/multi-memory/memory_trap1.wast:246 + assert_return(() => invoke($0, `i64.load`, [65528]), [value("i64", 0n)]); +} // ./test/core/multi-memory/memory_trap1.wast:247 assert_trap( @@ -589,8 +597,10 @@ assert_trap( `out of bounds memory access`, ); -// ./test/core/multi-memory/memory_trap1.wast:248 -assert_return(() => invoke($0, `f32.load`, [65532]), [value("f32", 0)]); +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/multi-memory/memory_trap1.wast:248 + assert_return(() => invoke($0, `f32.load`, [65532]), [value("f32", 0)]); +} // ./test/core/multi-memory/memory_trap1.wast:249 assert_trap( @@ -598,5 +608,7 @@ assert_trap( `out of bounds memory access`, ); -// ./test/core/multi-memory/memory_trap1.wast:250 -assert_return(() => invoke($0, `f64.load`, [65528]), [value("f64", 0)]); +if (!partialOobWriteMayWritePartialData()) { + // ./test/core/multi-memory/memory_trap1.wast:250 + assert_return(() => invoke($0, `f64.load`, [65528]), [value("f64", 0)]); +} diff --git a/js/src/jit-test/tests/wasm/spec/relaxed-simd/directives.txt b/js/src/jit-test/tests/wasm/spec/relaxed-simd/directives.txt index 625758af79..bbeff405b1 100644 --- a/js/src/jit-test/tests/wasm/spec/relaxed-simd/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/relaxed-simd/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-relaxed-simd; skip-if: !wasmRelaxedSimdEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_relaxed_simd=true; skip-if: !wasmRelaxedSimdEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/spec/directives.txt b/js/src/jit-test/tests/wasm/spec/spec/directives.txt index 9fa4f75347..b26fb254a9 100644 --- a/js/src/jit-test/tests/wasm/spec/spec/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/spec/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; test-also=--no-avx; skip-variant-if: --no-avx, !getBuildConfiguration('x86') && !getBuildConfiguration('x64') || getBuildConfiguration('simulator') \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; test-also=--no-avx; skip-variant-if: --no-avx, !getBuildConfiguration('x86') && !getBuildConfiguration('x64') || getBuildConfiguration('simulator') \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/spec/spec/global.wast.js b/js/src/jit-test/tests/wasm/spec/spec/global.wast.js index e3351d3421..7f2502cc27 100644 --- a/js/src/jit-test/tests/wasm/spec/spec/global.wast.js +++ b/js/src/jit-test/tests/wasm/spec/spec/global.wast.js @@ -1,4 +1,4 @@ -// |jit-test| --no-wasm-gc +// |jit-test| --setpref=wasm_gc=false /* Copyright 2021 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js b/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js index 831bb26d69..211f610b69 100644 --- a/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js +++ b/js/src/jit-test/tests/wasm/spec/spec/memory.wast.js @@ -33,14 +33,16 @@ let $4 = instantiate(`(module (memory 1 256))`); // ./test/core/memory.wast:8 let $5 = instantiate(`(module (memory 0 65536))`); -// ./test/core/memory.wast:10 -assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`); - -// ./test/core/memory.wast:11 -assert_invalid( - () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`), - `multiple memories`, -); +if (!wasmMultiMemoryEnabled()) { + // ./test/core/memory.wast:10 + assert_invalid(() => instantiate(`(module (memory 0) (memory 0))`), `multiple memories`); + + // ./test/core/memory.wast:11 + assert_invalid( + () => instantiate(`(module (memory (import "spectest" "memory") 0) (memory 0))`), + `multiple memories`, + ); +} // ./test/core/memory.wast:13 let $6 = instantiate(`(module (memory (data)) (func (export "memsize") (result i32) (memory.size)))`); diff --git a/js/src/jit-test/tests/wasm/spec/tail-call/directives.txt b/js/src/jit-test/tests/wasm/spec/tail-call/directives.txt index 223b6b843a..fbd3639abc 100644 --- a/js/src/jit-test/tests/wasm/spec/tail-call/directives.txt +++ b/js/src/jit-test/tests/wasm/spec/tail-call/directives.txt @@ -1 +1 @@ -|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--wasm-test-serialization; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --wasm-tail-calls; skip-if: !wasmTailCallsEnabled() \ No newline at end of file +|jit-test| test-also=--wasm-compiler=optimizing; test-also=--wasm-compiler=baseline; test-also=--setpref=wasm_test_serialization=true; test-also=--test-wasm-await-tier2; test-also=--disable-wasm-huge-memory; skip-variant-if: --disable-wasm-huge-memory, !wasmHugeMemorySupported(); local-include:harness/harness.js; --setpref=wasm_tail_calls=true; skip-if: !wasmTailCallsEnabled() \ No newline at end of file diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1862473.js b/js/src/jit-test/tests/wasm/tail-calls/bug1862473.js index 57e5ea2118..fd44aa8f26 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/bug1862473.js +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1862473.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; skip-if: !wasmGcEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() var ins = wasmEvalText(`(module (func $func1) diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1865044.js b/js/src/jit-test/tests/wasm/tail-calls/bug1865044.js index 042e641f32..bf984e7b87 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/bug1865044.js +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1865044.js @@ -1,4 +1,4 @@ -// |jit-test| --more-compartments; skip-variant-if: --wasm-test-serialization, true; skip-variant-if: --wasm-compiler=ion, true; skip-if: !wasmGcEnabled() || !('Function' in WebAssembly) +// |jit-test| --more-compartments; skip-variant-if: --setpref=wasm_test_serialization=true, true; skip-variant-if: --wasm-compiler=ion, true; skip-if: !wasmGcEnabled() || !('Function' in WebAssembly) a = newGlobal(); a.b = this; diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1871605.js b/js/src/jit-test/tests/wasm/tail-calls/bug1871605.js index 84f37a3e42..3403cea102 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/bug1871605.js +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1871605.js @@ -1,4 +1,4 @@ -// |jit-test| --more-compartments; skip-variant-if: --wasm-test-serialization, true; skip-variant-if: --wasm-compiler=ion, true; skip-if: !wasmGcEnabled() +// |jit-test| --more-compartments; skip-variant-if: --setpref=wasm_test_serialization=true, true; skip-variant-if: --wasm-compiler=ion, true; skip-if: !wasmGcEnabled() var dbg = newGlobal() dbg.parent = this diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1871606.js b/js/src/jit-test/tests/wasm/tail-calls/bug1871606.js index aa520d1f53..ec43665c62 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/bug1871606.js +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1871606.js @@ -1,4 +1,4 @@ -// |jit-test| --more-compartments; skip-variant-if: --wasm-test-serialization, true; skip-variant-if: --wasm-compiler=ion, true +// |jit-test| --more-compartments; skip-variant-if: --setpref=wasm_test_serialization=true, true; skip-variant-if: --wasm-compiler=ion, true dbg = newGlobal(); dbg.b = this; dbg.eval("(" + function() { diff --git a/js/src/jit-test/tests/wasm/tail-calls/bug1871951.js b/js/src/jit-test/tests/wasm/tail-calls/bug1871951.js index 6b3e481d59..6dc8b69548 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/bug1871951.js +++ b/js/src/jit-test/tests/wasm/tail-calls/bug1871951.js @@ -1,4 +1,4 @@ -// |jit-test| skip-variant-if: --wasm-test-serialization, true; skip-if: !wasmGcEnabled() +// |jit-test| skip-variant-if: --setpref=wasm_test_serialization=true, true; skip-if: !wasmGcEnabled() gczeal(18) function a(str, imports) { diff --git a/js/src/jit-test/tests/wasm/tail-calls/directives.txt b/js/src/jit-test/tests/wasm/tail-calls/directives.txt index 66e8161b9d..eac1ba242f 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/directives.txt +++ b/js/src/jit-test/tests/wasm/tail-calls/directives.txt @@ -1 +1 @@ -|jit-test| --wasm-tail-calls; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=ion; test-also=--wasm-test-serialization; skip-if: !wasmTailCallsEnabled(); include:wasm.js +|jit-test| --setpref=wasm_tail_calls=true; test-also=--wasm-compiler=baseline; test-also=--wasm-compiler=ion; test-also=--setpref=wasm_test_serialization=true; skip-if: !wasmTailCallsEnabled(); include:wasm.js diff --git a/js/src/jit-test/tests/wasm/tail-calls/exceptions.js b/js/src/jit-test/tests/wasm/tail-calls/exceptions.js index fd05f37e53..c4c774a4f3 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/exceptions.js +++ b/js/src/jit-test/tests/wasm/tail-calls/exceptions.js @@ -1,5 +1,3 @@ -// |jit-test| --wasm-exceptions; skip-if: !wasmExceptionsEnabled() - // Simple test with return_call. var ins = wasmEvalText(`(module (tag $exn) diff --git a/js/src/jit-test/tests/wasm/tail-calls/gc.js b/js/src/jit-test/tests/wasm/tail-calls/gc.js index 10e5971e6d..7f4df4c69a 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/gc.js +++ b/js/src/jit-test/tests/wasm/tail-calls/gc.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-function-references; --wasm-gc; skip-if: !wasmGcEnabled() || getBuildConfiguration("simulator") +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() || getBuildConfiguration("simulator") // Tests GC references passed as arguments during return calls. // Similar to js/src/jit-test/tests/wasm/gc/trailers-gc-stress.js diff --git a/js/src/jit-test/tests/wasm/tail-calls/litmus3.js b/js/src/jit-test/tests/wasm/tail-calls/litmus3.js index bdd0918717..4fe367fb29 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/litmus3.js +++ b/js/src/jit-test/tests/wasm/tail-calls/litmus3.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmTailCallsEnabled() || !wasmExceptionsEnabled() +// |jit-test| skip-if: !wasmTailCallsEnabled() // Mutually recursive functions implement a multi-entry loop using tail calls, // with exception handling. diff --git a/js/src/jit-test/tests/wasm/tail-calls/litmus4.js b/js/src/jit-test/tests/wasm/tail-calls/litmus4.js index c16f712aac..6562f76686 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/litmus4.js +++ b/js/src/jit-test/tests/wasm/tail-calls/litmus4.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmTailCallsEnabled() || !wasmExceptionsEnabled() +// |jit-test| skip-if: !wasmTailCallsEnabled() // Mutually recursive functions implement a multi-entry loop using indirect tail // calls, with exception handling. diff --git a/js/src/jit-test/tests/wasm/tail-calls/litmus8.js b/js/src/jit-test/tests/wasm/tail-calls/litmus8.js index 4602664488..126367a0a0 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/litmus8.js +++ b/js/src/jit-test/tests/wasm/tail-calls/litmus8.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmTailCallsEnabled() || !wasmExceptionsEnabled() +// |jit-test| skip-if: !wasmTailCallsEnabled() // Tail-call litmus test with multiple results // diff --git a/js/src/jit-test/tests/wasm/tail-calls/litmus9.js b/js/src/jit-test/tests/wasm/tail-calls/litmus9.js index 3bbde27111..513e5c058e 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/litmus9.js +++ b/js/src/jit-test/tests/wasm/tail-calls/litmus9.js @@ -1,4 +1,4 @@ -// |jit-test| skip-if: !wasmTailCallsEnabled() || !wasmExceptionsEnabled() +// |jit-test| skip-if: !wasmTailCallsEnabled() // Tail-call litmus test with multiple results // diff --git a/js/src/jit-test/tests/wasm/tail-calls/return_call_ref.js b/js/src/jit-test/tests/wasm/tail-calls/return_call_ref.js index c5f250a41c..947da02ef5 100644 --- a/js/src/jit-test/tests/wasm/tail-calls/return_call_ref.js +++ b/js/src/jit-test/tests/wasm/tail-calls/return_call_ref.js @@ -1,4 +1,4 @@ -// |jit-test| --wasm-gc; skip-if: !wasmGcEnabled() +// |jit-test| --setpref=wasm_gc=true; skip-if: !wasmGcEnabled() var ins = wasmEvalText(`(module (type $t (func (param i64 i64 funcref) (result i64))) (elem declare func $fac-acc $fac-acc-broken) diff --git a/js/src/jit-test/tests/wasm/testing/directives.txt b/js/src/jit-test/tests/wasm/testing/directives.txt new file mode 100644 index 0000000000..01f722ba1e --- /dev/null +++ b/js/src/jit-test/tests/wasm/testing/directives.txt @@ -0,0 +1 @@ +|jit-test| include:wasm.js diff --git a/js/src/jit-test/tests/wasm/testing/global-lossless-invoke.js b/js/src/jit-test/tests/wasm/testing/global-lossless-invoke.js new file mode 100644 index 0000000000..66db0499d9 --- /dev/null +++ b/js/src/jit-test/tests/wasm/testing/global-lossless-invoke.js @@ -0,0 +1,13 @@ +// |jit-test| skip-if: !('wasmLosslessInvoke' in this) + +let bytecode = wasmTextToBinary(`(module + (func (export "f") (result i32) + i32.const 1 + ) +)`); +let g = newGlobal({sameCompartmentAs: wasmLosslessInvoke}); +let m = new g.WebAssembly.Module(bytecode); +let i = new g.WebAssembly.Instance(m); + +assertEq(i.exports.f(), 1); +assertEq(wasmLosslessInvoke(i.exports.f).value, 1); -- cgit v1.2.3