| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 --expose-gc --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 kMemSize = 65536; | 10 var kMemSize = 65536; |
| 11 | 11 |
| 12 function genModule(memory) { | 12 function genModule(memory) { |
| 13 var builder = new WasmModuleBuilder(); | 13 var builder = new WasmModuleBuilder(); |
| 14 | 14 |
| 15 builder.addImportedMemory("", "memory", 1, 1); | 15 builder.addImportedMemory("", "memory", 1); |
| 16 builder.exportMemoryAs("memory"); | 16 builder.exportMemoryAs("memory"); |
| 17 builder.addFunction("main", kSig_i_i) | 17 builder.addFunction("main", kSig_i_i) |
| 18 .addBody([ | 18 .addBody([ |
| 19 // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0; | 19 // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0; |
| 20 // TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc | 20 // TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc |
| 21 /**/ kExprLoop, kWasmStmt, // -- | 21 /**/ kExprLoop, kWasmStmt, // -- |
| 22 /* */ kExprGetLocal, 0, // -- | 22 /* */ kExprGetLocal, 0, // -- |
| 23 /* */ kExprIf, kWasmStmt, // -- | 23 /* */ kExprIf, kWasmStmt, // -- |
| 24 /* */ kExprGetLocal, 0, // -- | 24 /* */ kExprGetLocal, 0, // -- |
| 25 /* */ kExprI32LoadMem, 0, 0, // -- | 25 /* */ kExprI32LoadMem, 0, 0, // -- |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 | 163 |
| 164 for (offset = 65534; offset < 66536; offset++) { | 164 for (offset = 65534; offset < 66536; offset++) { |
| 165 assertTraps(kTrapMemOutOfBounds, read); | 165 assertTraps(kTrapMemOutOfBounds, read); |
| 166 assertTraps(kTrapMemOutOfBounds, write); | 166 assertTraps(kTrapMemOutOfBounds, write); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 testOOBThrows(); | 170 testOOBThrows(); |
| OLD | NEW |