Enh: Add the Ability to Disable / Enable JavaScript GC Timer
authormsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 May 2012 23:47:53 +0000 (23:47 +0000)
committermsaboff@apple.com <msaboff@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 14 May 2012 23:47:53 +0000 (23:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86382

Reviewed by Darin Adler.

Source/JavaScriptCore:

Add flag to GCActivityCallback to enable / disable activity timer.
Add api via Heap to set the flag's value.

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Windows export
* heap/Heap.cpp:
(JSC::Heap::setGarbageCollectionTimerEnabled):
* heap/Heap.h:
* runtime/GCActivityCallback.h:
(JSC::GCActivityCallback::isEnabled):
(JSC::GCActivityCallback::setEnabled):
(JSC::GCActivityCallback::GCActivityCallback):
* runtime/GCActivityCallbackCF.cpp:
(JSC::DefaultGCActivityCallbackPlatformData::timerDidFire):

Source/WebCore:

Plumbing to set / clear JS GC activity timer enable flag.

* WebCore.exp.in:
* bindings/js/GCController.cpp:
(WebCore::GCController::setJavaScriptGarbageCollectorTimerEnabled):
* bindings/js/GCController.h:

Source/WebKit/mac:

Plumbing to set / clear JS GC activity timer enable flag.

* Misc/WebCoreStatistics.h:
* Misc/WebCoreStatistics.mm:
(+[WebCoreStatistics setJavaScriptGarbageCollectorTimerEnabled:]):

Source/WebKit2:

Plumbing to set / clear JS GC activity timer enable flag.

* UIProcess/API/C/WKContext.cpp:
(WKContextSetJavaScriptGarbageCollectorTimerEnabled):
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::setJavaScriptGarbageCollectorTimerEnabled):
* UIProcess/WebContext.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::setJavaScriptGarbageCollectorTimerEnabled):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

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

21 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/runtime/GCActivityCallback.h
Source/JavaScriptCore/runtime/GCActivityCallbackCF.cpp
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/js/GCController.cpp
Source/WebCore/bindings/js/GCController.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Misc/WebCoreStatistics.h
Source/WebKit/mac/Misc/WebCoreStatistics.mm
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContext.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index 717ec0e..6a1ffb0 100644 (file)
@@ -1,5 +1,26 @@
 2012-05-14  Michael Saboff  <msaboff@apple.com>
 
+        Enh: Add the Ability to Disable / Enable JavaScript GC Timer
+        https://bugs.webkit.org/show_bug.cgi?id=86382
+
+        Reviewed by Darin Adler.
+
+        Add flag to GCActivityCallback to enable / disable activity timer.
+        Add api via Heap to set the flag's value.
+
+        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Windows export
+        * heap/Heap.cpp:
+        (JSC::Heap::setGarbageCollectionTimerEnabled):
+        * heap/Heap.h:
+        * runtime/GCActivityCallback.h:
+        (JSC::GCActivityCallback::isEnabled):
+        (JSC::GCActivityCallback::setEnabled):
+        (JSC::GCActivityCallback::GCActivityCallback):
+        * runtime/GCActivityCallbackCF.cpp:
+        (JSC::DefaultGCActivityCallbackPlatformData::timerDidFire):
+
+2012-05-14  Michael Saboff  <msaboff@apple.com>
+
         Increase Debug Logging in MarkStack::validate()
         https://bugs.webkit.org/show_bug.cgi?id=86408
 
index c4f6d5d..9c71699 100755 (executable)
@@ -294,6 +294,7 @@ EXPORTS
     ?setDescriptor@PropertyDescriptor@JSC@@QAEXVJSValue@2@I@Z
     ?setDumpsGeneratedCode@BytecodeGenerator@JSC@@SAX_N@Z
     ?setEnumerable@PropertyDescriptor@JSC@@QAEX_N@Z
+    ?setGarbageCollectionTimerEnabled@Heap@JSC@@QAEX_N@Z
     ?setGetter@PropertyDescriptor@JSC@@QAEXVJSValue@2@@Z
     ?setLoc@StatementNode@JSC@@QAEXHH@Z
     ?setMainThreadCallbacksPaused@WTF@@YAX_N@Z
index d0dbc31..ca78307 100644 (file)
@@ -832,6 +832,11 @@ GCActivityCallback* Heap::activityCallback()
     return m_activityCallback.get();
 }
 
