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/bug1693500.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/bug1693500.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/bug1693500.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/bug1693500.js b/js/src/jit-test/tests/wasm/bug1693500.js new file mode 100644 index 0000000000..932dba1a57 --- /dev/null +++ b/js/src/jit-test/tests/wasm/bug1693500.js @@ -0,0 +1,73 @@ +// |jit-test| skip-if: !wasmSimdEnabled() || wasmCompileMode() != "ion" || (!getBuildConfiguration().x86 && !getBuildConfiguration().x64) || getBuildConfiguration().simulator + +const avx = isAvxPresent(); +for (let [n1, n2, numInstr] of [ + [0x123456789abn, 0xffeeddccbbaa9988n, avx ? 6 : 7], + [42n, 0xFFFFFFFFn, avx ? 3 : 4], + [0n, 0n, 1], + [1n, 1n, 1], + ...iota(63).map(i => [2n << BigInt(i), 2n << BigInt(i), 1]), + ...iota(63).reduce((acc, i) => { + const base = 2n << BigInt(i); + return acc.concat(iota(i + 1).map(j => [ + base | (1n << BigInt(j)), base | (1n << BigInt(j)), + (avx ? 2 : 3) + (j == 0 ? 0 : 1)])); + }, []), + ...iota(63).map(i => [~(1n << BigInt(i)), ~(1n << BigInt(i)), avx ? 5 : 6]), + [0x7fffffffffffffffn, 0x7fffffffffffffffn, avx ? 5 : 6], + [-1n, -1n, 3], +]) { + var wasm = wasmTextToBinary(`(module + (memory (export "memory") 1 1) + (func $t (export "t") (param v128) (result v128) + local.get 0 + v128.const i64x2 ${n1} ${n2} + i64x2.mul + ) + (func $t0 (param v128 v128) (result v128) + local.get 0 + local.get 1 + i64x2.mul + ) + (func (export "run") (result i32) + i32.const 16 + i32.const 0 + v128.load + call $t + v128.store + + v128.const i64x2 ${n1} ${n2} + i32.const 0 + v128.load + call $t0 + + i32.const 16 + v128.load + i64x2.eq + i64x2.all_true + ) + )`) + + var ins = new WebAssembly.Instance(new WebAssembly.Module(wasm)); + var mem64 = new BigInt64Array(ins.exports.memory.buffer, 0, 4); + + for (let [t1, t2] of [ + [1n, 1n], [-1n, -2n], [0n, 0n], [0x123456789abn, 0xffeeddccbbaa9988n], + [0x100001111n, -0xFF0011n], [5555n, 0n], + ]) { + mem64[0] = t1; mem64[1] = t2; + assertEq(ins.exports.run(), 1); + } + + if (hasDisassembler() && getBuildConfiguration().x64) { + const dis = wasmDis(ins.exports.t, {asString: true,}); + const lines = getFuncBody(dis).trim().split('\n'); + assertEq(lines.length, numInstr); + } +} + +// Utils. +function getFuncBody(dis) { + const parts = dis.split(/mov %rsp, %rbp\n|^[0-9A-Fa-f ]+pop %rbp/gm); + return parts.at(-2).replace(/[0-9A-F]{8} (?: [0-9a-f]{2})+[\s\n]+/g, ""); +} |