2011-02-04 Geoffrey Garen <ggaren@apple.com>
[WebKit.git] / Source / JavaScriptCore / runtime / MarkedSpace.cpp
index 027a9731a9885d8f4da271230d869c3486668226..b2e2ee5fad5b7210b9231cedd7be3c8836fc0e12 100644 (file)
@@ -138,8 +138,12 @@ void* MarkedSpace::allocate(size_t s)
             m_heap.nextCell = block->marked.nextPossiblyUnset(m_heap.nextCell);
         } while (m_heap.nextCell != HeapConstants::cellsPerBlock);
         m_heap.nextCell = 0;
+        m_heap.waterMark += BLOCK_SIZE;
     } while (++m_heap.nextBlock != m_heap.usedBlocks);
-    
+
+    if (m_heap.waterMark < m_heap.highWaterMark)
+        return &allocateBlock()->cells[m_heap.nextCell++];
+
     return 0;
 }
 
@@ -270,6 +274,9 @@ void MarkedSpace::sweep()
         new (cell) JSCell(dummyMarkableCellStructure);
 #endif
     }
+    
+    if (m_heap.usedBlocks > 1)
+        shrinkBlocks(1);
 }
 
 size_t MarkedSpace::objectCount() const
@@ -294,10 +301,10 @@ void MarkedSpace::reset()
 {
     m_heap.nextCell = 0;
     m_heap.nextBlock = 0;
+    m_heap.waterMark = 0;
 #if ENABLE(JSC_ZOMBIES)
     sweep();
 #endif
-    resizeBlocks();
 }
 
 LiveObjectIterator MarkedSpace::primaryHeapBegin()