Commit c0023946 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] speedup async instrumentation

We use name of the function at the moment of first appearance of given
function in stack trace. Any further name changes would be ignored.
It gives us around 20% speedup.

Perf analysis: https://bit.ly/2wp99vt

R=yangguo@chromium.org,jgruber@chromium.org

Bug: v8:7078
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I9f21f0bd9cd923e5abaeffb9209df0be2f49afff
Reviewed-on: https://chromium-review.googlesource.com/1050984
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53446}
parent b6c9086c
......@@ -1094,7 +1094,9 @@ std::shared_ptr<StackFrame> V8Debugger::symbolize(
frameId = v8::debug::GetStackFrameId(v8Frame);
it = m_framesCache.find(frameId);
}
if (it != m_framesCache.end() && it->second.lock()) return it->second.lock();
if (it != m_framesCache.end() && !it->second.expired()) {
return std::shared_ptr<StackFrame>(it->second);
}
std::shared_ptr<StackFrame> frame(new StackFrame(v8Frame));
// TODO(clemensh): Figure out a way to do this translation only right before
// sending the stack trace over wire.
......
......@@ -23,9 +23,9 @@ std::vector<std::shared_ptr<StackFrame>> toFramesVector(
int maxStackSize) {
DCHECK(debugger->isolate()->InContext());
int frameCount = std::min(v8StackTrace->GetFrameCount(), maxStackSize);
std::vector<std::shared_ptr<StackFrame>> frames;
std::vector<std::shared_ptr<StackFrame>> frames(frameCount);
for (int i = 0; i < frameCount; ++i) {
frames.push_back(debugger->symbolize(v8StackTrace->GetFrame(i)));
frames[i] = debugger->symbolize(v8StackTrace->GetFrame(i));
}
return frames;
}
......
......@@ -769,11 +769,7 @@ class CaptureStackTraceHelper {
if (entry != NumberDictionary::kNotFound) {
Handle<StackFrameInfo> frame(
StackFrameInfo::cast(cache->ValueAt(entry)));
DCHECK(frame->function_name()->IsString());
Handle<String> function_name = summ.FunctionName();
if (function_name->Equals(String::cast(frame->function_name()))) {
return frame;
}
return frame;
}
}
......
......@@ -17066,31 +17066,31 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(origin, "function.name", 2, 24, false, false,
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
stackTrace->GetFrame(0));
} else if (testGroup == kDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(origin, "function.displayName", 2, 24, false, false,
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
stackTrace->GetFrame(0));
} else if (testGroup == kFunctionNameAndDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(origin, "function.displayName", 2, 24, false, false,
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
stackTrace->GetFrame(0));
} else if (testGroup == kDisplayNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(origin, "function.name", 2, 24, false, false,
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
stackTrace->GetFrame(0));
} else if (testGroup == kFunctionNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(origin, "f", 2, 24, false, false, stackTrace->GetFrame(0));
checkStackFrame(nullptr, "", 3, 1, true, false, stackTrace->GetFrame(0));
}
}
......@@ -17157,7 +17157,7 @@ TEST(CaptureStackTrace) {
// Test using function.name and function.displayName in stack trace
const char* function_name_source =
"function bar(function_name, display_name, testGroup) {\n"
" var f = function() { AnalyzeStackInNativeCode(testGroup); };\n"
" var f = new Function(`AnalyzeStackInNativeCode(${testGroup});`);\n"
" if (function_name) {\n"
" Object.defineProperty(f, 'name', { value: function_name });\n"
" }\n"
......
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