Heap::destroy leaks CopiedSpace
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 21:14:16 +0000 (21:14 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Mar 2012 21:14:16 +0000 (21:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=81055

Reviewed by Geoffrey Garen.

Added a destroy() function to CopiedSpace that moves all normal size
CopiedBlocks from the CopiedSpace to the Heap's list of free blocks
as well as deallocates all of the oversize blocks in the CopiedSpace.
This function is now called in Heap::destroy().

* heap/CopiedSpace.cpp:
(JSC::CopiedSpace::destroy):
(JSC):
* heap/CopiedSpace.h:
(CopiedSpace):
* heap/Heap.cpp:
(JSC::Heap::destroy):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/CopiedSpace.cpp
Source/JavaScriptCore/heap/CopiedSpace.h
Source/JavaScriptCore/heap/Heap.cpp

index ec8e5cf..a60baac 100644 (file)
@@ -1,3 +1,23 @@
+2012-03-14  Mark Hahnenberg  <mhahnenberg@apple.com>
+
+        Heap::destroy leaks CopiedSpace
+        https://bugs.webkit.org/show_bug.cgi?id=81055
+
+        Reviewed by Geoffrey Garen.
+
+        Added a destroy() function to CopiedSpace that moves all normal size 
+        CopiedBlocks from the CopiedSpace to the Heap's list of free blocks 
+        as well as deallocates all of the oversize blocks in the CopiedSpace. 
+        This function is now called in Heap::destroy().
+
+        * heap/CopiedSpace.cpp:
+        (JSC::CopiedSpace::destroy):
+        (JSC):
+        * heap/CopiedSpace.h:
+        (CopiedSpace):
+        * heap/Heap.cpp:
+        (JSC::Heap::destroy):
+
 2012-03-14  Andrew Lo  <anlo@rim.com>
 
         [BlackBerry] Implement REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR using AnimationFrameRateController
index c847012..5a2ac40 100644 (file)
@@ -261,4 +261,26 @@ CheckedBoolean CopiedSpace::getFreshBlock(AllocationEffort allocationEffort, Cop
     return true;
 }
 
+void CopiedSpace::destroy()
+{
+    while (!m_toSpace->isEmpty()) {
+        CopiedBlock* block = static_cast<CopiedBlock*>(m_toSpace->removeHead());
+        MutexLocker locker(m_heap->m_freeBlockLock);
+        m_heap->m_freeBlocks.append(block);
+        m_heap->m_numberOfFreeBlocks++;
+    }
+
+    while (!m_fromSpace->isEmpty()) {
+        CopiedBlock* block = static_cast<CopiedBlock*>(m_fromSpace->removeHead());
+        MutexLocker locker(m_heap->m_freeBlockLock);
+        m_heap->m_freeBlocks.append(block);
+        m_heap->m_numberOfFreeBlocks++;
+    }
+
+    while (!m_oversizeBlocks.isEmpty()) {
+        CopiedBlock* block = static_cast<CopiedBlock*>(m_oversizeBlocks.removeHead());
+        block->m_allocation.deallocate();
+    }
+}
+
 } // namespace JSC
index e8fa800..a8036cf 100644 (file)
@@ -68,6 +68,8 @@ public:
     size_t totalMemoryAllocated() { return m_totalMemoryAllocated; }
     size_t totalMemoryUtilized() { return m_totalMemoryUtilized; }
 
+    void destroy();
+
     static CopiedBlock* blockFor(void*);
 
 private:
index a5d4a06..da7231c 100644 (file)
@@ -379,8 +379,9 @@ void Heap::destroy()
     m_handleHeap.finalizeWeakHandles();
     m_globalData->smallStrings.finalizeSmallStrings();
     shrink();
+    m_storageSpace.destroy();
     ASSERT(!size());
-    
+
 #if ENABLE(SIMPLE_HEAP_PROFILING)
     m_slotVisitor.m_visitedTypeCounts.dump(WTF::dataFile(), "Visited Type Counts");
     m_destroyedTypeCounts.dump(WTF::dataFile(), "Destroyed Type Counts");