Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/inspector/v8-debugger.cc

Issue 2825903002: [inspector] deduplicate stack frames (Closed)
Patch Set: addressed comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-stack-trace-impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/v8-debugger.h" 5 #include "src/inspector/v8-debugger.h"
6 6
7 #include "src/inspector/debugger-script.h" 7 #include "src/inspector/debugger-script.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/script-breakpoint.h" 10 #include "src/inspector/script-breakpoint.h"
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 968
969 void V8Debugger::allAsyncTasksCanceled() { 969 void V8Debugger::allAsyncTasksCanceled() {
970 m_asyncTaskStacks.clear(); 970 m_asyncTaskStacks.clear();
971 m_recurringTasks.clear(); 971 m_recurringTasks.clear();
972 m_currentAsyncParent.clear(); 972 m_currentAsyncParent.clear();
973 m_currentAsyncCreation.clear(); 973 m_currentAsyncCreation.clear();
974 m_currentTasks.clear(); 974 m_currentTasks.clear();
975 m_parentTask.clear(); 975 m_parentTask.clear();
976 m_asyncTaskCreationStacks.clear(); 976 m_asyncTaskCreationStacks.clear();
977 977
978 m_framesCache.clear();
978 m_allAsyncStacks.clear(); 979 m_allAsyncStacks.clear();
979 m_asyncStacksCount = 0; 980 m_asyncStacksCount = 0;
980 } 981 }
981 982
982 void V8Debugger::muteScriptParsedEvents() { 983 void V8Debugger::muteScriptParsedEvents() {
983 ++m_ignoreScriptParsedEventsCounter; 984 ++m_ignoreScriptParsedEventsCounter;
984 } 985 }
985 986
986 void V8Debugger::unmuteScriptParsedEvents() { 987 void V8Debugger::unmuteScriptParsedEvents() {
987 --m_ignoreScriptParsedEventsCounter; 988 --m_ignoreScriptParsedEventsCounter;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 m_recurringTasks.swap(recurringLeft); 1027 m_recurringTasks.swap(recurringLeft);
1027 protocol::HashMap<void*, void*> parentLeft; 1028 protocol::HashMap<void*, void*> parentLeft;
1028 for (auto it : m_parentTask) { 1029 for (auto it : m_parentTask) {
1029 if (m_asyncTaskCreationStacks.find(it.second) == 1030 if (m_asyncTaskCreationStacks.find(it.second) ==
1030 m_asyncTaskCreationStacks.end()) { 1031 m_asyncTaskCreationStacks.end()) {
1031 continue; 1032 continue;
1032 } 1033 }
1033 parentLeft.insert(it); 1034 parentLeft.insert(it);
1034 } 1035 }
1035 m_parentTask.swap(parentLeft); 1036 m_parentTask.swap(parentLeft);
1037 std::map<int, std::weak_ptr<StackFrame>> framesCache;
1038 for (auto it : m_framesCache) {
1039 if (!it.second.expired()) framesCache.insert(it);
1040 }
1041 m_framesCache.swap(framesCache);
1036 } 1042 }
1037 1043
1038 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { 1044 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) {
1039 AsyncTaskToStackTrace cleanCopy; 1045 AsyncTaskToStackTrace cleanCopy;
1040 for (auto it : map) { 1046 for (auto it : map) {
1041 if (!it.second.expired()) cleanCopy.insert(it); 1047 if (!it.second.expired()) cleanCopy.insert(it);
1042 } 1048 }
1043 map.swap(cleanCopy); 1049 map.swap(cleanCopy);
1044 } 1050 }
1045 1051
1052 std::shared_ptr<StackFrame> V8Debugger::symbolize(
1053 v8::Local<v8::StackFrame> v8Frame) {
1054 auto it = m_framesCache.end();
1055 int frameId = 0;
1056 if (m_maxAsyncCallStackDepth) {
1057 frameId = v8::debug::GetStackFrameId(v8Frame);
1058 it = m_framesCache.find(frameId);
1059 }
1060 if (it != m_framesCache.end() && it->second.lock()) return it->second.lock();
1061 std::shared_ptr<StackFrame> frame(new StackFrame(v8Frame));
1062 // TODO(clemensh): Figure out a way to do this translation only right before
1063 // sending the stack trace over wire.
1064 if (v8Frame->IsWasm()) frame->translate(&m_wasmTranslation);
1065 if (m_maxAsyncCallStackDepth) {
1066 m_framesCache[frameId] = frame;
1067 }
1068 return frame;
1069 }
1070
1046 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) { 1071 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) {
1047 m_maxAsyncCallStacks = 0; 1072 m_maxAsyncCallStacks = 0;
1048 collectOldAsyncStacksIfNeeded(); 1073 collectOldAsyncStacksIfNeeded();
1049 m_maxAsyncCallStacks = limit; 1074 m_maxAsyncCallStacks = limit;
1050 } 1075 }
1051 1076
1052 void V8Debugger::dumpAsyncTaskStacksStateForTest() { 1077 void V8Debugger::dumpAsyncTaskStacksStateForTest() {
1053 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount); 1078 fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
1054 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size()); 1079 fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
1055 fprintf(stdout, "Created async tasks: %zu\n", 1080 fprintf(stdout, "Created async tasks: %zu\n",
1056 m_asyncTaskCreationStacks.size()); 1081 m_asyncTaskCreationStacks.size());
1057 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size()); 1082 fprintf(stdout, "Async tasks with parent: %zu\n", m_parentTask.size());
1058 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size()); 1083 fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
1059 fprintf(stdout, "\n"); 1084 fprintf(stdout, "\n");
1060 } 1085 }
1061 1086
1062 } // namespace v8_inspector 1087 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | src/inspector/v8-stack-trace-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698