Title: [155316] trunk/Source/_javascript_Core
Revision
155316
Author
[email protected]
Date
2013-09-08 16:36:40 -0700 (Sun, 08 Sep 2013)

Log Message

Clearing MarkedBlock::m_newlyAllocated should be separate from MarkedBlock::clearMarks
https://bugs.webkit.org/show_bug.cgi?id=121007

Reviewed by Oliver Hunt.

We call clearMarks on every MarkedBlock in the Heap, whereas we only need to clear 
m_newlyAllocated for the m_currentBlock at the time of the last canonicalizeCellLiveness() 
for each MarkedAllocator. We also need to call it on every block in the largeAllocators 
because each one of their blocks is canonicalized as it is used.

* heap/Heap.cpp:
(JSC::Heap::markRoots):
* heap/MarkedAllocator.h:
(JSC::MarkedAllocator::getAndClearCanonicalizedBlock):
(JSC::MarkedAllocator::MarkedAllocator):
(JSC::MarkedAllocator::canonicalizeCellLivenessData):
* heap/MarkedBlock.h:
(JSC::MarkedBlock::lastChanceToFinalize):
(JSC::MarkedBlock::clearMarks):
(JSC::MarkedBlock::clearNewlyAllocated):
* heap/MarkedSpace.cpp:
(JSC::clearNewlyAllocatedInBlock):
(JSC::ClearNewlyAllocated::operator()):
(JSC::MarkedSpace::clearNewlyAllocated):
* heap/MarkedSpace.h:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (155315 => 155316)


--- trunk/Source/_javascript_Core/ChangeLog	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-09-08 23:36:40 UTC (rev 155316)
@@ -1,3 +1,31 @@
+2013-09-08  Mark Hahnenberg  <[email protected]>
+
+        Clearing MarkedBlock::m_newlyAllocated should be separate from MarkedBlock::clearMarks
+        https://bugs.webkit.org/show_bug.cgi?id=121007
+
+        Reviewed by Oliver Hunt.
+
+        We call clearMarks on every MarkedBlock in the Heap, whereas we only need to clear 
+        m_newlyAllocated for the m_currentBlock at the time of the last canonicalizeCellLiveness() 
+        for each MarkedAllocator. We also need to call it on every block in the largeAllocators 
+        because each one of their blocks is canonicalized as it is used.
+
+        * heap/Heap.cpp:
+        (JSC::Heap::markRoots):
+        * heap/MarkedAllocator.h:
+        (JSC::MarkedAllocator::getAndClearCanonicalizedBlock):
+        (JSC::MarkedAllocator::MarkedAllocator):
+        (JSC::MarkedAllocator::canonicalizeCellLivenessData):
+        * heap/MarkedBlock.h:
+        (JSC::MarkedBlock::lastChanceToFinalize):
+        (JSC::MarkedBlock::clearMarks):
+        (JSC::MarkedBlock::clearNewlyAllocated):
+        * heap/MarkedSpace.cpp:
+        (JSC::clearNewlyAllocatedInBlock):
+        (JSC::ClearNewlyAllocated::operator()):
+        (JSC::MarkedSpace::clearNewlyAllocated):
+        * heap/MarkedSpace.h:
+
 2013-09-07  Filip Pizlo  <[email protected]>
 
         FTL should support typed array PutByVal

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (155315 => 155316)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2013-09-08 23:36:40 UTC (rev 155316)
@@ -467,7 +467,8 @@
 #endif
 
     {
-        GCPHASE(clearMarks);
+        GCPHASE(ClearLivenessData);
+        m_objectSpace.clearNewlyAllocated();
         m_objectSpace.clearMarks();
     }
 

Modified: trunk/Source/_javascript_Core/heap/MarkedAllocator.h (155315 => 155316)


--- trunk/Source/_javascript_Core/heap/MarkedAllocator.h	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/heap/MarkedAllocator.h	2013-09-08 23:36:40 UTC (rev 155316)
@@ -27,6 +27,12 @@
     MarkedBlock::DestructorType destructorType() { return m_destructorType; }
     void* allocate(size_t);
     Heap* heap() { return m_heap; }
+    MarkedBlock* takeCanonicalizedBlock()
+    {
+        MarkedBlock* block = m_canonicalizedBlock;
+        m_canonicalizedBlock = 0;
+        return block;
+    }
     
     template<typename Functor> void forEachBlock(Functor&);
     
@@ -44,6 +50,7 @@
     
     MarkedBlock::FreeList m_freeList;
     MarkedBlock* m_currentBlock;
+    MarkedBlock* m_canonicalizedBlock;
     MarkedBlock* m_blocksToSweep;
     DoublyLinkedList<MarkedBlock> m_blockList;
     size_t m_cellSize;
@@ -59,6 +66,7 @@
 
 inline MarkedAllocator::MarkedAllocator()
     : m_currentBlock(0)
+    , m_canonicalizedBlock(0)
     , m_blocksToSweep(0)
     , m_cellSize(0)
     , m_destructorType(MarkedBlock::None)
