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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --expose-wasm --stress-compaction 5 // Flags: --expose-wasm --stress-compaction
6 6
7 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 var kPageSize = 0x10000; 10 var kPageSize = 0x10000;
11 var kV8MaxPages = 16384; 11 var kV8MaxPages = 32767;
12 12
13 function genGrowMemoryBuilder() { 13 function genGrowMemoryBuilder() {
14 var builder = new WasmModuleBuilder(); 14 var builder = new WasmModuleBuilder();
15 builder.addFunction("grow_memory", kSig_i_i) 15 builder.addFunction("grow_memory", kSig_i_i)
16 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero]) 16 .addBody([kExprGetLocal, 0, kExprGrowMemory, kMemoryZero])
17 .exportFunc(); 17 .exportFunc();
18 builder.addFunction("load", kSig_i_i) 18 builder.addFunction("load", kSig_i_i)
19 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0]) 19 .addBody([kExprGetLocal, 0, kExprI32LoadMem, 0, 0])
20 .exportFunc(); 20 .exportFunc();
21 builder.addFunction("store", kSig_i_ii) 21 builder.addFunction("store", kSig_i_ii)
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 assertTraps(kTrapMemOutOfBounds, peek); 291 assertTraps(kTrapMemOutOfBounds, peek);
292 } 292 }
293 } 293 }
294 294
295 testGrowMemoryZeroInitialSize8(); 295 testGrowMemoryZeroInitialSize8();
296 296
297 function testGrowMemoryTrapMaxPagesZeroInitialMemory() { 297 function testGrowMemoryTrapMaxPagesZeroInitialMemory() {
298 var builder = genGrowMemoryBuilder(); 298 var builder = genGrowMemoryBuilder();
299 builder.addMemory(0, kV8MaxPages, false); 299 builder.addMemory(0, kV8MaxPages, false);
300 var module = builder.instantiate(); 300 var module = builder.instantiate();
301 var maxPages = 16385;
302 function growMem(pages) { return module.exports.grow_memory(pages); } 301 function growMem(pages) { return module.exports.grow_memory(pages); }
303 assertEquals(-1, growMem(maxPages)); 302 assertEquals(-1, growMem(kV8MaxPages + 1));
304 } 303 }
305 304
306 testGrowMemoryTrapMaxPagesZeroInitialMemory(); 305 testGrowMemoryTrapMaxPagesZeroInitialMemory();
307 306
308 function testGrowMemoryTrapMaxPages() { 307 function testGrowMemoryTrapMaxPages() {
309 var builder = genGrowMemoryBuilder(); 308 var builder = genGrowMemoryBuilder();
310 builder.addMemory(1, 1, false); 309 builder.addMemory(1, 1, false);
311 var module = builder.instantiate(); 310 var module = builder.instantiate();
312 var maxPages = 16384;
313 function growMem(pages) { return module.exports.grow_memory(pages); } 311 function growMem(pages) { return module.exports.grow_memory(pages); }
314 assertEquals(-1, growMem(maxPages)); 312 assertEquals(-1, growMem(kV8MaxPages));
315 } 313 }
316 314
317 testGrowMemoryTrapMaxPages(); 315 testGrowMemoryTrapMaxPages();
318 316
319 function testGrowMemoryTrapsWithNonSmiInput() { 317 function testGrowMemoryTrapsWithNonSmiInput() {
320 var builder = genGrowMemoryBuilder(); 318 var builder = genGrowMemoryBuilder();
321 builder.addMemory(0, kV8MaxPages, false); 319 builder.addMemory(0, kV8MaxPages, false);
322 var module = builder.instantiate(); 320 var module = builder.instantiate();
323 function growMem(pages) { return module.exports.grow_memory(pages); } 321 function growMem(pages) { return module.exports.grow_memory(pages); }
324 // The parameter of grow_memory is unsigned. Therefore -1 stands for 322 // The parameter of grow_memory is unsigned. Therefore -1 stands for
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 var kSpecMaxPages = 65535; 484 var kSpecMaxPages = 65535;
487 builder.addMemory(1, kSpecMaxPages, false); 485 builder.addMemory(1, kSpecMaxPages, false);
488 var module = builder.instantiate(); 486 var module = builder.instantiate();
489 function poke(value) { return module.exports.store(offset, value); } 487 function poke(value) { return module.exports.store(offset, value); }
490 function growMem(pages) { return module.exports.grow_memory(pages); } 488 function growMem(pages) { return module.exports.grow_memory(pages); }
491 assertEquals(1, growMem(20)); 489 assertEquals(1, growMem(20));
492 assertEquals(-1, growMem(kV8MaxPages - 20)); 490 assertEquals(-1, growMem(kV8MaxPages - 20));
493 } 491 }
494 492
495 testGrowMemoryDeclaredSpecMaxTraps(); 493 testGrowMemoryDeclaredSpecMaxTraps();
494
495 function testGrowMemory2Gb() {
496 print("testGrowMemory2Gb");
497 var builder = genGrowMemoryBuilder();
498 builder.addMemory(1, kV8MaxPages, false);
499 var module = builder.instantiate();
500 var offset, val;
501 function peek() { return module.exports.load(offset); }
502 function poke(value) { return module.exports.store(offset, value); }
503 function growMem(pages) { return module.exports.grow_memory(pages); }
504
505 for(offset = 0; offset <= (kPageSize - 4); offset+=4) {
506 poke(100000 - offset);
507 assertEquals(100000 - offset, peek());
508 }
509
510 let result = growMem(kV8MaxPages - 1);
511 if (result == 1 ){
512 for(offset = 0; offset <= (kPageSize - 4); offset+=4) {
513 assertEquals(100000 - offset, peek());
514 }
515
516 // Bounds check for large mem size
517 for(offset = (kV8MaxPages - 1) * kPageSize;
518 offset <= (kV8MaxPages * kPageSize - 4); offset+=4) {
519 poke(0xaced);
520 assertEquals(0xaced, peek());
521 }
522
523 for (offset = kV8MaxPages * kPageSize - 3;
524 offset <= kV8MaxPages * kPageSize + 4; offset++) {
525 assertTraps(kTrapMemOutOfBounds, poke);
526 }
527
528 // Check traps around 3GB/4GB boundaries
529 let offset_3gb = 49152 * kPageSize;
530 let offset_4gb = 2 * kV8MaxPages * kPageSize;
531 for (offset = offset_3gb - 5; offset < offset_3gb + 4; offset++) {
532 assertTraps(kTrapMemOutOfBounds, poke);
533 }
534 for (offset = offset_4gb - 5; offset < offset_4gb; offset++) {
535 assertTraps(kTrapMemOutOfBounds, poke);
536 }
537 } else {
538 // Allocating big chunks of memory can fail on gc_stress, especially on 32
539 // bit platforms. When grow_memory fails, expected result is -1.
540 assertEquals(-1, result);
541 }
542 }
543
544 testGrowMemory2Gb();
OLDNEW
« 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