summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/memory64/memory-grow.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/wasm/memory64/memory-grow.js
parentInitial commit. (diff)
downloadfirefox-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-grow.js')
-rw-r--r--js/src/jit-test/tests/wasm/memory64/memory-grow.js31
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);
+}
+