summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/memory64/memory-grow.js
diff options
context:
space:
mode:
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);
+}
+