Title: [202090] trunk/Source/WebCore
Revision
202090
Author
akl...@apple.com
Date
2016-06-15 08:13:03 -0700 (Wed, 15 Jun 2016)

Log Message

[Cocoa] Add two notify listeners for poking the garbage collector.
<https://webkit.org/b/158783>

Reviewed by Antti Koivisto.

Add two new notify listeners:

- com.apple.WebKit.fullGC

    Trigger a full garbage collection in the main WebCore VM immediately.

- com.apple.WebKit.deleteAllCode

    Throw away all of JSC's linked and unlinked code, and do a full GC.

These will make it easier to diagnose memory growth issues by having a lever that
eliminates many of the large object graphs without going after behavior-changing things
like the memory cache.

* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::platformInitialize):
* platform/MemoryPressureHandler.h:
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::platformInitialize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (202089 => 202090)


--- trunk/Source/WebCore/ChangeLog	2016-06-15 14:12:16 UTC (rev 202089)
+++ trunk/Source/WebCore/ChangeLog	2016-06-15 15:13:03 UTC (rev 202090)
@@ -1,3 +1,30 @@
+2016-06-15  Andreas Kling  <akl...@apple.com>
+
+        [Cocoa] Add two notify listeners for poking the garbage collector.
+        <https://webkit.org/b/158783>
+
+        Reviewed by Antti Koivisto.
+
+        Add two new notify listeners:
+
+        - com.apple.WebKit.fullGC
+
+            Trigger a full garbage collection in the main WebCore VM immediately.
+
+        - com.apple.WebKit.deleteAllCode
+
+            Throw away all of JSC's linked and unlinked code, and do a full GC.
+
+        These will make it easier to diagnose memory growth issues by having a lever that
+        eliminates many of the large object graphs without going after behavior-changing things
+        like the memory cache.
+
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::platformInitialize):
+        * platform/MemoryPressureHandler.h:
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::platformInitialize):
+
 2016-06-15  Antti Koivisto  <an...@apple.com>
 
         Vary:Cookie validation doesn't work in private browsing

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (202089 => 202090)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2016-06-15 14:12:16 UTC (rev 202089)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2016-06-15 15:13:03 UTC (rev 202090)
@@ -73,6 +73,7 @@
     , m_holdOffTimer(*this, &MemoryPressureHandler::holdOffTimerFired)
 #endif
 {
+    platformInitialize();
 }
 
 void MemoryPressureHandler::releaseNoncriticalMemory()
@@ -211,6 +212,10 @@
         MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory);
 }
 
+#if !PLATFORM(COCOA)
+void MemoryPressureHandler::platformInitialize() { }
+#endif
+
 #if !PLATFORM(COCOA) && !OS(LINUX) && !PLATFORM(WIN)
 void MemoryPressureHandler::install() { }
 void MemoryPressureHandler::uninstall() { }

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (202089 => 202090)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-06-15 14:12:16 UTC (rev 202089)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-06-15 15:13:03 UTC (rev 202090)
@@ -122,6 +122,7 @@
     WEBCORE_EXPORT void releaseMemory(Critical, Synchronous = Synchronous::No);
 
 private:
+    void platformInitialize();
     void releaseNoncriticalMemory();
     void releaseCriticalMemory(Synchronous);
 

Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (202089 => 202090)


--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2016-06-15 14:12:16 UTC (rev 202089)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2016-06-15 15:13:03 UTC (rev 202090)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "MemoryPressureHandler.h"
 
+#import "GCController.h"
 #import "IOSurfacePool.h"
 #import "LayerPool.h"
 #import "Logging.h"
@@ -47,6 +48,18 @@
 
 namespace WebCore {
 
+void MemoryPressureHandler::platformInitialize()
+{
+    int dummy;
+    notify_register_dispatch("com.apple.WebKit.fullGC", &dummy, dispatch_get_main_queue(), ^(int) {
+        GCController::singleton().garbageCollectNow();
+    });
+    notify_register_dispatch("com.apple.WebKit.deleteAllCode", &dummy, dispatch_get_main_queue(), ^(int) {
+        GCController::singleton().deleteAllCode();
+        GCController::singleton().garbageCollectNow();
+    });
+}
+
 void MemoryPressureHandler::platformReleaseMemory(Critical critical)
 {
     {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to