diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/wasm/function-references/br-non-null.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/jit-test/tests/wasm/function-references/br-non-null.js | 76 |
1 files changed, 76 insertions, 0 deletions
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 new file mode 100644 index 0000000000..371cdaa40a --- /dev/null +++ b/js/src/jit-test/tests/wasm/function-references/br-non-null.js @@ -0,0 +1,76 @@ +// |jit-test| skip-if: !wasmFunctionReferencesEnabled() + +// br_on_non_null from constant +wasmValidateText(`(module + (func + block (result (ref extern)) + ref.null extern + br_on_non_null 0 + return + end + drop + ) +)`); + +// br_on_non_null from parameter +wasmValidateText(`(module + (func (param externref) (result (ref extern)) + local.get 0 + br_on_non_null 0 + unreachable + ) +)`); + +// br_on_null with multiple results +wasmValidateText(`(module + (func (param (ref null extern) (ref extern)) (result i32 i32 i32 (ref extern)) + i32.const 0 + i32.const 1 + i32.const 2 + local.get 0 + br_on_non_null 0 + local.get 1 + ) +)`); + +// no block type +wasmFailValidateText(`(module + (func + block + ref.null extern + br_on_non_null 0 + end + ) +)`, /type mismatch: target block type expected to be \[_, ref\]/); + +// in dead code +wasmValidateText(`(module + (type $t (func)) + (func (result funcref) + ref.null $t + return + br_on_non_null 0 + ) +)`); + +wasmFailValidateText(`(module + (func + return + br_on_non_null 0 + ) +)`, /type mismatch: target block type expected to be \[_, ref\]/); + +// Test the branch takes the correct path and results are passed correctly +let {ifNull} = wasmEvalText(`(module + (func (export "ifNull") (param externref externref) (result externref) + local.get 0 + br_on_non_null 0 + local.get 1 + ) +)`).exports; + +const DefaultTestVal = "default!test"; +assertEq(ifNull(null, DefaultTestVal), DefaultTestVal); +for (let val of WasmNonNullExternrefValues) { + assertEq(ifNull(val, DefaultTestVal), val); +} |