summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/wasm/module-memory.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/mjsunit/wasm/module-memory.js')
-rw-r--r--deps/v8/test/mjsunit/wasm/module-memory.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/deps/v8/test/mjsunit/wasm/module-memory.js b/deps/v8/test/mjsunit/wasm/module-memory.js
index f5b5981436..e9d2bb954d 100644
--- a/deps/v8/test/mjsunit/wasm/module-memory.js
+++ b/deps/v8/test/mjsunit/wasm/module-memory.js
@@ -172,3 +172,26 @@ function testOOBThrows() {
}
testOOBThrows();
+
+function testAddressSpaceLimit() {
+ // 1TiB, see wasm-memory.h
+ const kMaxAddressSpace = 1 * 1024 * 1024 * 1024 * 1024;
+ const kAddressSpacePerMemory = 8 * 1024 * 1024 * 1024;
+
+ try {
+ let memories = [];
+ let address_space = 0;
+ while (address_space <= kMaxAddressSpace + 1) {
+ memories.push(new WebAssembly.Memory({initial: 1}));
+ address_space += kAddressSpacePerMemory;
+ }
+ } catch (e) {
+ assertTrue(e instanceof RangeError);
+ return;
+ }
+ failWithMessage("allocated too much memory");
+}
+
+if(%IsWasmTrapHandlerEnabled()) {
+ testAddressSpaceLimit();
+}