Unreviewed.
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2012 03:17:15 +0000 (03:17 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2012 03:17:15 +0000 (03:17 +0000)
Rolled out r119364 because it's still causing crashes (when running
v8-earley in release builds of DRT)

This time for sure!

* heap/Heap.cpp:
(JSC::Heap::collect):
* heap/MarkedBlock.cpp:
(JSC::MarkedBlock::sweep):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::resetAllocator):
(JSC):
* heap/MarkedSpace.cpp:
(JSC::ResetAllocator::operator()):
(JSC):
(JSC::MarkedSpace::resetAllocators):
(JSC::MarkedSpace::sweepWeakSets):
* heap/MarkedSpace.h:
(MarkedSpace):
* heap/WeakBlock.cpp:
(JSC::WeakBlock::sweep):
* heap/WeakSet.cpp:
(JSC::WeakSet::sweep):
(JSC::WeakSet::tryFindAllocator):
* heap/WeakSet.h:
(JSC::WeakSet::shrink):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@119453 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/MarkedBlock.cpp
Source/JavaScriptCore/heap/MarkedBlock.h
Source/JavaScriptCore/heap/MarkedSpace.cpp
Source/JavaScriptCore/heap/MarkedSpace.h
Source/JavaScriptCore/heap/WeakBlock.cpp
Source/JavaScriptCore/heap/WeakSet.cpp
Source/JavaScriptCore/heap/WeakSet.h

index a38308f..a3bc98a 100644 (file)
@@ -1,3 +1,34 @@
+2012-06-04  Geoffrey Garen  <ggaren@apple.com>
+
+        Unreviewed.
+
+        Rolled out r119364 because it's still causing crashes (when running
+        v8-earley in release builds of DRT)
+
+        This time for sure!
+
+        * heap/Heap.cpp:
+        (JSC::Heap::collect):
+        * heap/MarkedBlock.cpp:
+        (JSC::MarkedBlock::sweep):
+        * heap/MarkedBlock.h:
+        (JSC::MarkedBlock::resetAllocator):
+        (JSC):
+        * heap/MarkedSpace.cpp:
+        (JSC::ResetAllocator::operator()):
+        (JSC):
+        (JSC::MarkedSpace::resetAllocators):
+        (JSC::MarkedSpace::sweepWeakSets):
+        * heap/MarkedSpace.h:
+        (MarkedSpace):
+        * heap/WeakBlock.cpp:
+        (JSC::WeakBlock::sweep):
+        * heap/WeakSet.cpp:
+        (JSC::WeakSet::sweep):
+        (JSC::WeakSet::tryFindAllocator):
+        * heap/WeakSet.h:
+        (JSC::WeakSet::shrink):
+
 2012-06-04  Filip Pizlo  <fpizlo@apple.com>
 
         DFG arguments simplification should have rationalized handling of TearOffArguments
index 22f6c91..90c4bb7 100644 (file)
@@ -688,7 +688,8 @@ void Heap::collect(SweepToggle sweepToggle)
     }
 
     {
-        GCPHASE(FinalizeSmallString);
+        GCPHASE(FinalizeWeakHandles);
+        m_objectSpace.sweepWeakSets();
         m_globalData->smallStrings.finalizeSmallStrings();
     }
     