+void Heap::setGarbageCollectionTimerEnabled(bool enable)
+{
+    activityCallback()->setEnabled(enable);
+}
+
 void Heap::didAllocate(size_t bytes)
 {
     m_activityCallback->didAllocate(m_bytesAllocated + m_bytesAbandoned);
index 10fdb07..397bd08 100644 (file)
@@ -100,6 +100,7 @@ namespace JSC {
 
         JS_EXPORT_PRIVATE GCActivityCallback* activityCallback();
         JS_EXPORT_PRIVATE void setActivityCallback(PassOwnPtr<GCActivityCallback>);
+        JS_EXPORT_PRIVATE void setGarbageCollectionTimerEnabled(bool);
 
         // true if an allocation or collection is in progress
         inline bool isBusy();
index 1a18a8b..32077f2 100644 (file)
@@ -47,9 +47,16 @@ public:
     virtual void willCollect() { }
     virtual void synchronize() { }
     virtual void cancel() { }
+    bool isEnabled() const { return m_enabled; }
+    void setEnabled(bool enabled) { m_enabled = enabled; }
 
 protected:
-    GCActivityCallback() {}
+    GCActivityCallback()
+        : m_enabled(true)
+    {
+    }
+
+    bool m_enabled;
 };
 
 struct DefaultGCActivityCallbackPlatformData;
index 8b690a4..d82403a 100644 (file)
@@ -63,6 +63,9 @@ const CFTimeInterval hour = 60 * 60;
 void DefaultGCActivityCallbackPlatformData::timerDidFire(CFRunLoopTimerRef, void *info)
 {
     Heap* heap = static_cast<Heap*>(info);
+    if (!heap->activityCallback()->isEnabled())
+        return;
+
     APIEntryShim shim(heap->globalData());
 #if !PLATFORM(IOS)
     double startTime = WTF::monotonicallyIncreasingTime();
index 2e6d92d..f3e688a 100644 (file)
@@ -1,3 +1,17 @@
+2012-05-14  Michael Saboff  <msaboff@apple.com>
+
+        Enh: Add the Ability to Disable / Enable JavaScript GC Timer
+        https://bugs.webkit.org/show_bug.cgi?id=86382
+
+        Reviewed by Darin Adler.
+
+        Plumbing to set / clear JS GC activity timer enable flag.
+
+        * WebCore.exp.in:
+        * bindings/js/GCController.cpp:
+        (WebCore::GCController::setJavaScriptGarbageCollectorTimerEnabled):
+        * bindings/js/GCController.h:
+
 2012-05-14  Nate Chapin  <japhet@chromium.org>
 
         [V8] Crash in npObjectGetProperty() in V8NPObject.cpp
index 0454e2e..0635985 100644 (file)
@@ -250,6 +250,7 @@ __ZN7WebCore12EventHandler8keyEventERKNS_21PlatformKeyboardEventE
 __ZN7WebCore12EventHandler9mouseDownEP7NSEvent
 __ZN7WebCore12GCController17garbageCollectNowEv
 __ZN7WebCore12GCController18garbageCollectSoonEv
+__ZN7WebCore12GCController41setJavaScriptGarbageCollectorTimerEnabledEb
 __ZN7WebCore12GCController43garbageCollectOnAlternateThreadForDebuggingEb
 __ZN7WebCore12PopupMenuMacC1EPNS_15PopupMenuClientE
 __ZN7WebCore12PrintContext12pagePropertyEPNS_5FrameEPKci
index a137c3a..2e304cb 100644 (file)
@@ -97,6 +97,11 @@ void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDon
     detachThread(threadID);
 }
 
+void GCController::setJavaScriptGarbageCollectorTimerEnabled(bool enable)
+{
+    JSDOMWindow::commonJSGlobalData()->heap.setGarbageCollectionTimerEnabled(enable);
+}
+
 void GCController::discardAllCompiledCode()
 {
     JSLock lock(SilenceAssertionsOnly);
index a367378..40c8a7d 100644 (file)
@@ -44,7 +44,7 @@ namespace WebCore {
         void garbageCollectNow(); // It's better to call garbageCollectSoon, unless you have a specific reason not to.
 
         void garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone); // Used for stress testing.
-
+        void setJavaScriptGarbageCollectorTimerEnabled(bool);
         void discardAllCompiledCode();
 
     private:
index 5c04022..8d2fd30 100644 (file)
@@ -1,3 +1,16 @@
+2012-05-14  Michael Saboff  <msaboff@apple.com>
+
+        Enh: Add the Ability to Disable / Enable JavaScript GC Timer
+        https://bugs.webkit.org/show_bug.cgi?id=86382
+
+        Reviewed by Darin Adler.
+
+        Plumbing to set / clear JS GC activity timer enable flag.
+
+        * Misc/WebCoreStatistics.h:
+        * Misc/WebCoreStatistics.mm:
+        (+[WebCoreStatistics setJavaScriptGarbageCollectorTimerEnabled:]):
+
 2012-05-11  Gavin Barraclough  <barraclough@apple.com>
 
         Introduce PropertyName class
index 1565c26..973fa77 100644 (file)
@@ -47,6 +47,7 @@
 
 + (void)garbageCollectJavaScriptObjects;
 + (void)garbageCollectJavaScriptObjectsOnAlternateThreadForDebugging:(BOOL)waitUntilDone;
++ (void)setJavaScriptGarbageCollectorTimerEnabled:(BOOL)enabled;
 
 + (size_t)iconPageURLMappingCount;
 + (size_t)iconRetainedPageURLCount;
index d593f8c..1840451 100644 (file)
@@ -120,6 +120,11 @@ using namespace WebCore;
     gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone);
 }
 
