diff options
Diffstat (limited to 'Source/JavaScriptCore/heap')
-rw-r--r-- | Source/JavaScriptCore/heap/BlockAllocator.cpp | 28 | ||||
-rw-r--r-- | Source/JavaScriptCore/heap/HeapStatistics.cpp | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/heap/HeapStatistics.h | 1 |
3 files changed, 12 insertions, 23 deletions
diff --git a/Source/JavaScriptCore/heap/BlockAllocator.cpp b/Source/JavaScriptCore/heap/BlockAllocator.cpp index 9a2e0bf60..16f607396 100644 --- a/Source/JavaScriptCore/heap/BlockAllocator.cpp +++ b/Source/JavaScriptCore/heap/BlockAllocator.cpp @@ -102,6 +102,7 @@ void BlockAllocator::blockFreeingThreadStartFunc(void* blockAllocator) void BlockAllocator::blockFreeingThreadMain() { + size_t currentNumberOfEmptyRegions; while (!m_blockFreeingThreadShouldQuit) { // Generally wait for one second before scavenging free blocks. This // may return early, particularly when we're being asked to quit. @@ -114,12 +115,17 @@ void BlockAllocator::blockFreeingThreadMain() continue; } - // Now process the list of free blocks. Keep freeing until half of the - // blocks that are currently on the list are gone. Assume that a size_t - // field can be accessed atomically. - size_t currentNumberOfEmptyRegions = m_numberOfEmptyRegions; - if (!currentNumberOfEmptyRegions) - continue; + // Sleep until there is actually work to do rather than waking up every second to check. + { + MutexLocker locker(m_emptyRegionConditionLock); + SpinLockHolder regionLocker(&m_regionLock); + while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) { + m_regionLock.Unlock(); + m_emptyRegionCondition.wait(m_emptyRegionConditionLock); + m_regionLock.Lock(); + } + currentNumberOfEmptyRegions = m_numberOfEmptyRegions; + } size_t desiredNumberOfEmptyRegions = currentNumberOfEmptyRegions / 2; @@ -141,16 +147,6 @@ void BlockAllocator::blockFreeingThreadMain() delete region; } - - // Sleep until there is actually work to do rather than waking up every second to check. - MutexLocker locker(m_emptyRegionConditionLock); - m_regionLock.Lock(); - while (!m_numberOfEmptyRegions && !m_blockFreeingThreadShouldQuit) { - m_regionLock.Unlock(); - m_emptyRegionCondition.wait(m_emptyRegionConditionLock); - m_regionLock.Lock(); - } - m_regionLock.Unlock(); } } diff --git a/Source/JavaScriptCore/heap/HeapStatistics.cpp b/Source/JavaScriptCore/heap/HeapStatistics.cpp index 68044e0b3..8340bfa37 100644 --- a/Source/JavaScriptCore/heap/HeapStatistics.cpp +++ b/Source/JavaScriptCore/heap/HeapStatistics.cpp @@ -138,12 +138,6 @@ void HeapStatistics::reportSuccess() #endif // OS(UNIX) -size_t HeapStatistics::usedJSHeap() -{ - JSGlobalData* globalData = &JSGlobalData::sharedInstance(); - return globalData->heap.size(); -} - size_t HeapStatistics::parseMemoryAmount(char* s) { size_t multiplier = 1; diff --git a/Source/JavaScriptCore/heap/HeapStatistics.h b/Source/JavaScriptCore/heap/HeapStatistics.h index 34d05af7c..0800f0c16 100644 --- a/Source/JavaScriptCore/heap/HeapStatistics.h +++ b/Source/JavaScriptCore/heap/HeapStatistics.h @@ -36,7 +36,6 @@ class HeapStatistics { public: NO_RETURN static void exitWithFailure(); JS_EXPORT_PRIVATE static void reportSuccess(); - JS_EXPORT_PRIVATE static size_t usedJSHeap(); static void initialize(); static void recordGCPauseTime(double start, double end); |