Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 m_taskWithScheduledBreak = nullptr; | 967 m_taskWithScheduledBreak = nullptr; |
| 968 } | 968 } |
| 969 | 969 |
| 970 void V8Debugger::allAsyncTasksCanceled() { | 970 void V8Debugger::allAsyncTasksCanceled() { |
| 971 m_asyncTaskStacks.clear(); | 971 m_asyncTaskStacks.clear(); |
| 972 m_recurringTasks.clear(); | 972 m_recurringTasks.clear(); |
| 973 m_currentAsyncParent.clear(); | 973 m_currentAsyncParent.clear(); |
| 974 m_currentAsyncCreation.clear(); | 974 m_currentAsyncCreation.clear(); |
| 975 m_currentTasks.clear(); | 975 m_currentTasks.clear(); |
| 976 m_parentTask.clear(); | 976 m_parentTask.clear(); |
| 977 m_asyncTaskCreationStacks.clear(); | 977 m_asyncTaskCreationStacks.clear(); |
|
dgozman
2017/04/19 20:29:04
Let's cleanup frames cache here as well.
kozy
2017/04/20 00:06:49
Done.
| |
| 978 | 978 |
| 979 m_allAsyncStacks.clear(); | 979 m_allAsyncStacks.clear(); |
| 980 m_asyncStacksCount = 0; | 980 m_asyncStacksCount = 0; |
| 981 } | 981 } |
| 982 | 982 |
| 983 void V8Debugger::muteScriptParsedEvents() { | 983 void V8Debugger::muteScriptParsedEvents() { |
| 984 ++m_ignoreScriptParsedEventsCounter; | 984 ++m_ignoreScriptParsedEventsCounter; |
| 985 } | 985 } |
| 986 | 986 |
| 987 void V8Debugger::unmuteScriptParsedEvents() { | 987 void V8Debugger::unmuteScriptParsedEvents() { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 if (m_asyncTaskStacks.find(task) == m_asyncTaskStacks.end()) continue; | 1024 if (m_asyncTaskStacks.find(task) == m_asyncTaskStacks.end()) continue; |
| 1025 recurringLeft.insert(task); | 1025 recurringLeft.insert(task); |
| 1026 } | 1026 } |
| 1027 m_recurringTasks.swap(recurringLeft); | 1027 m_recurringTasks.swap(recurringLeft); |
| 1028 protocol::HashMap<void*, void*> parentLeft; | 1028 protocol::HashMap<void*, void*> parentLeft; |
| 1029 for (auto it : m_parentTask) { | 1029 for (auto it : m_parentTask) { |
| 1030 if (m_asyncTaskStacks.find(it.first) == m_asyncTaskStacks.end()) continue; | 1030 if (m_asyncTaskStacks.find(it.first) == m_asyncTaskStacks.end()) continue; |
| 1031 parentLeft.insert(it); | 1031 parentLeft.insert(it); |
| 1032 } | 1032 } |
| 1033 m_parentTask.swap(parentLeft); | 1033 m_parentTask.swap(parentLeft); |
| 1034 std::map<int, std::weak_ptr<StackFrame>> framesCache; | |
| 1035 for (auto it : m_framesCache) { | |
| 1036 if (!it.second.expired()) framesCache.insert(it); | |
| 1037 } | |
| 1038 m_framesCache.swap(framesCache); | |
| 1034 } | 1039 } |
| 1035 | 1040 |
| 1036 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { | 1041 void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { |
| 1037 AsyncTaskToStackTrace cleanCopy; | 1042 AsyncTaskToStackTrace cleanCopy; |
| 1038 for (auto it : map) { | 1043 for (auto it : map) { |
| 1039 if (!it.second.expired()) cleanCopy.insert(it); | 1044 if (!it.second.expired()) cleanCopy.insert(it); |
| 1040 } | 1045 } |
| 1041 map.swap(cleanCopy); | 1046 map.swap(cleanCopy); |
| 1042 } | 1047 } |
| 1043 | 1048 |
| 1049 std::shared_ptr<StackFrame> V8Debugger::lookupFrame(int frameId) { | |
| 1050 auto it = m_framesCache.find(frameId); | |
| 1051 if (it != m_framesCache.end()) return it->second.lock(); | |
| 1052 return nullptr; | |
| 1053 } | |
| 1054 | |
| 1055 void V8Debugger::storeFrame(int frameId, std::shared_ptr<StackFrame> frame) { | |
| 1056 m_framesCache[frameId] = frame; | |
| 1057 } | |
| 1058 | |
| 1044 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) { | 1059 void V8Debugger::setMaxAsyncTaskStacksForTest(int limit) { |
| 1045 m_maxAsyncCallStacks = 0; | 1060 m_maxAsyncCallStacks = 0; |
| 1046 collectOldAsyncStacksIfNeeded(); | 1061 collectOldAsyncStacksIfNeeded(); |
| 1047 m_maxAsyncCallStacks = limit; | 1062 m_maxAsyncCallStacks = limit; |
| 1048 } | 1063 } |
| 1049 | 1064 |
| 1050 } // namespace v8_inspector | 1065 } // namespace v8_inspector |
| OLD | NEW |