Commit d1ba8c85 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] cleanup all task related data when limit reached

- and reduce limit to 128 * 1024.

BUG=v8:6189
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2824293002
Cr-Commit-Position: refs/heads/master@{#44735}
parent 5806d862
...@@ -21,7 +21,7 @@ namespace v8_inspector { ...@@ -21,7 +21,7 @@ namespace v8_inspector {
namespace { namespace {
static const int kMaxAsyncTaskStacks = 1024 * 1024; static const int kMaxAsyncTaskStacks = 128 * 1024;
inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) { inline v8::Local<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) {
return value ? v8::True(isolate) : v8::False(isolate); return value ? v8::True(isolate) : v8::False(isolate);
...@@ -851,7 +851,7 @@ void V8Debugger::asyncTaskCreatedForStack(void* task, void* parentTask) { ...@@ -851,7 +851,7 @@ void V8Debugger::asyncTaskCreatedForStack(void* task, void* parentTask) {
// Passing one as maxStackSize forces no async chain for the new stack. // Passing one as maxStackSize forces no async chain for the new stack.
if (asyncCreation && !asyncCreation->isEmpty()) { if (asyncCreation && !asyncCreation->isEmpty()) {
m_asyncTaskCreationStacks[task] = asyncCreation; m_asyncTaskCreationStacks[task] = asyncCreation;
m_allAsyncStacks.push_back(asyncCreation); m_allAsyncStacks.push_back(std::move(asyncCreation));
++m_asyncStacksCount; ++m_asyncStacksCount;
collectOldAsyncStacksIfNeeded(); collectOldAsyncStacksIfNeeded();
} }
...@@ -888,8 +888,7 @@ void V8Debugger::asyncTaskScheduledForStack(const String16& taskName, ...@@ -888,8 +888,7 @@ void V8Debugger::asyncTaskScheduledForStack(const String16& taskName,
if (asyncStack) { if (asyncStack) {
m_asyncTaskStacks[task] = asyncStack; m_asyncTaskStacks[task] = asyncStack;
if (recurring) m_recurringTasks.insert(task); if (recurring) m_recurringTasks.insert(task);
m_allAsyncStacks.push_back(std::move(asyncStack));
m_allAsyncStacks.push_back(asyncStack);
++m_asyncStacksCount; ++m_asyncStacksCount;
collectOldAsyncStacksIfNeeded(); collectOldAsyncStacksIfNeeded();
} }
...@@ -916,15 +915,15 @@ void V8Debugger::asyncTaskStartedForStack(void* task) { ...@@ -916,15 +915,15 @@ void V8Debugger::asyncTaskStartedForStack(void* task) {
// - asyncTaskCanceled <-- canceled before finished // - asyncTaskCanceled <-- canceled before finished
// <-- async stack requested here --> // <-- async stack requested here -->
// - asyncTaskFinished // - asyncTaskFinished
std::shared_ptr<AsyncStackTrace> asyncParent; std::weak_ptr<AsyncStackTrace> asyncParent;
if (stackIt != m_asyncTaskStacks.end()) asyncParent = stackIt->second.lock(); if (stackIt != m_asyncTaskStacks.end()) asyncParent = stackIt->second;
auto itCreation = m_asyncTaskCreationStacks.find(task); auto itCreation = m_asyncTaskCreationStacks.find(task);
if (asyncParent && itCreation != m_asyncTaskCreationStacks.end()) { if (asyncParent.lock() && itCreation != m_asyncTaskCreationStacks.end()) {
m_currentAsyncCreation.push_back(itCreation->second.lock()); m_currentAsyncCreation.push_back(itCreation->second.lock());
} else { } else {
m_currentAsyncCreation.push_back(nullptr); m_currentAsyncCreation.emplace_back();
} }
m_currentAsyncParent.push_back(asyncParent); m_currentAsyncParent.push_back(asyncParent.lock());
} }
void V8Debugger::asyncTaskFinishedForStack(void* task) { void V8Debugger::asyncTaskFinishedForStack(void* task) {
...@@ -1023,6 +1022,20 @@ void V8Debugger::collectOldAsyncStacksIfNeeded() { ...@@ -1023,6 +1022,20 @@ void V8Debugger::collectOldAsyncStacksIfNeeded() {
} }
removeOldAsyncTasks(m_asyncTaskStacks); removeOldAsyncTasks(m_asyncTaskStacks);
removeOldAsyncTasks(m_asyncTaskCreationStacks); removeOldAsyncTasks(m_asyncTaskCreationStacks);
protocol::HashSet<void*> recurringLeft;
for (auto task : m_recurringTasks) {
if (m_asyncTaskStacks.find(task) == m_asyncTaskStacks.end()) continue;
recurringLeft.insert(task);
}
m_recurringTasks.swap(recurringLeft);
protocol::HashMap<void*, void*> parentLeft;
for (auto it : m_parentTask) {
if (m_asyncTaskCreationStacks.find(it.second) == m_asyncTaskStacks.end()) {
continue;
}
parentLeft.insert(it);
}
m_parentTask.swap(parentLeft);
} }
void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) { void V8Debugger::removeOldAsyncTasks(AsyncTaskToStackTrace& map) {
......
...@@ -185,8 +185,10 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -185,8 +185,10 @@ class V8Debugger : public v8::debug::DebugDelegate {
protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>; protocol::HashMap<void*, std::weak_ptr<AsyncStackTrace>>;
AsyncTaskToStackTrace m_asyncTaskStacks; AsyncTaskToStackTrace m_asyncTaskStacks;
AsyncTaskToStackTrace m_asyncTaskCreationStacks; AsyncTaskToStackTrace m_asyncTaskCreationStacks;
int m_maxAsyncCallStacks;
protocol::HashSet<void*> m_recurringTasks; protocol::HashSet<void*> m_recurringTasks;
protocol::HashMap<void*, void*> m_parentTask;
int m_maxAsyncCallStacks;
int m_maxAsyncCallStackDepth; int m_maxAsyncCallStackDepth;
std::vector<void*> m_currentTasks; std::vector<void*> m_currentTasks;
...@@ -201,8 +203,6 @@ class V8Debugger : public v8::debug::DebugDelegate { ...@@ -201,8 +203,6 @@ class V8Debugger : public v8::debug::DebugDelegate {
std::list<std::shared_ptr<AsyncStackTrace>> m_allAsyncStacks; std::list<std::shared_ptr<AsyncStackTrace>> m_allAsyncStacks;
protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap; protocol::HashMap<V8DebuggerAgentImpl*, int> m_maxAsyncCallStackDepthMap;
protocol::HashMap<void*, void*> m_parentTask;
protocol::HashMap<void*, void*> m_firstNextTask;
void* m_taskWithScheduledBreak = nullptr; void* m_taskWithScheduledBreak = nullptr;
std::unique_ptr<ScheduleStepIntoAsyncCallback> m_stepIntoAsyncCallback; std::unique_ptr<ScheduleStepIntoAsyncCallback> m_stepIntoAsyncCallback;
......
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