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/memory64/memory-grow.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/memory64/memory-grow.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/memory64/memory-grow.js b/js/src/jit-test/tests/wasm/memory64/memory-grow.js new file mode 100644 index 0000000000..0316c01b45 --- /dev/null +++ b/js/src/jit-test/tests/wasm/memory64/memory-grow.js @@ -0,0 +1,31 @@ +// |jit-test| allow-oom; skip-if: !canRunHugeMemoryTests() + +// This tests that we can grow the heap by more than 4GB. Other grow tests are +// in basic.js. + +for (let shared of ['', 'shared']) { + try { + var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(` +(module + (memory (export "mem") i64 0 65540 ${shared}) + (func (export "f") (param $delta i64) (result i64) + (memory.grow (local.get $delta))))`))); + } catch (e) { + if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) { + quit(0); + } + throw e; + } + + let res = ins.exports.f(65537n); + if (res === -1n) { + quit(0); // OOM + } + assertEq(ins.exports.mem.buffer.byteLength, 65537*65536); + let mem = new Uint8Array(ins.exports.mem.buffer); + mem[65537*65536-1] = 37; + assertEq(mem[65537*65536-1], 37); + + assertEq(ins.exports.f(4n), -1n); +} + |