OLD | NEW |
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 --expose-gc --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 | 11 |
12 function genGrowMemoryBuilder() { | 12 function genGrowMemoryBuilder() { |
13 var builder = new WasmModuleBuilder(); | 13 var builder = new WasmModuleBuilder(); |
14 builder.addFunction("grow_memory", kSig_i_i) | 14 builder.addFunction("grow_memory", kSig_i_i) |
15 .addBody([kExprGetLocal, 0, kExprGrowMemory]) | 15 .addBody([kExprGetLocal, 0, kExprGrowMemory]) |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 poke(0xaced); | 434 poke(0xaced); |
435 assertEquals(0xaced, peek()); | 435 assertEquals(0xaced, peek()); |
436 } | 436 } |
437 | 437 |
438 for (offset = 4*kPageSize - 3; offset <= 4*kPageSize + 4; offset++) { | 438 for (offset = 4*kPageSize - 3; offset <= 4*kPageSize + 4; offset++) { |
439 assertTraps(kTrapMemOutOfBounds, poke); | 439 assertTraps(kTrapMemOutOfBounds, poke); |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 testGrowMemoryOutOfBoundsOffset(); | 443 testGrowMemoryOutOfBoundsOffset(); |
| 444 |
| 445 function testGrowMemoryOutOfBoundsOffset2() { |
| 446 var builder = new WasmModuleBuilder(); |
| 447 builder.addMemory(16, 128, false); |
| 448 builder.addFunction("main", kSig_v_v) |
| 449 .addBody([ |
| 450 kExprI32Const, 20, |
| 451 kExprI32Const, 29, |
| 452 kExprGrowMemory, |
| 453 kExprI32StoreMem, 0, 0xFF, 0xFF, 0xFF, 0x3a |
| 454 ]) |
| 455 .exportAs("main"); |
| 456 var module = builder.instantiate(); |
| 457 assertTraps(kTrapMemOutOfBounds, module.exports.main); |
| 458 } |
| 459 |
| 460 testGrowMemoryOutOfBoundsOffset2(); |
OLD | NEW |