diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/wasm/memory64/memory-init.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/wasm/memory64/memory-init.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/memory64/memory-init.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/memory64/memory-init.js b/js/src/jit-test/tests/wasm/memory64/memory-init.js new file mode 100644 index 0000000000..246fc3f2d4 --- /dev/null +++ b/js/src/jit-test/tests/wasm/memory64/memory-init.js @@ -0,0 +1,45 @@ +// |jit-test| allow-oom; skip-if: !canRunHugeMemoryTests() + +var S = (function () { + let s = ""; + for ( let i=0; i < 16; i++ ) + s += "0123456789abcdef" + return s; +})(); + +for (let shared of ['', 'shared']) { + try { + var ins = new WebAssembly.Instance(new WebAssembly.Module(wasmTextToBinary(` +(module + (memory (export "mem") i64 65537 65537 ${shared}) + (data $d "${S}") + (func (export "f") (param $p i64) (param $o i32) (param $n i32) + (memory.init $d (local.get $p) (local.get $o) (local.get $n))))`))); + } catch (e) { + if (e instanceof WebAssembly.RuntimeError && String(e).match(/too many memory pages/)) { + quit(0); + } + throw e; + } + + var mem = new Uint8Array(ins.exports.mem.buffer); + + // Init above 4GB + doit(mem, 0x1_0000_1000, 1, S.length-1); + + // Init above 4GB with OOM + assertErrorMessage(() => ins.exports.f(0x1_0000_ff80n, 0, 256), + WebAssembly.RuntimeError, + /out of bounds/); + + // Init across 4GB + doit(mem, 0xffff_ff80, 3, 200); +} + +function doit(mem, addr, offs, n) { + ins.exports.f(BigInt(addr), offs, n); + for (let i=0; i < n; i++) { + assertEq(mem[addr+i], S.charCodeAt(offs+i)); + } +} + |