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 | 5 // Flags: --expose-wasm |
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 // Collect the Callsite objects instead of just a string: | 10 // Collect the Callsite objects instead of just a string: |
11 Error.prepareStackTrace = function(error, frames) { | 11 Error.prepareStackTrace = function(error, frames) { |
12 return frames; | 12 return frames; |
13 }; | 13 }; |
14 | 14 |
15 var builder = new WasmModuleBuilder(); | 15 var builder = new WasmModuleBuilder(); |
16 | 16 |
17 var sig_index = builder.addSignature(kSig_i_v) | 17 var sig_index = builder.addType(kSig_i_v) |
18 | 18 |
19 // Build a function to resemble this code: | 19 // Build a function to resemble this code: |
20 // if (idx < 2) { | 20 // if (idx < 2) { |
21 // return load(-2 / idx); | 21 // return load(-2 / idx); |
22 // } else if (idx == 2) { | 22 // } else if (idx == 2) { |
23 // unreachable; | 23 // unreachable; |
24 // } else { | 24 // } else { |
25 // return call_indirect(idx); | 25 // return call_indirect(idx); |
26 // } | 26 // } |
27 // There are four different traps which are triggered by different input values: | 27 // There are four different traps which are triggered by different input values: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 assertEquals(0, e.stack[0].getLineNumber(), "wasmFunctionIndex"); | 69 assertEquals(0, e.stack[0].getLineNumber(), "wasmFunctionIndex"); |
70 assertEquals(position, e.stack[0].getPosition(), "position"); | 70 assertEquals(position, e.stack[0].getPosition(), "position"); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 // The actual tests: | 74 // The actual tests: |
75 testWasmTrap(0, kTrapDivByZero, 12); | 75 testWasmTrap(0, kTrapDivByZero, 12); |
76 testWasmTrap(1, kTrapMemOutOfBounds, 13); | 76 testWasmTrap(1, kTrapMemOutOfBounds, 13); |
77 testWasmTrap(2, kTrapUnreachable, 26); | 77 testWasmTrap(2, kTrapUnreachable, 26); |
78 testWasmTrap(3, kTrapFuncInvalid, 30); | 78 testWasmTrap(3, kTrapFuncInvalid, 30); |
OLD | NEW |