index 01e4237..0075f78 100644 (file)
@@ -114,8 +114,6 @@ MarkedBlock::FreeList MarkedBlock::sweep(SweepMode sweepMode)
 {
     HEAP_LOG_BLOCK_STATE_TRANSITION(this);
 
-    m_weakSet.sweep();
-
     if (sweepMode == SweepOnly && !m_cellsNeedDestruction)
         return FreeList();
 
index 7d3394e..b94c1e2 100644 (file)
@@ -129,6 +129,7 @@ namespace JSC {
         FreeList sweep(SweepMode = SweepOnly);
 
         void shrink();
+        void resetAllocator();
 
         void visitWeakSet(HeapRootVisitor&);
         void reapWeakSet();
@@ -273,6 +274,11 @@ namespace JSC {
         m_weakSet.shrink();
     }
 
+    inline void MarkedBlock::resetAllocator()
+    {
+        m_weakSet.resetAllocator();
+    }
+
     inline void MarkedBlock::visitWeakSet(HeapRootVisitor& heapRootVisitor)
     {
         m_weakSet.visit(heapRootVisitor);
index 1921510..1604d2d 100644 (file)
@@ -112,6 +112,10 @@ void MarkedSpace::lastChanceToFinalize()
     forEachBlock<LastChanceToFinalize>();
 }
 
+struct ResetAllocator : MarkedBlock::VoidFunctor {
+    void operator()(MarkedBlock* block) { block->resetAllocator(); }
+};
+
 void MarkedSpace::resetAllocators()
 {
     for (size_t cellSize = preciseStep; cellSize <= preciseCutoff; cellSize += preciseStep) {
@@ -123,6 +127,8 @@ void MarkedSpace::resetAllocators()
         allocatorFor(cellSize).reset();
         destructorAllocatorFor(cellSize).reset();
     }
+
+    forEachBlock<ResetAllocator>();
 }
 
 void MarkedSpace::visitWeakSets(HeapRootVisitor& heapRootVisitor)
@@ -136,6 +142,11 @@ void MarkedSpace::reapWeakSets()
     forEachBlock<ReapWeakSet>();
 }
 
+void MarkedSpace::sweepWeakSets()
+{
+    forEachBlock<SweepWeakSet>();
+}
+
 void MarkedSpace::canonicalizeCellLivenessData()
 {
     for (size_t cellSize = preciseStep; cellSize <= preciseCutoff; cellSize += preciseStep) {
index 3f82bac..18b57c6 100644 (file)
@@ -85,6 +85,7 @@ public:
 
     void visitWeakSets(HeapRootVisitor&);
     void reapWeakSets();
+    void sweepWeakSets();
 
     MarkedBlockSet& blocks() { return m_blocks; }
     
index 8900e73..685779d 100644 (file)
@@ -69,8 +69,7 @@ void WeakBlock::lastChanceToFinalize()
 
 void WeakBlock::sweep()
 {
-    // If a block is completely empty, a sweep won't have any effect.
-    if (isEmpty())
+    if (!m_sweepResult.isNull())
         return;
 
     SweepResult sweepResult;
index 4a510b8..9374fd8 100644 (file)
@@ -42,10 +42,17 @@ WeakSet::~WeakSet()
 
 void WeakSet::sweep()
 {
-    for (WeakBlock* block = m_blocks.head(); block; block = block->next())
-        block->sweep();
+    WeakBlock* next;
+    for (WeakBlock* block = m_blocks.head(); block; block = next) {
+        next = block->next();
+
+        // If a block is completely empty, a new sweep won't have any effect.
+        if (block->isEmpty())
+            continue;
 
-    resetAllocator();
+        block->takeSweepResult(); // Force a new sweep by discarding the last sweep.
+        block->sweep();
+    }
 }
 
 WeakBlock::FreeCell* WeakSet::findAllocator()
@@ -62,6 +69,7 @@ WeakBlock::FreeCell* WeakSet::tryFindAllocator()
         WeakBlock* block = m_nextAllocator;
         m_nextAllocator = m_nextAllocator->next();
 
+        block->sweep();
         WeakBlock::SweepResult sweepResult = block->takeSweepResult();
         if (sweepResult.freeList)
             return sweepResult.freeList;
index 291d0ae..be9844a 100644 (file)
@@ -118,8 +118,6 @@ inline void WeakSet::shrink()
         if (block->isEmpty())
             removeAllocator(block);
     }
-
-    resetAllocator();
 }
 
 inline void WeakSet::resetAllocator()