Commit 2656330f authored by Thibaud Michaud's avatar Thibaud Michaud Committed by V8 LUCI CQ

[wasm] Print hash of anonymous scripts in stack traces

So that it is possible to differentiate modules in the stack trace even
when they are anonymous.

R=kimanh@chromium.org

Bug: v8:11808
Change-Id: I12a1f07accdf62c404052f32624e9914381a7451
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3074472
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Reviewed-by: 's avatarKim-Anh Tran <kimanh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76141}
parent 007aec55
......@@ -718,12 +718,6 @@ void SerializeJSStackFrame(Isolate* isolate, Handle<StackFrameInfo> frame,
}
#if V8_ENABLE_WEBASSEMBLY
bool IsAnonymousWasmScript(Isolate* isolate, Handle<Object> url) {
Handle<String> prefix =
isolate->factory()->NewStringFromStaticChars("wasm://wasm/");
return StringIndexOf(isolate, Handle<String>::cast(url), prefix) == 0;
}
void SerializeWasmStackFrame(Isolate* isolate, Handle<StackFrameInfo> frame,
IncrementalStringBuilder* builder) {
Handle<Object> module_name = StackFrameInfo::GetWasmModuleName(frame);
......@@ -743,7 +737,7 @@ void SerializeWasmStackFrame(Isolate* isolate, Handle<StackFrameInfo> frame,
}
Handle<Object> url(frame->GetScriptNameOrSourceURL(), isolate);
if (IsNonEmptyString(url) && !IsAnonymousWasmScript(isolate, url)) {
if (IsNonEmptyString(url)) {
builder->AppendString(Handle<String>::cast(url));
} else {
builder->AppendCString("<anonymous>");
......
......@@ -12,8 +12,8 @@ Script wasm://wasm/8c388106 byte offset 33: Wasm opcode 0x01 (kExprNop)
Getting current stack trace via "new Error().stack".
Error
at v8://test/getStack:1:1
at func (<anonymous>:wasm-function[0]:0x21)
at main (<anonymous>:wasm-function[1]:0x2f)
at func (wasm://wasm/8c388106:wasm-function[0]:0x21)
at main (wasm://wasm/24ba77a6:wasm-function[1]:0x2f)
at v8://test/runWasm:1:22
exports.main returned.
Finished.
......@@ -12,8 +12,8 @@ Result of evaluate (string):
Error: this is your stack trace:
-- skipped --
at call_debugger (<anonymous>:3:5)
at call_func (<anonymous>:wasm-function[1]:0x37)
at main (<anonymous>:wasm-function[2]:0x3e)
at call_func (wasm://wasm/37655946:wasm-function[1]:0x37)
at main (wasm://wasm/37655946:wasm-function[2]:0x3e)
at testFunction (<anonymous>:15:20)
at <anonymous>:1:1
Finished!
wasm-function[0]:0x32: WebAssembly.Exception: wasm exception
WebAssembly.Exception: wasm exception
at rethrow0 (<anonymous>:wasm-function[0]:0x32)
at rethrow0 (wasm://wasm/f019909a:wasm-function[0]:0x32)
at *%(basename)s:21:18
wasm-function[0]:0x2e: WebAssembly.Exception: wasm exception
WebAssembly.Exception: wasm exception
at throw0 (<anonymous>:wasm-function[0]:0x2e)
at throw0 (wasm://wasm/e4cabeba:wasm-function[0]:0x2e)
at *%(basename)s:17:18
wasm-function[0]:0x22: RuntimeError: unreachable
RuntimeError: unreachable
at main (<anonymous>:wasm-function[0]:0x22)
at main (wasm://wasm/d578b3d2:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:31
wasm-function[0]:0x22: RuntimeError: unreachable
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:31
wasm-function[0]:0x22: RuntimeError: unreachable
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:31
wasm-function[0]:0x22: RuntimeError: unreachable
RuntimeError: unreachable
at <anonymous>:wasm-function[0]:0x22
at wasm://wasm/44ee3bce:wasm-function[0]:0x22
at *%(basename)s:{NUMBER}:31
wasm-function[1]:0x30: RuntimeError: divide by zero
RuntimeError: divide by zero
at main (<anonymous>:wasm-function[1]:0x30)
at main (wasm://wasm/7b123b7e:wasm-function[1]:0x30)
at *%(basename)s:{NUMBER}:16
RuntimeError: unreachable
at main (<anonymous>:wasm-function[0]:0x22)
at main (wasm://wasm/d578b3d2:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at main (<anonymous>:wasm-function[0]:0x22)
at main (wasm://wasm/d578b3d2:wasm-function[0]:0x22)
at test/message/wasm-function-name-async.js:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at test/message/wasm-module-and-function-name-async.js:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at *%(basename)s:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at test-module.main (<anonymous>:wasm-function[0]:0x22)
at test-module.main (wasm://wasm/test-module-712dabfa:wasm-function[0]:0x22)
at test/message/wasm-module-name-async.js:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at <anonymous>:wasm-function[0]:0x22
at wasm://wasm/44ee3bce:wasm-function[0]:0x22
at *%(basename)s:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
RuntimeError: unreachable
at <anonymous>:wasm-function[0]:0x22
at wasm://wasm/44ee3bce:wasm-function[0]:0x22
at test/message/wasm-no-name-async.js:{NUMBER}:27
at test/mjsunit/mjsunit.js:*
......@@ -23,7 +23,7 @@ function verifyStack(frames, expected) {
assertContains(exp[4], frames[i].getFileName(), "["+i+"].getFileName()");
var toString;
if (exp[0]) {
toString = "<anonymous>:wasm-function[" + exp[6] + "]:" + exp[5];
toString = exp[4] + ":wasm-function[" + exp[6] + "]:" + exp[5];
if (exp[1] !== null) toString = exp[1] + " (" + toString + ")";
} else {
toString = exp[4] + ":" + exp[2] + ":";
......@@ -69,7 +69,7 @@ var module = builder.instantiate({mod: {func: STACK}});
var expected_string = 'Error\n' +
// The line numbers below will change as this test gains / loses lines..
' at STACK (stack.js:38:11)\n' + // --
' at main (<anonymous>:wasm-function[1]:0x72)\n' + // --
' at main (wasm://wasm/862e1cf6:wasm-function[1]:0x72)\n' + // --
' at testSimpleStack (stack.js:76:18)\n' + // --
' at stack.js:78:3'; // --
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment