Commit d3fd6d25 authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Speed up StackTraceFrame::GetFileName()

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.

This is necessary to switch AdTagging over from using
GetScriptNameOrSourceURL() to GetScriptName(), to ensure that scripts
with source urls are tagged appropriately. (See crrev.com/c/2551259.)

Bug: chromium:1127391
Change-Id: I6eb145b88c26deb1a088f038b0f8b377bc8fe3ab
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2550504Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71318}
parent 794c2305
......@@ -78,8 +78,20 @@ int StackTraceFrame::GetWasmFunctionIndex(Handle<StackTraceFrame> frame) {
// static
Handle<Object> StackTraceFrame::GetFileName(Handle<StackTraceFrame> frame) {
auto name = GetFrameInfo(frame)->script_name();
return handle(name, frame->GetIsolate());
Isolate* isolate = frame->GetIsolate();
// Use FrameInfo if it's already there, but avoid initializing it for just
// the file name, as it is much more expensive than just getting this
// directly. See GetScriptNameOrSourceUrl() for more detail.
if (!frame->frame_info().IsUndefined()) {
auto name = GetFrameInfo(frame)->script_name();
return handle(name, isolate);
}
FrameArrayIterator it(isolate,
handle(FrameArray::cast(frame->frame_array()), isolate),
frame->frame_index());
DCHECK(it.HasFrame());
return it.Frame()->GetFileName();
}
// 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