Commit 4111c98e authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[async] Only try to peak into async functions/generators.

For --async-stack-traces don't try to peak into frames that don't belong
to async functions/generators, specifically don't try to peak into some
arbitrary builtin frames (the FrameInspector doesn't support that).

Bug: chromium:892472, chromium:892473, v8:7522
Change-Id: Idcdee26ff958c03b24dd2910bb92fc51cbc14e3c
Ref: nodejs/node#11865
Design-Document: http://bit.ly/v8-zero-cost-async-stack-traces
Reviewed-on: https://chromium-review.googlesource.com/c/1264276Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56396}
parent 63345e68
...@@ -711,15 +711,22 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, ...@@ -711,15 +711,22 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
//==================================================================== //====================================================================
// Handle a JavaScript frame. // Handle a JavaScript frame.
//==================================================================== //====================================================================
if (builder.AppendJavaScriptFrame(summary.AsJavaScript())) { auto const& java_script = summary.AsJavaScript();
last_frame_id = frame->id(); if (builder.AppendJavaScriptFrame(java_script)) {
last_frame_index = static_cast<int>(i); if (IsAsyncFunction(java_script.function()->shared()->kind())) {
last_frame_id = frame->id();
last_frame_index = static_cast<int>(i);
} else {
last_frame_id = StackFrame::NO_ID;
last_frame_index = 0;
}
} }
} else if (summary.IsWasmCompiled()) { } else if (summary.IsWasmCompiled()) {
//==================================================================== //====================================================================
// Handle a WASM compiled frame. // Handle a WASM compiled frame.
//==================================================================== //====================================================================
if (builder.AppendWasmCompiledFrame(summary.AsWasmCompiled())) { auto const& wasm_compiled = summary.AsWasmCompiled();
if (builder.AppendWasmCompiledFrame(wasm_compiled)) {
last_frame_id = StackFrame::NO_ID; last_frame_id = StackFrame::NO_ID;
last_frame_index = 0; last_frame_index = 0;
} }
...@@ -727,8 +734,8 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, ...@@ -727,8 +734,8 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
//==================================================================== //====================================================================
// Handle a WASM interpreted frame. // Handle a WASM interpreted frame.
//==================================================================== //====================================================================
if (builder.AppendWasmInterpretedFrame( auto const& wasm_interpreted = summary.AsWasmInterpreted();
summary.AsWasmInterpreted())) { if (builder.AppendWasmInterpretedFrame(wasm_interpreted)) {
last_frame_id = StackFrame::NO_ID; last_frame_id = StackFrame::NO_ID;
last_frame_index = 0; last_frame_index = 0;
} }
...@@ -762,7 +769,8 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object, ...@@ -762,7 +769,8 @@ Handle<Object> Isolate::CaptureSimpleStackTrace(Handle<JSReceiver> error_object,
FunctionKind const kind = inspector.GetFunction()->shared()->kind(); FunctionKind const kind = inspector.GetFunction()->shared()->kind();
if (IsAsyncGeneratorFunction(kind)) { if (IsAsyncGeneratorFunction(kind)) {
// TODO(bmeurer): Handle async generators here. // TODO(bmeurer): Handle async generators here.
} else if (IsAsyncFunction(kind)) { } else {
DCHECK(IsAsyncFunction(kind));
Handle<Object> const dot_promise = Handle<Object> const dot_promise =
inspector.GetExpression(DeclarationScope::kPromiseVarIndex); inspector.GetExpression(DeclarationScope::kPromiseVarIndex);
if (dot_promise->IsJSPromise()) { if (dot_promise->IsJSPromise()) {
......
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --async-stack-traces
const a = /x/;
a.exec = RegExp.prototype.test;
assertThrows(() => RegExp.prototype.test.call(a));
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --async-stack-traces
assertThrows(_ => '' + {toString: Object.prototype.toLocaleString});
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