Title: [123931] trunk/Source/_javascript_Core
Revision
123931
Author
[email protected]
Date
2012-07-27 15:59:14 -0700 (Fri, 27 Jul 2012)

Log Message

Split functionality of MarkedAllocator::m_currentBlock
https://bugs.webkit.org/show_bug.cgi?id=92550

Reviewed by Filip Pizlo.

MarkedAllocator::m_currentBlock serves two purposes right now; it indicates the block that is currently 
being used for allocation and the beginning of the list of blocks that need to be swept. We should split 
these two functionalities into two separate fields.

* heap/MarkedAllocator.cpp:
(JSC::MarkedAllocator::tryAllocateHelper): Use m_blocksToSweep instead of m_currentBlock as the 
initializer/reference of the loop. Only change m_currentBlock when we know what the result will be.
(JSC::MarkedAllocator::addBlock): When we add a new block we know that both m_blocksToSweep and 
m_currentBlock are null. In order to preserve the invariant that m_currentBlock <= m_blocksToSweep, 
we assign both of them to point to the new block.
(JSC::MarkedAllocator::removeBlock): We need a separate check to see if the block we're removing is 
m_blocksToSweep and if so, advance it to the next block in the list.
* heap/MarkedAllocator.h:
(MarkedAllocator): Initialize m_blocksToSweep.
(JSC::MarkedAllocator::MarkedAllocator):
(JSC::MarkedAllocator::reset): We set m_blocksToSweep to be the head of our list. This function is called
at the end of a collection, so all of the blocks in our allocator need to be swept. We need to sweep a 
block before we can start allocating, so m_currentBlock is set to null. We also set the freeList to 
the empty FreeList to emphasize the fact that we can't start allocating until we do some sweeping.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (123930 => 123931)


--- trunk/Source/_javascript_Core/ChangeLog	2012-07-27 22:58:02 UTC (rev 123930)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-07-27 22:59:14 UTC (rev 123931)
@@ -1,5 +1,32 @@
 2012-07-27  Mark Hahnenberg  <[email protected]>
 
+        Split functionality of MarkedAllocator::m_currentBlock
+        https://bugs.webkit.org/show_bug.cgi?id=92550
+
+        Reviewed by Filip Pizlo.
+
+        MarkedAllocator::m_currentBlock serves two purposes right now; it indicates the block that is currently 
+        being used for allocation and the beginning of the list of blocks that need to be swept. We should split 
+        these two functionalities into two separate fields.
+
+        * heap/MarkedAllocator.cpp:
+        (JSC::MarkedAllocator::tryAllocateHelper): Use m_blocksToSweep instead of m_currentBlock as the 
+        initializer/reference of the loop. Only change m_currentBlock when we know what the result will be.
+        (JSC::MarkedAllocator::addBlock): When we add a new block we know that both m_blocksToSweep and 
+        m_currentBlock are null. In order to preserve the invariant that m_currentBlock <= m_blocksToSweep, 
+        we assign both of them to point to the new block.
+        (JSC::MarkedAllocator::removeBlock): We need a separate check to see if the block we're removing is 
+        m_blocksToSweep and if so, advance it to the next block in the list.
+        * heap/MarkedAllocator.h:
+        (MarkedAllocator): Initialize m_blocksToSweep.
+        (JSC::MarkedAllocator::MarkedAllocator):
+        (JSC::MarkedAllocator::reset): We set m_blocksToSweep to be the head of our list. This function is called
+        at the end of a collection, so all of the blocks in our allocator need to be swept. We need to sweep a 
+        block before we can start allocating, so m_currentBlock is set to null. We also set the freeList to 
+        the empty FreeList to emphasize the fact that we can't start allocating until we do some sweeping.
+
+2012-07-27  Mark Hahnenberg  <[email protected]>
+
         Increase inline storage for JSFinalObjects by one
         https://bugs.webkit.org/show_bug.cgi?id=92526
 

Modified: trunk/Source/_javascript_Core/heap/MarkedAllocator.cpp (123930 => 123931)


--- trunk/Source/_javascript_Core/heap/MarkedAllocator.cpp	2012-07-27 22:58:02 UTC (rev 123930)
+++ trunk/Source/_javascript_Core/heap/MarkedAllocator.cpp	2012-07-27 22:59:14 UTC (rev 123931)
@@ -29,15 +29,19 @@
 inline void* MarkedAllocator::tryAllocateHelper()
 {
     if (!m_freeList.head) {
-        for (MarkedBlock*& block = m_currentBlock; block; block = static_cast<MarkedBlock*>(block->next())) {
+        for (MarkedBlock*& block = m_blocksToSweep; block; block = static_cast<MarkedBlock*>(block->next())) {
             m_freeList = block->sweep(MarkedBlock::SweepToFreeList);
-            if (m_freeList.head)
+            if (m_freeList.head) {
+                m_currentBlock = block;
                 break;
+            }
             block->didConsumeFreeList();
         }
         
-        if (!m_freeList.head)
+        if (!m_freeList.head) {
+            m_currentBlock = 0;
             return 0;
+        }
     }
     
     MarkedBlock::FreeCell* head = m_freeList.head;
@@ -100,10 +104,11 @@
 void MarkedAllocator::addBlock(MarkedBlock* block)
 {
     ASSERT(!m_currentBlock);
+    ASSERT(!m_blocksToSweep);
     ASSERT(!m_freeList.head);
     
     m_blockList.append(block);
-    m_currentBlock = block;
+    m_blocksToSweep = m_currentBlock = block;
     m_freeList = block->sweep(MarkedBlock::SweepToFreeList);
 }
 
@@ -113,6 +118,8 @@
         m_currentBlock = static_cast<MarkedBlock*>(m_currentBlock->next());
         m_freeList = MarkedBlock::FreeList();
     }
+    if (m_blocksToSweep == block)
+        m_blocksToSweep = static_cast<MarkedBlock*>(m_blocksToSweep->next());
     m_blockList.remove(block);
 }
 

Modified: trunk/Source/_javascript_Core/heap/MarkedAllocator.h (123930 => 123931)


--- trunk/Source/_javascript_Core/heap/MarkedAllocator.h	2012-07-27 22:58:02 UTC (rev 123930)
+++ trunk/Source/_javascript_Core/heap/MarkedAllocator.h	2012-07-27 22:59:14 UTC (rev 123931)
@@ -46,6 +46,7 @@
     
     MarkedBlock::FreeList m_freeList;
     MarkedBlock* m_currentBlock;
+    MarkedBlock* m_blocksToSweep;
     DoublyLinkedList<HeapBlock> m_blockList;
     size_t m_cellSize;
     bool m_cellsNeedDestruction;
@@ -56,6 +57,7 @@
 
 inline MarkedAllocator::MarkedAllocator()
     : m_currentBlock(0)
+    , m_blocksToSweep(0)
     , m_cellSize(0)
     , m_cellsNeedDestruction(true)
     , m_onlyContainsStructures(false)
@@ -86,7 +88,9 @@
 
 inline void MarkedAllocator::reset()
 {
-    m_currentBlock = static_cast<MarkedBlock*>(m_blockList.head());
+    m_currentBlock = 0;
+    m_freeList = MarkedBlock::FreeList();
+    m_blocksToSweep = static_cast<MarkedBlock*>(m_blockList.head());
 }
 
 inline void MarkedAllocator::zapFreeList()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to