Title: [225540] trunk/Source/_javascript_Core
Revision
225540
Author
fpi...@apple.com
Date
2017-12-05 13:55:08 -0800 (Tue, 05 Dec 2017)

Log Message

IsoAlignedMemoryAllocator needs to free all of its memory when the VM destructs
https://bugs.webkit.org/show_bug.cgi?id=180425

Reviewed by Saam Barati.
        
Failure to do so causes leaks after starting workers.

* heap/IsoAlignedMemoryAllocator.cpp:
(JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator):
(JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (225539 => 225540)


--- trunk/Source/_javascript_Core/ChangeLog	2017-12-05 21:52:31 UTC (rev 225539)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-12-05 21:55:08 UTC (rev 225540)
@@ -1,3 +1,16 @@
+2017-12-05  Filip Pizlo  <fpi...@apple.com>
+
+        IsoAlignedMemoryAllocator needs to free all of its memory when the VM destructs
+        https://bugs.webkit.org/show_bug.cgi?id=180425
+
+        Reviewed by Saam Barati.
+        
+        Failure to do so causes leaks after starting workers.
+
+        * heap/IsoAlignedMemoryAllocator.cpp:
+        (JSC::IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator):
+        (JSC::IsoAlignedMemoryAllocator::tryAllocateAlignedMemory):
+
 2017-12-05  Per Arne Vollan  <pvol...@apple.com>
 
         [Win64] Compile error in testmasm.cpp.

Modified: trunk/Source/_javascript_Core/heap/IsoAlignedMemoryAllocator.cpp (225539 => 225540)


--- trunk/Source/_javascript_Core/heap/IsoAlignedMemoryAllocator.cpp	2017-12-05 21:52:31 UTC (rev 225539)
+++ trunk/Source/_javascript_Core/heap/IsoAlignedMemoryAllocator.cpp	2017-12-05 21:55:08 UTC (rev 225540)
@@ -34,6 +34,12 @@
 
 IsoAlignedMemoryAllocator::~IsoAlignedMemoryAllocator()
 {
+    for (unsigned i = 0; i < m_blocks.size(); ++i) {
+        void* block = m_blocks[i];
+        if (!m_committed[i])
+            OSAllocator::commit(block, MarkedBlock::blockSize, true, false);
+        fastFree(block);
+    }
 }
 
 void* IsoAlignedMemoryAllocator::tryAllocateAlignedMemory(size_t alignment, size_t size)
@@ -53,7 +59,9 @@
         return result;
     }
     
-    void* result = fastAlignedMalloc(MarkedBlock::blockSize, MarkedBlock::blockSize);
+    void* result = tryFastAlignedMalloc(MarkedBlock::blockSize, MarkedBlock::blockSize);
+    if (!result)
+        return nullptr;
     unsigned index = m_blocks.size();
     m_blocks.append(result);
     m_blockIndices.add(result, index);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to