[Cocoa] Release freed up blocks from the JS heap after simulated memory pressure.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jun 2014 20:48:13 +0000 (20:48 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jun 2014 20:48:13 +0000 (20:48 +0000)
<https://webkit.org/b/134112>

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore:
* heap/BlockAllocator.h:

Source/WebCore:
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::install):

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/BlockAllocator.h
Source/WebCore/ChangeLog
Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm

index 99ae88c..64005af 100644 (file)
@@ -1,3 +1,12 @@
+2014-06-20  Andreas Kling  <akling@apple.com>
+
+        [Cocoa] Release freed up blocks from the JS heap after simulated memory pressure.
+        <https://webkit.org/b/134112>
+
+        Reviewed by Mark Hahnenberg.
+
+        * heap/BlockAllocator.h:
+
 2014-06-19  Alex Christensen  <achristensen@webkit.org>
 
         Unreviewed fix after r170130.
index 06df3b4..eb6867f 100644 (file)
@@ -62,6 +62,8 @@ public:
     template <typename T> void deallocate(T*);
     template <typename T> void deallocateCustomSize(T*);
 
+    JS_EXPORT_PRIVATE void releaseFreeRegions();
+
 private:
     void waitForDuration(std::chrono::milliseconds);
 
@@ -90,7 +92,6 @@ private:
     DeadBlock* tryAllocateFromRegion(RegionSet&, DoublyLinkedList<Region>&, size_t&);
 
     bool allRegionSetsAreEmpty() const;
-    void releaseFreeRegions();
 
     template <typename T> RegionSet& regionSetFor();
 
index 2c02b90..6283a8e 100644 (file)
@@ -1,3 +1,13 @@
+2014-06-20  Andreas Kling  <akling@apple.com>
+
+        [Cocoa] Release freed up blocks from the JS heap after simulated memory pressure.
+        <https://webkit.org/b/134112>
+
+        Reviewed by Mark Hahnenberg.
+
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::install):
+
 2014-06-20  Zalan Bujtas  <zalan@apple.com>
 
         Remove redundant RenderLayer::computeOffsetFromRoot() function.
index 50a4e02..e7ddd35 100644 (file)
@@ -28,6 +28,7 @@
 
 #import "IOSurfacePool.h"
 #import "GCController.h"
+#import "JSDOMWindowBase.h"
 #import "LayerPool.h"
 #import "Logging.h"
 #import "WebCoreSystemInterface.h"
@@ -115,6 +116,9 @@ void MemoryPressureHandler::install()
         // This gives us a more consistent picture of live objects at the end of testing.
         gcController().garbageCollectNow();
 
+        // Release any freed up blocks from the JS heap back to the system.
+        JSDOMWindowBase::commonVM().heap.blockAllocator().releaseFreeRegions();
+
         malloc_zone_pressure_relief(nullptr, 0);
     });