@@ -108,6 +116,7 @@
     }
     
     m_currentBlock->canonicalizeCellLivenessData(m_freeList);
+    m_canonicalizedBlock = m_currentBlock;
     m_currentBlock = 0;
     m_freeList = MarkedBlock::FreeList();
 }
@@ -120,7 +129,7 @@
         functor(block);
     }
 }
-    
+
 } // namespace JSC
 
 #endif

Modified: trunk/Source/_javascript_Core/heap/MarkedBlock.h (155315 => 155316)


--- trunk/Source/_javascript_Core/heap/MarkedBlock.h	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/heap/MarkedBlock.h	2013-09-08 23:36:40 UTC (rev 155316)
@@ -134,6 +134,9 @@
         void didConsumeFreeList(); // Call this once you've allocated all the items in the free list.
         void canonicalizeCellLivenessData(const FreeList&);
 
+        // Returns true if the "newly allocated" bitmap was non-null 
+        // and was successfully cleared and false otherwise.
+        bool clearNewlyAllocated();
         void clearMarks();
         size_t markCount();
         bool isEmpty();
@@ -226,6 +229,7 @@
     {
         m_weakSet.lastChanceToFinalize();
 
+        clearNewlyAllocated();
         clearMarks();
         sweep();
     }
@@ -279,7 +283,6 @@
 
         ASSERT(m_state != New && m_state != FreeListed);
         m_marks.clearAll();
-        m_newlyAllocated.clear();
 
         // This will become true at the end of the mark phase. We set it now to
         // avoid an extra pass to do so later.
@@ -357,6 +360,15 @@
         m_newlyAllocated->clear(atomNumber(p));
     }
 
+    inline bool MarkedBlock::clearNewlyAllocated()
+    {
+        if (m_newlyAllocated) {
+            m_newlyAllocated.clear();
+            return true;
+        }
+        return false;
+    }
+
     inline bool MarkedBlock::isLive(const JSCell* cell)
     {
         switch (m_state) {

Modified: trunk/Source/_javascript_Core/heap/MarkedSpace.cpp (155315 => 155316)


--- trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.cpp	2013-09-08 23:36:40 UTC (rev 155316)
@@ -223,4 +223,49 @@
     forEachBlock(freeOrShrink);
 }
 
+static void clearNewlyAllocatedInBlock(MarkedBlock* block)
+{
+    if (!block)
+        return;
+    block->clearNewlyAllocated();
+}
+
+struct ClearNewlyAllocated : MarkedBlock::VoidFunctor {
+    void operator()(MarkedBlock* block) { block->clearNewlyAllocated(); }
+};
+
+#ifndef NDEBUG
+struct VerifyNewlyAllocated : MarkedBlock::VoidFunctor {
+    void operator()(MarkedBlock* block) { ASSERT(!block->clearNewlyAllocated()); }
+};
+#endif
+
+void MarkedSpace::clearNewlyAllocated()
+{
+    for (size_t i = 0; i < preciseCount; ++i) {
+        clearNewlyAllocatedInBlock(m_normalSpace.preciseAllocators[i].takeCanonicalizedBlock());
+        clearNewlyAllocatedInBlock(m_normalDestructorSpace.preciseAllocators[i].takeCanonicalizedBlock());
+        clearNewlyAllocatedInBlock(m_immortalStructureDestructorSpace.preciseAllocators[i].takeCanonicalizedBlock());
+    }
+
+    for (size_t i = 0; i < impreciseCount; ++i) {
+        clearNewlyAllocatedInBlock(m_normalSpace.impreciseAllocators[i].takeCanonicalizedBlock());
+        clearNewlyAllocatedInBlock(m_normalDestructorSpace.impreciseAllocators[i].takeCanonicalizedBlock());
+        clearNewlyAllocatedInBlock(m_immortalStructureDestructorSpace.impreciseAllocators[i].takeCanonicalizedBlock());
+    }
+
+    // We have to iterate all of the blocks in the large allocators because they are
+    // canonicalized as they are used up (see MarkedAllocator::tryAllocateHelper)
+    // which creates the m_newlyAllocated bitmap.
+    ClearNewlyAllocated functor;
+    m_normalSpace.largeAllocator.forEachBlock(functor);
+    m_normalDestructorSpace.largeAllocator.forEachBlock(functor);
+    m_immortalStructureDestructorSpace.largeAllocator.forEachBlock(functor);
+
+#ifndef NDEBUG
+    VerifyNewlyAllocated verifyFunctor;
+    forEachBlock(verifyFunctor);
+#endif
+}
+
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/heap/MarkedSpace.h (155315 => 155316)


--- trunk/Source/_javascript_Core/heap/MarkedSpace.h	2013-09-08 21:10:59 UTC (rev 155315)
+++ trunk/Source/_javascript_Core/heap/MarkedSpace.h	2013-09-08 23:36:40 UTC (rev 155316)
@@ -104,6 +104,7 @@
     void didConsumeFreeList(MarkedBlock*);
 
     void clearMarks();
+    void clearNewlyAllocated();
     void sweep();
     size_t objectCount();
     size_t size();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to