Commit 8f965daa authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Speed up StackTraceFrame::GetScriptNameOrSourceUrl()

This retrieves script name directly from StackFrameBase, bypassing
building of StackFrameInfo if one hasn't already been initialized,
thus avoiding computation of expensive properties that are not
required.

Bug: chromium:1057211
Change-Id: I91eaecdbaee6f5834a02d70e2df872e82998ab83
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2080663
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66600}
parent 3b08dce3
......@@ -71,8 +71,23 @@ Handle<Object> StackTraceFrame::GetFileName(Handle<StackTraceFrame> frame) {
// static
Handle<Object> StackTraceFrame::GetScriptNameOrSourceUrl(
Handle<StackTraceFrame> frame) {
auto name = GetFrameInfo(frame)->script_name_or_source_url();
return handle(name, frame->GetIsolate());
Isolate* isolate = frame->GetIsolate();
// TODO(caseq, szuend): the logic below is a workaround for crbug.com/1057211.
// We should probably have a dedicated API for the scenario described in the
// bug above and make getters of this class behave consistently.
// See https://bit.ly/2wkbuIy for further discussion.
// Use FrameInfo if it's already there, but avoid initializing it for just
// the script name, as it is much more expensive than just getting this
// directly.
if (!frame->frame_info().IsUndefined()) {
auto name = GetFrameInfo(frame)->script_name_or_source_url();
return handle(name, isolate);
}
FrameArrayIterator it(isolate,
handle(FrameArray::cast(frame->frame_array()), isolate),
frame->frame_index());
DCHECK(it.HasFrame());
return it.Frame()->GetScriptNameOrSourceUrl();
}
// static
......
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