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

Unified Diff: third_party/WebKit/Source/platform/heap/Heap.cpp

Issue 2697703005: Remove ThreadHeap::m_threads (Closed)
Patch Set: temp Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/heap/Heap.cpp
diff --git a/third_party/WebKit/Source/platform/heap/Heap.cpp b/third_party/WebKit/Source/platform/heap/Heap.cpp
index 97ce82652ee13f4f0faa6d619a769c9dda901936..e0b5cb80ec238d28fcb9ab05fb363996602e8b87 100644
--- a/third_party/WebKit/Source/platform/heap/Heap.cpp
+++ b/third_party/WebKit/Source/platform/heap/Heap.cpp
@@ -145,8 +145,9 @@ void ThreadHeapStats::decreaseAllocatedSpace(size_t delta) {
ProcessHeap::decreaseTotalAllocatedSpace(delta);
}
-ThreadHeap::ThreadHeap()
- : m_regionTree(WTF::makeUnique<RegionTree>()),
+ThreadHeap::ThreadHeap(ThreadState* threadState)
+ : m_threadState(threadState),
+ m_regionTree(WTF::makeUnique<RegionTree>()),
m_heapDoesNotContainCache(WTF::wrapUnique(new HeapDoesNotContainCache)),
m_freePagePool(WTF::wrapUnique(new PagePool)),
m_markingStack(CallbackStack::create()),
@@ -160,41 +161,9 @@ ThreadHeap::ThreadHeap()
ThreadHeap::~ThreadHeap() {
}
-void ThreadHeap::attach(ThreadState* thread) {
- MutexLocker locker(m_threadAttachMutex);
- m_threads.insert(thread);
-}
-
-void ThreadHeap::detach(ThreadState* thread) {
- ASSERT(ThreadState::current() == thread);
- bool isLastThread = false;
- {
- // Grab the threadAttachMutex to ensure only one thread can shutdown at
- // a time and that no other thread can do a global GC. It also allows
- // safe iteration of the m_threads set which happens as part of
- // thread local GC asserts. We enter a safepoint while waiting for the
- // lock to avoid a dead-lock where another thread has already requested
- // GC.
- MutexLocker locker(m_threadAttachMutex);
- thread->runTerminationGC();
- ASSERT(m_threads.contains(thread));
- m_threads.erase(thread);
- isLastThread = m_threads.isEmpty();
- }
- if (thread->isMainThread())
- DCHECK_EQ(heapStats().allocatedSpace(), 0u);
- if (isLastThread)
- delete this;
-}
-
#if DCHECK_IS_ON()
BasePage* ThreadHeap::findPageFromAddress(Address address) {
- MutexLocker locker(m_threadAttachMutex);
- for (ThreadState* state : m_threads) {
- if (BasePage* page = state->findPageFromAddress(address))
- return page;
- }
- return nullptr;
+ return m_threadState->findPageFromAddress(address);
}
#endif
@@ -346,19 +315,16 @@ void ThreadHeap::decommitCallbackStacks() {
void ThreadHeap::preGC() {
ASSERT(!ThreadState::current()->isInGC());
- for (ThreadState* state : m_threads)
- state->preGC();
+ m_threadState->preGC();
}
void ThreadHeap::postGC(BlinkGC::GCType gcType) {
ASSERT(ThreadState::current()->isInGC());
- for (ThreadState* state : m_threads)
- state->postGC(gcType);
+ m_threadState->postGC(gcType);
}
void ThreadHeap::preSweep(BlinkGC::GCType gcType) {
- for (ThreadState* state : m_threads)
- state->preSweep(gcType);
+ m_threadState->preSweep(gcType);
}
void ThreadHeap::processMarkingStack(Visitor* visitor) {
@@ -510,15 +476,12 @@ void ThreadHeap::reportMemoryUsageForTracing() {
}
size_t ThreadHeap::objectPayloadSizeForTesting() {
- // MEMO: is threadAttachMutex locked?
size_t objectPayloadSize = 0;
- for (ThreadState* state : m_threads) {
- state->setGCState(ThreadState::GCRunning);
- state->makeConsistentForGC();
- objectPayloadSize += state->objectPayloadSizeForTesting();
- state->setGCState(ThreadState::Sweeping);
- state->setGCState(ThreadState::NoGCScheduled);
- }
+ m_threadState->setGCState(ThreadState::GCRunning);
+ m_threadState->makeConsistentForGC();
+ objectPayloadSize += m_threadState->objectPayloadSizeForTesting();
+ m_threadState->setGCState(ThreadState::Sweeping);
+ m_threadState->setGCState(ThreadState::NoGCScheduled);
return objectPayloadSize;
}
@@ -527,15 +490,13 @@ void ThreadHeap::visitPersistentRoots(Visitor* visitor) {
TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots");
ProcessHeap::crossThreadPersistentRegion().tracePersistentNodes(visitor);
- for (ThreadState* state : m_threads)
- state->visitPersistents(visitor);
+ m_threadState->visitPersistents(visitor);
}
void ThreadHeap::visitStackRoots(Visitor* visitor) {
ASSERT(ThreadState::current()->isInGC());
TRACE_EVENT0("blink_gc", "ThreadHeap::visitStackRoots");
- for (ThreadState* state : m_threads)
- state->visitStack(visitor);
+ m_threadState->visitStack(visitor);
}
BasePage* ThreadHeap::lookupPageForAddress(Address address) {
@@ -555,8 +516,7 @@ void ThreadHeap::resetHeapCounters() {
ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize());
m_stats.reset();
- for (ThreadState* state : m_threads)
- state->resetHeapCounters();
+ m_threadState->resetHeapCounters();
}
ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr;
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.h ('k') | third_party/WebKit/Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698