Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Unified Diff: test/mjsunit/wasm/stack.js

Issue 1878563003: [wasm] Add test case for stack trace of wasm traps (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@extend-wasm-stack-test-1
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/wasm/stack.js
diff --git a/test/mjsunit/wasm/stack.js b/test/mjsunit/wasm/stack.js
index 11f5f84703698f908c0df9909434ce94215cccb7..5235ce950fb4f7b55eeb1823d53dc6c0d0ae28ba 100644
--- a/test/mjsunit/wasm/stack.js
+++ b/test/mjsunit/wasm/stack.js
@@ -42,6 +42,21 @@ builder.addFunction("main", [kAstStmt])
.addBody([kExprCallImport, 0])
.exportAs("main");
+builder.addFunction("exec_unreachable", [kAstStmt])
+ .addBody([kExprUnreachable])
+ .exportAs("exec_unreachable");
+
+// make this function unnamed, just to test also this case
+var mem_oob_func = builder.addFunction(undefined, [kAstStmt])
+ // access the memory at offset -1
+ .addBody([kExprI32LoadMem8S, 0, 0, kExprI32Const, 0x7f])
+ .exportAs("mem_out_of_bounds");
+
+// call the mem_out_of_bounds function, in order to have two WASM stack frames
+builder.addFunction("call_mem_out_of_bounds", [kAstStmt])
+ .addBody([kExprCallFunction, mem_oob_func.index])
+ .exportAs("call_mem_out_of_bounds");
+
var module = builder.instantiate({func: STACK});
(function testSimpleStack() {
@@ -49,8 +64,8 @@ var module = builder.instantiate({func: STACK});
// The line numbers below will change as this test gains / loses lines..
" at STACK (stack.js:33:11)\n" + // --
" at <WASM> (<anonymous>)\n" + // TODO(jfb): wasm stack here.
- " at testSimpleStack (stack.js:55:18)\n" + // --
- " at stack.js:57:3"; // --
+ " at testSimpleStack (stack.js:70:18)\n" + // --
+ " at stack.js:72:3"; // --
module.exports.main();
assertEquals(expected_string, stripPath(stack));
@@ -70,7 +85,38 @@ Error.prepareStackTrace = function(error, frames) {
// function line file toString
[ "STACK", 33, "stack.js", "stack.js:33:11"],
[ "<WASM>", null, null, "<WASM>"],
- ["testStackFrames", 66, "stack.js", "stack.js:66:18"],
- [ null, 76, "stack.js", "stack.js:76:3"]
+ ["testStackFrames", 81, "stack.js", "stack.js:81:18"],
+ [ null, 91, "stack.js", "stack.js:91:3"]
]);
})();
+
+(function testWasmUnreachable() {
+ try {
+ module.exports.exec_unreachable();
+ fail("expected wasm exception");
+ } catch (e) {
+ assertContains("unreachable", e.message);
+ verifyStack(e.stack, [
+ // function line file toString
+ [ "<WASM>", null, null, "<WASM>"],
+ ["testWasmUnreachable", 95, "stack.js", "stack.js:95:20"],
+ [ null, 106, "stack.js", "stack.js:106:3"]
+ ]);
+ }
+})();
+
+(function testWasmMemOutOfBounds() {
+ try {
+ module.exports.call_mem_out_of_bounds();
+ fail("expected wasm exception");
+ } catch (e) {
+ assertContains("out of bounds", e.message);
+ verifyStack(e.stack, [
+ // function line file toString
+ [ "<WASM>", null, null, "<WASM>"],
+ [ "<WASM>", null, null, "<WASM>"],
+ ["testWasmMemOutOfBounds", 110, "stack.js", "stack.js:110:20"],
+ [ null, 122, "stack.js", "stack.js:122:3"]
+ ]);
+ }
+})();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698