Commit debf0896 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by V8 LUCI CQ

[inspector] Remove redundant `V8Debugger::m_asyncStacksCount`.

There's no point in maintaining a separate counter for the size of a
`std::list`. Also changing the type to `size_t` consistently.

Bug: chromium:1257637
Change-Id: I4f938b9888bb09cd1223ae6b6ae1db0fa1181096
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3220332
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Jaroslav Sevcik <jarin@chromium.org>
Auto-Submit: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77376}
parent 17e0ac9a
......@@ -23,7 +23,7 @@ namespace v8_inspector {
namespace {
static const int kMaxAsyncTaskStacks = 8 * 1024;
static const size_t kMaxAsyncTaskStacks = 8 * 1024;
static const int kNoBreakpointId = 0;
template <typename Map>
......@@ -914,7 +914,6 @@ V8StackTraceId V8Debugger::storeCurrentStackTrace(
uintptr_t id = AsyncStackTrace::store(this, asyncStack);
m_allAsyncStacks.push_back(std::move(asyncStack));
++m_asyncStacksCount;
collectOldAsyncStacksIfNeeded();
bool shouldPause =
......@@ -993,7 +992,6 @@ void V8Debugger::asyncTaskScheduledForStack(const String16& taskName,
m_asyncTaskStacks[task] = asyncStack;
if (recurring) m_recurringTasks.insert(task);
m_allAsyncStacks.push_back(std::move(asyncStack));
++m_asyncStacksCount;
collectOldAsyncStacksIfNeeded();
}
}
......@@ -1080,7 +1078,6 @@ void V8Debugger::allAsyncTasksCanceled() {
m_currentTasks.clear();
m_allAsyncStacks.clear();
m_asyncStacksCount = 0;
}
void V8Debugger::muteScriptParsedEvents() {
......@@ -1120,12 +1117,11 @@ int V8Debugger::currentContextGroupId() {
}
void V8Debugger::collectOldAsyncStacksIfNeeded() {
if (m_asyncStacksCount <= m_maxAsyncCallStacks) return;
int halfOfLimitRoundedUp =
if (m_allAsyncStacks.size() <= m_maxAsyncCallStacks) return;
size_t halfOfLimitRoundedUp =
m_maxAsyncCallStacks / 2 + m_maxAsyncCallStacks % 2;
while (m_asyncStacksCount > halfOfLimitRoundedUp) {
while (m_allAsyncStacks.size() > halfOfLimitRoundedUp) {
m_allAsyncStacks.pop_front();
--m_asyncStacksCount;
}
cleanupExpiredWeakPointers(m_asyncTaskStacks);
cleanupExpiredWeakPointers(m_storedStackTraces);
......@@ -1169,7 +1165,7 @@ bool V8Debugger::addInternalObject(v8::Local<v8::Context> context,
}
void V8Debugger::dumpAsyncTaskStacksStateForTest() {
fprintf(stdout, "Async stacks count: %d\n", m_asyncStacksCount);
fprintf(stdout, "Async stacks count: %zu\n", m_allAsyncStacks.size());
fprintf(stdout, "Scheduled async tasks: %zu\n", m_asyncTaskStacks.size());
fprintf(stdout, "Recurring async tasks: %zu\n", m_recurringTasks.size());
fprintf(stdout, "\n");
......
......@@ -215,7 +215,7 @@ class V8Debugger : public v8::debug::DebugDelegate,
AsyncTaskToStackTrace m_asyncTaskStacks;
std::unordered_set<void*> m_recurringTasks;
int m_maxAsyncCallStacks;
size_t m_maxAsyncCallStacks;
int m_maxAsyncCallStackDepth;
std::vector<void*> m_currentTasks;
......@@ -223,7 +223,6 @@ class V8Debugger : public v8::debug::DebugDelegate,
std::vector<V8StackTraceId> m_currentExternalParent;
void collectOldAsyncStacksIfNeeded();
int m_asyncStacksCount = 0;
// V8Debugger owns all the async stacks, while most of the other references
// are weak, which allows to collect some stacks when there are too many.
std::list<std::shared_ptr<AsyncStackTrace>> m_allAsyncStacks;
......
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