Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: test/mjsunit/wasm/grow-memory.js

Issue 2903153002: [wasm] Increase WebAssembly.Memory maximum size to ~2GB (Closed)
Patch Set: Remove incorrect DCHECK Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-limits.h ('k') | test/mjsunit/wasm/import-memory.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/grow-memory.js
diff --git a/test/mjsunit/wasm/grow-memory.js b/test/mjsunit/wasm/grow-memory.js
index 71eb4fec95a7971ab0b824480b66304ea565ef59..a42889684778d44c548c569b0b927e61985162fe 100644
--- a/test/mjsunit/wasm/grow-memory.js
+++ b/test/mjsunit/wasm/grow-memory.js
@@ -8,7 +8,7 @@ load("test/mjsunit/wasm/wasm-constants.js");
load("test/mjsunit/wasm/wasm-module-builder.js");
var kPageSize = 0x10000;
-var kV8MaxPages = 16384;
+var kV8MaxPages = 32767;
function genGrowMemoryBuilder() {
var builder = new WasmModuleBuilder();
@@ -298,9 +298,8 @@ function testGrowMemoryTrapMaxPagesZeroInitialMemory() {
var builder = genGrowMemoryBuilder();
builder.addMemory(0, kV8MaxPages, false);
var module = builder.instantiate();
- var maxPages = 16385;
function growMem(pages) { return module.exports.grow_memory(pages); }
- assertEquals(-1, growMem(maxPages));
+ assertEquals(-1, growMem(kV8MaxPages + 1));
}
testGrowMemoryTrapMaxPagesZeroInitialMemory();
@@ -309,9 +308,8 @@ function testGrowMemoryTrapMaxPages() {
var builder = genGrowMemoryBuilder();
builder.addMemory(1, 1, false);
var module = builder.instantiate();
- var maxPages = 16384;
function growMem(pages) { return module.exports.grow_memory(pages); }
- assertEquals(-1, growMem(maxPages));
+ assertEquals(-1, growMem(kV8MaxPages));
}
testGrowMemoryTrapMaxPages();
@@ -493,3 +491,54 @@ function testGrowMemoryDeclaredSpecMaxTraps() {
}
testGrowMemoryDeclaredSpecMaxTraps();
+
+function testGrowMemory2Gb() {
+ print("testGrowMemory2Gb");
+ var builder = genGrowMemoryBuilder();
+ builder.addMemory(1, kV8MaxPages, false);
+ var module = builder.instantiate();
+ var offset, val;
+ function peek() { return module.exports.load(offset); }
+ function poke(value) { return module.exports.store(offset, value); }
+ function growMem(pages) { return module.exports.grow_memory(pages); }
+
+ for(offset = 0; offset <= (kPageSize - 4); offset+=4) {
+ poke(100000 - offset);
+ assertEquals(100000 - offset, peek());
+ }
+
+ let result = growMem(kV8MaxPages - 1);
+ if (result == 1 ){
+ for(offset = 0; offset <= (kPageSize - 4); offset+=4) {
+ assertEquals(100000 - offset, peek());
+ }
+
+ // Bounds check for large mem size
+ for(offset = (kV8MaxPages - 1) * kPageSize;
+ offset <= (kV8MaxPages * kPageSize - 4); offset+=4) {
+ poke(0xaced);
+ assertEquals(0xaced, peek());
+ }
+
+ for (offset = kV8MaxPages * kPageSize - 3;
+ offset <= kV8MaxPages * kPageSize + 4; offset++) {
+ assertTraps(kTrapMemOutOfBounds, poke);
+ }
+
+ // Check traps around 3GB/4GB boundaries
+ let offset_3gb = 49152 * kPageSize;
+ let offset_4gb = 2 * kV8MaxPages * kPageSize;
+ for (offset = offset_3gb - 5; offset < offset_3gb + 4; offset++) {
+ assertTraps(kTrapMemOutOfBounds, poke);
+ }
+ for (offset = offset_4gb - 5; offset < offset_4gb; offset++) {
+ assertTraps(kTrapMemOutOfBounds, poke);
+ }
+ } else {
+ // Allocating big chunks of memory can fail on gc_stress, especially on 32
+ // bit platforms. When grow_memory fails, expected result is -1.
+ assertEquals(-1, result);
+ }
+}
+
+testGrowMemory2Gb();
« no previous file with comments | « src/wasm/wasm-limits.h ('k') | test/mjsunit/wasm/import-memory.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698