Commit 6422f3b2 authored by haraken's avatar haraken Committed by Commit bot

HeapCompact doesn't need to support multiple threads

Now that the per-thread heaps have been shipped, HeapCompact no longer needs to
support multiple threads. This CL removes that code.

BUG=671856

Review-Url: https://codereview.chromium.org/2633463006
Cr-Commit-Position: refs/heads/master@{#443542}
parent 989dace1
...@@ -253,7 +253,6 @@ class HeapCompact::MovableObjectFixups final { ...@@ -253,7 +253,6 @@ class HeapCompact::MovableObjectFixups final {
HeapCompact::HeapCompact() HeapCompact::HeapCompact()
: m_doCompact(false), : m_doCompact(false),
m_gcCountSinceLastCompaction(0), m_gcCountSinceLastCompaction(0),
m_threadCount(0),
m_freeListSize(0), m_freeListSize(0),
m_compactableArenas(0u), m_compactableArenas(0u),
m_freedPages(0), m_freedPages(0),
...@@ -346,7 +345,6 @@ void HeapCompact::initialize(ThreadState* state) { ...@@ -346,7 +345,6 @@ void HeapCompact::initialize(ThreadState* state) {
m_doCompact = true; m_doCompact = true;
m_freedPages = 0; m_freedPages = 0;
m_freedSize = 0; m_freedSize = 0;
m_threadCount = state->heap().threads().size();
m_fixups.reset(); m_fixups.reset();
m_gcCountSinceLastCompaction = 0; m_gcCountSinceLastCompaction = 0;
s_forceCompactionGC = false; s_forceCompactionGC = false;
...@@ -418,7 +416,6 @@ void HeapCompact::startThreadCompaction() { ...@@ -418,7 +416,6 @@ void HeapCompact::startThreadCompaction() {
if (!m_doCompact) if (!m_doCompact)
return; return;
MutexLocker locker(m_mutex);
if (!m_startCompactionTimeMS) if (!m_startCompactionTimeMS)
m_startCompactionTimeMS = WTF::currentTimeMS(); m_startCompactionTimeMS = WTF::currentTimeMS();
} }
...@@ -427,48 +424,32 @@ void HeapCompact::finishThreadCompaction() { ...@@ -427,48 +424,32 @@ void HeapCompact::finishThreadCompaction() {
if (!m_doCompact) if (!m_doCompact)
return; return;
MutexLocker locker(m_mutex);
// Final one clears out.
if (!--m_threadCount) {
#if DEBUG_HEAP_COMPACTION #if DEBUG_HEAP_COMPACTION
if (m_fixups) if (m_fixups)
m_fixups->dumpDebugStats(); m_fixups->dumpDebugStats();
#endif #endif
m_fixups.reset(); m_fixups.reset();
m_doCompact = false; m_doCompact = false;
double timeForHeapCompaction = double timeForHeapCompaction = WTF::currentTimeMS() - m_startCompactionTimeMS;
WTF::currentTimeMS() - m_startCompactionTimeMS; DEFINE_STATIC_LOCAL(CustomCountHistogram, timeForHeapCompactionHistogram,
DEFINE_STATIC_LOCAL(CustomCountHistogram, timeForHeapCompactionHistogram, ("BlinkGC.TimeForHeapCompaction", 1, 10 * 1000, 50));
("BlinkGC.TimeForHeapCompaction", 1, 10 * 1000, 50)); timeForHeapCompactionHistogram.count(timeForHeapCompaction);
timeForHeapCompactionHistogram.count(timeForHeapCompaction); m_startCompactionTimeMS = 0;
m_startCompactionTimeMS = 0;
DEFINE_STATIC_LOCAL( DEFINE_STATIC_LOCAL(
CustomCountHistogram, objectSizeFreedByHeapCompaction, CustomCountHistogram, objectSizeFreedByHeapCompaction,
("BlinkGC.ObjectSizeFreedByHeapCompaction", 1, 4 * 1024 * 1024, 50)); ("BlinkGC.ObjectSizeFreedByHeapCompaction", 1, 4 * 1024 * 1024, 50));
objectSizeFreedByHeapCompaction.count(m_freedSize / 1024); objectSizeFreedByHeapCompaction.count(m_freedSize / 1024);
#if DEBUG_LOG_HEAP_COMPACTION_RUNNING_TIME #if DEBUG_LOG_HEAP_COMPACTION_RUNNING_TIME
LOG_HEAP_COMPACTION_INTERNAL( LOG_HEAP_COMPACTION_INTERNAL(
"Compaction stats: time=%gms, pages freed=%zu, size=%zu\n", "Compaction stats: time=%gms, pages freed=%zu, size=%zu\n",
timeForHeapCompaction, m_freedPages, m_freedSize); timeForHeapCompaction, m_freedPages, m_freedSize);
#else #else
LOG_HEAP_COMPACTION("Compaction stats: freed pages=%zu size=%zu\n", LOG_HEAP_COMPACTION("Compaction stats: freed pages=%zu size=%zu\n",
m_freedPages, m_freedSize); m_freedPages, m_freedSize);
#endif #endif
// Compaction has been completed by all participating threads, unblock
// them all.
m_finished.broadcast();
} else {
// Letting a thread return here and let it exit its safe point opens up
// the possibility of it accessing heaps of other threads that are
// still being compacted. It is not in a valid state until objects have
// all been moved together, hence all GC-participating threads must
// complete compaction together. Grab the condition variable and wait.
m_finished.wait(m_mutex);
}
} }
void HeapCompact::addCompactingPage(BasePage* page) { void HeapCompact::addCompactingPage(BasePage* page) {
......
...@@ -139,18 +139,6 @@ class PLATFORM_EXPORT HeapCompact final { ...@@ -139,18 +139,6 @@ class PLATFORM_EXPORT HeapCompact final {
bool m_doCompact; bool m_doCompact;
size_t m_gcCountSinceLastCompaction; size_t m_gcCountSinceLastCompaction;
// Lock protecting finishedThreadCompaction() signalling.
Mutex m_mutex;
// All threads performing a GC must synchronize on completion
// of all heap compactions. Not doing so risks one thread resuming
// the mutator, which could perform cross-thread access to a heap
// that's still in the process of being compacted.
ThreadCondition m_finished;
// Number of heap threads participating in the compaction.
int m_threadCount;
// Last reported freelist size, across all compactable arenas. // Last reported freelist size, across all compactable arenas.
size_t m_freeListSize; size_t m_freeListSize;
......
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