Commit 76e9ddb8 authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Speed up StackTraceFrame::GetScriptId()

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. This matches current behavior of GetScriptNameOrSourceURL()
and is a workaround until a dedicated API is available.

Bug: chromium:1098530
Change-Id: I181dc7feeebaf2f45758bbd29be24ab036e44b19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2261736Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68543}
parent 0895c903
......@@ -42,7 +42,21 @@ int StackTraceFrame::GetOneBasedColumnNumber(Handle<StackTraceFrame> frame) {
// static
int StackTraceFrame::GetScriptId(Handle<StackTraceFrame> frame) {
int id = GetFrameInfo(frame)->script_id();
Isolate* isolate = frame->GetIsolate();
// Use FrameInfo if it's already there, but avoid initializing it for just
// the script id, as it is much more expensive than just getting this
// directly. See GetScriptNameOrSourceUrl() for more detail.
int id;
if (!frame->frame_info().IsUndefined()) {
id = GetFrameInfo(frame)->script_id();
} else {
FrameArrayIterator it(
isolate, handle(FrameArray::cast(frame->frame_array()), isolate),
frame->frame_index());
DCHECK(it.HasFrame());
id = it.Frame()->GetScriptId();
}
return id != StackFrameBase::kNone ? id : Message::kNoScriptIdInfo;
}
......
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