Title: [131619] trunk/Source/_javascript_Core
Revision
131619
Author
[email protected]
Date
2012-10-17 10:30:37 -0700 (Wed, 17 Oct 2012)

Log Message

Block freeing thread should sleep indefinitely when there's no work to do
https://bugs.webkit.org/show_bug.cgi?id=98084

Reviewed by Geoffrey Garen.

r130212 didn't fully fix the problem.

* heap/BlockAllocator.cpp:
(JSC::BlockAllocator::blockFreeingThreadMain): We would just continue to the next iteration if
we found that we had zero blocks to copy. We should move the indefinite wait up to where that
check is done so that we properly detect the "no more blocks to copy, wait for more" condition.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (131618 => 131619)


--- trunk/Source/_javascript_Core/ChangeLog	2012-10-17 17:17:06 UTC (rev 131618)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-10-17 17:30:37 UTC (rev 131619)
@@ -1,3 +1,17 @@
+2012-10-17  Mark Hahnenberg  <[email protected]>
+
+        Block freeing thread should sleep indefinitely when there's no work to do
+        https://bugs.webkit.org/show_bug.cgi?id=98084
+
+        Reviewed by Geoffrey Garen.
+
+        r130212 didn't fully fix the problem.
+
+        * heap/BlockAllocator.cpp:
+        (JSC::BlockAllocator::blockFreeingThreadMain): We would just continue to the next iteration if 
+        we found that we had zero blocks to copy. We should move the indefinite wait up to where that 
+        check is done so that we properly detect the "no more blocks to copy, wait for more" condition.
+
 2012-10-16  Csaba Osztrogonác  <[email protected]>
 
         Unreviewed, rolling out r131516 and r131550.

Modified: trunk/Source/_javascript_Core/heap/BlockAllocator.cpp (131618 => 131619)


--- trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2012-10-17 17:17:06 UTC (rev 131618)
+++ trunk/Source/_javascript_Core/heap/BlockAllocator.cpp	2012-10-17 17:30:37 UTC (rev 131619)
@@ -102,6 +102,7 @@
 
 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 @@
             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 @@
             
             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();
     }
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to