| 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 // clang-format off | 5 // clang-format off |
| 6 // Flags: --expose-wasm | 6 // Flags: --expose-wasm |
| 7 | 7 |
| 8 load("test/mjsunit/wasm/wasm-constants.js"); | 8 load("test/mjsunit/wasm/wasm-constants.js"); |
| 9 load("test/mjsunit/wasm/wasm-module-builder.js"); | 9 load("test/mjsunit/wasm/wasm-module-builder.js"); |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 "["+i+"].getFunctionName()"); | 21 "["+i+"].getFunctionName()"); |
| 22 } | 22 } |
| 23 assertEquals(exp[2], frames[i].getLineNumber(), "["+i+"].getLineNumber()"); | 23 assertEquals(exp[2], frames[i].getLineNumber(), "["+i+"].getLineNumber()"); |
| 24 if (exp[0]) | 24 if (exp[0]) |
| 25 assertEquals(exp[3], frames[i].getPosition(), | 25 assertEquals(exp[3], frames[i].getPosition(), |
| 26 "["+i+"].getPosition()"); | 26 "["+i+"].getPosition()"); |
| 27 assertContains(exp[4], frames[i].getFileName(), "["+i+"].getFileName()"); | 27 assertContains(exp[4], frames[i].getFileName(), "["+i+"].getFileName()"); |
| 28 var toString; | 28 var toString; |
| 29 if (exp[0]) { | 29 if (exp[0]) { |
| 30 var funName = exp[1] == "?" ? "" : exp[1]; | 30 var funName = exp[1] == "?" ? "" : exp[1]; |
| 31 toString = funName + " (<WASM>:" + exp[2] + ":" + exp[3] + ")"; | 31 toString = funName + " (<WASM>[" + exp[2] + "]+" + exp[3] + ")"; |
| 32 } else { | 32 } else { |
| 33 toString = exp[4] + ":" + exp[2] + ":"; | 33 toString = exp[4] + ":" + exp[2] + ":"; |
| 34 } | 34 } |
| 35 assertContains(toString, frames[i].toString(), "["+i+"].toString()"); | 35 assertContains(toString, frames[i].toString(), "["+i+"].toString()"); |
| 36 }); | 36 }); |
| 37 } | 37 } |
| 38 | 38 |
| 39 | 39 |
| 40 var stack; | 40 var stack; |
| 41 function STACK() { | 41 function STACK() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 builder.addFunction("call_mem_out_of_bounds", kSig_v_v) | 65 builder.addFunction("call_mem_out_of_bounds", kSig_v_v) |
| 66 .addBody([kExprCallFunction, kArity0, mem_oob_func.index]) | 66 .addBody([kExprCallFunction, kArity0, mem_oob_func.index]) |
| 67 .exportAs("call_mem_out_of_bounds"); | 67 .exportAs("call_mem_out_of_bounds"); |
| 68 | 68 |
| 69 var module = builder.instantiate({func: STACK}); | 69 var module = builder.instantiate({func: STACK}); |
| 70 | 70 |
| 71 (function testSimpleStack() { | 71 (function testSimpleStack() { |
| 72 var expected_string = "Error\n" + | 72 var expected_string = "Error\n" + |
| 73 // The line numbers below will change as this test gains / loses lines.. | 73 // The line numbers below will change as this test gains / loses lines.. |
| 74 " at STACK (stack.js:42:11)\n" + // -- | 74 " at STACK (stack.js:42:11)\n" + // -- |
| 75 " at main (<WASM>:0:1)\n" + // -- | 75 " at main (<WASM>[0]+1)\n" + // -- |
| 76 " at testSimpleStack (stack.js:79:18)\n" + // -- | 76 " at testSimpleStack (stack.js:79:18)\n" + // -- |
| 77 " at stack.js:81:3"; // -- | 77 " at stack.js:81:3"; // -- |
| 78 | 78 |
| 79 module.exports.main(); | 79 module.exports.main(); |
| 80 assertEquals(expected_string, stripPath(stack)); | 80 assertEquals(expected_string, stripPath(stack)); |
| 81 })(); | 81 })(); |
| 82 | 82 |
| 83 // For the remaining tests, collect the Callsite objects instead of just a | 83 // For the remaining tests, collect the Callsite objects instead of just a |
| 84 // string: | 84 // string: |
| 85 Error.prepareStackTrace = function(error, frames) { | 85 Error.prepareStackTrace = function(error, frames) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 assertContains("out of bounds", e.message); | 121 assertContains("out of bounds", e.message); |
| 122 verifyStack(e.stack, [ | 122 verifyStack(e.stack, [ |
| 123 // isWasm function line pos file | 123 // isWasm function line pos file |
| 124 [ true, "?", 2, 3, null], | 124 [ true, "?", 2, 3, null], |
| 125 [ true, "call_mem_out_of_bounds", 3, 1, null], | 125 [ true, "call_mem_out_of_bounds", 3, 1, null], |
| 126 [ false, "testWasmMemOutOfBounds", 118, 0, "stack.js"], | 126 [ false, "testWasmMemOutOfBounds", 118, 0, "stack.js"], |
| 127 [ false, null, 130, 0, "stack.js"] | 127 [ false, null, 130, 0, "stack.js"] |
| 128 ]); | 128 ]); |
| 129 } | 129 } |
| 130 })(); | 130 })(); |
| OLD | NEW |