++ (void)setJavaScriptGarbageCollectorTimerEnabled:(BOOL)enable
+{
+    gcController().setJavaScriptGarbageCollectorTimerEnabled(enable);
+}
+
 + (size_t)iconPageURLMappingCount
 {
     return iconDatabase().pageURLMappingCount();
index 63c579c..86aba2d 100644 (file)
@@ -1,3 +1,23 @@
+2012-05-14  Michael Saboff  <msaboff@apple.com>
+
+        Enh: Add the Ability to Disable / Enable JavaScript GC Timer
+        https://bugs.webkit.org/show_bug.cgi?id=86382
+
+        Reviewed by Darin Adler.
+
+        Plumbing to set / clear JS GC activity timer enable flag.
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetJavaScriptGarbageCollectorTimerEnabled):
+        * UIProcess/API/C/WKContext.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::setJavaScriptGarbageCollectorTimerEnabled):
+        * UIProcess/WebContext.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::setJavaScriptGarbageCollectorTimerEnabled):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
 2012-05-14  Anders Carlsson  <andersca@apple.com>
 
         The "plug-in was blocked" callback needs to include enough info to uniquely identify the plug-in + version
index 8890e80..9f6dbbc 100644 (file)
@@ -265,6 +265,10 @@ void WKContextGarbageCollectJavaScriptObjects(WKContextRef contextRef)
     toImpl(contextRef)->garbageCollectJavaScriptObjects();
 }
 
+void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef contextRef, bool enable)
+{
+    toImpl(contextRef)->setJavaScriptGarbageCollectorTimerEnabled(enable);
+}
 // Deprecated functions.
 void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory)
 {
index f0ae594..f4299da 100644 (file)
@@ -156,6 +156,7 @@ typedef void (*WKContextGetStatisticsFunction)(WKDictionaryRef statistics, WKErr
 WK_EXPORT void WKContextGetStatistics(WKContextRef context, void* functionContext, WKContextGetStatisticsFunction function);
     
 WK_EXPORT void WKContextGarbageCollectJavaScriptObjects(WKContextRef context);
+WK_EXPORT void WKContextSetJavaScriptGarbageCollectorTimerEnabled(WKContextRef context, bool enable);
 
 #ifdef __cplusplus
 }
index 8ebd9b6..6987405 100644 (file)
@@ -956,6 +956,11 @@ void WebContext::garbageCollectJavaScriptObjects()
     sendToAllProcesses(Messages::WebProcess::GarbageCollectJavaScriptObjects());
 }
 
+void WebContext::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
+{
+    sendToAllProcesses(Messages::WebProcess::SetJavaScriptGarbageCollectorTimerEnabled(flag));
+}
+
 void WebContext::didReceiveMessageOnConnectionWorkQueue(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, bool& didHandleMessage)
 {
     if (messageID.is<CoreIPC::MessageClassWebContext>()) {
index 50aa579..fa4567f 100644 (file)
@@ -194,6 +194,7 @@ public:
     
     void getWebCoreStatistics(PassRefPtr<DictionaryCallback>);
     void garbageCollectJavaScriptObjects();
+    void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
 
 #if PLATFORM(MAC)
     static bool omitPDFSupport();
index d6e2b24..f292334 100644 (file)
@@ -962,6 +962,11 @@ void WebProcess::garbageCollectJavaScriptObjects()
     gcController().garbageCollectNow();
 }
 
+void WebProcess::setJavaScriptGarbageCollectorTimerEnabled(bool flag)
+{
+    gcController().setJavaScriptGarbageCollectorTimerEnabled(flag);
+}
+
 #if ENABLE(PLUGIN_PROCESS)
 void WebProcess::pluginProcessCrashed(CoreIPC::Connection*, const String& pluginPath)
 {
index 91915d6..e6fac2c 100644 (file)
@@ -216,6 +216,7 @@ private:
     
     void getWebCoreStatistics(uint64_t callbackID);
     void garbageCollectJavaScriptObjects();
+    void setJavaScriptGarbageCollectorTimerEnabled(bool flag);
 
 #if PLATFORM(MAC)
     void secItemResponse(CoreIPC::Connection*, uint64_t requestID, const SecItemResponseData&);
index b7bc720..4fbfd2a 100644 (file)
@@ -77,6 +77,7 @@ messages -> WebProcess {
 
     GetWebCoreStatistics(uint64_t callbackID)
     GarbageCollectJavaScriptObjects()
+    SetJavaScriptGarbageCollectorTimerEnabled(bool enable)
 
 #if PLATFORM(MAC)
     SecItemResponse(uint64_t requestID, WebKit::SecItemResponseData response) DispatchOnConnectionQueue