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.addMemory(1, 1, true); | 15 builder.addMemory(1, 1, true); |
16 builder.addFunction("main", kSig_i_i) | 16 builder.addFunction("main", kSig_i_i) |
17 .addBody([ | 17 .addBody([ |
18 // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0; | 18 // main body: while(i) { if(mem[i]) return -1; i -= 4; } return 0; |
19 // TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc | 19 // TODO(titzer): this manual bytecode has a copy of test-run-wasm.cc |
20 /**/ kExprLoop, kAstStmt, // -- | 20 /**/ kExprLoop, kWasmStmt, // -- |
21 /* */ kExprGetLocal, 0, // -- | 21 /* */ kExprGetLocal, 0, // -- |
22 /* */ kExprIf, kAstStmt, // -- | 22 /* */ kExprIf, kWasmStmt, // -- |
23 /* */ kExprGetLocal, 0, // -- | 23 /* */ kExprGetLocal, 0, // -- |
24 /* */ kExprI32LoadMem, 0, 0, // -- | 24 /* */ kExprI32LoadMem, 0, 0, // -- |
25 /* */ kExprIf, kAstStmt, // -- | 25 /* */ kExprIf, kWasmStmt, // -- |
26 /* */ kExprI8Const, 255, // -- | 26 /* */ kExprI8Const, 255, // -- |
27 /* */ kExprReturn, // -- | 27 /* */ kExprReturn, // -- |
28 /* */ kExprEnd, // -- | 28 /* */ kExprEnd, // -- |
29 /* */ kExprGetLocal, 0, // -- | 29 /* */ kExprGetLocal, 0, // -- |
30 /* */ kExprI8Const, 4, // -- | 30 /* */ kExprI8Const, 4, // -- |
31 /* */ kExprI32Sub, // -- | 31 /* */ kExprI32Sub, // -- |
32 /* */ kExprSetLocal, 0, // -- | 32 /* */ kExprSetLocal, 0, // -- |
33 /* */ kExprBr, 1, // -- | 33 /* */ kExprBr, 1, // -- |
34 /* */ kExprEnd, // -- | 34 /* */ kExprEnd, // -- |
35 /* */ kExprEnd, // -- | 35 /* */ kExprEnd, // -- |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 for (offset = 65534; offset < 66536; offset++) { | 163 for (offset = 65534; offset < 66536; offset++) { |
164 assertTraps(kTrapMemOutOfBounds, read); | 164 assertTraps(kTrapMemOutOfBounds, read); |
165 assertTraps(kTrapMemOutOfBounds, write); | 165 assertTraps(kTrapMemOutOfBounds, write); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 testOOBThrows(); | 169 testOOBThrows(); |
OLD | NEW |