Title: [124431] trunk/Source/WebCore
Revision
124431
Author
[email protected]
Date
2012-08-02 02:26:37 -0700 (Thu, 02 Aug 2012)

Log Message

[chromium] Improve garbage collector hint if page uses Canvas contexts
https://bugs.webkit.org/show_bug.cgi?id=92856

Patch by [email protected] <[email protected]> on 2012-08-02
Reviewed by Kentaro Hara.

Request GC by sending context disposed and idle notification to V8 instead
of sending low memory notification. It is faster as it causes one GC
instead of seven GCs caused by low memory notification.

* bindings/v8/V8Binding.cpp:
(WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData):
* bindings/v8/V8Binding.h:
(V8BindingPerIsolateData):
(WebCore::V8BindingPerIsolateData::setShouldCollectGarbageSoon):
(WebCore::V8BindingPerIsolateData::clearShouldCollectGarbageSoon):
(WebCore::V8BindingPerIsolateData::shouldCollectGarbageSoon):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::hintForGCIfNecessary):
* bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
(WebCore::V8HTMLCanvasElement::getContextCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124430 => 124431)


--- trunk/Source/WebCore/ChangeLog	2012-08-02 09:18:58 UTC (rev 124430)
+++ trunk/Source/WebCore/ChangeLog	2012-08-02 09:26:37 UTC (rev 124431)
@@ -1,3 +1,26 @@
+2012-08-02  [email protected]  <[email protected]>
+
+        [chromium] Improve garbage collector hint if page uses Canvas contexts
+        https://bugs.webkit.org/show_bug.cgi?id=92856
+
+        Reviewed by Kentaro Hara.
+
+        Request GC by sending context disposed and idle notification to V8 instead
+        of sending low memory notification. It is faster as it causes one GC
+        instead of seven GCs caused by low memory notification.
+
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData):
+        * bindings/v8/V8Binding.h:
+        (V8BindingPerIsolateData):
+        (WebCore::V8BindingPerIsolateData::setShouldCollectGarbageSoon):
+        (WebCore::V8BindingPerIsolateData::clearShouldCollectGarbageSoon):
+        (WebCore::V8BindingPerIsolateData::shouldCollectGarbageSoon):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::hintForGCIfNecessary):
+        * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
+        (WebCore::V8HTMLCanvasElement::getContextCallback):
+
 2012-08-02  Mihnea Ovidenie  <[email protected]>
 
         CSSRegions: Crash when reattaching a region to a named flow.

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (124430 => 124431)


--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-08-02 09:18:58 UTC (rev 124430)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-08-02 09:26:37 UTC (rev 124431)
@@ -60,7 +60,7 @@
 #ifndef NDEBUG
     , m_internalScriptRecursionLevel(0)
 #endif
-    , m_lowMemoryNotificationHint(false)
+    , m_shouldCollectGarbageSoon(false)
 {
 }
 

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.h (124430 => 124431)


--- trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-08-02 09:18:58 UTC (rev 124430)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.h	2012-08-02 09:26:37 UTC (rev 124431)
@@ -220,13 +220,13 @@
 
         void reportMemoryUsage(MemoryObjectInfo*) const;
 
-        // Gives the system a hint that we should send a low memory
-        // notification upon the next close or navigation event,
-        // because some expensive objects have been allocated that we
-        // want to take every opportunity to collect.
-        void setLowMemoryNotificationHint() { m_lowMemoryNotificationHint = true; }
-        void clearLowMemoryNotificationHint() { m_lowMemoryNotificationHint = false; }
-        bool isLowMemoryNotificationHint() const { return m_lowMemoryNotificationHint; }
+        // Gives the system a hint that we should request garbage collection
+        // upon the next close or navigation event, because some expensive
+        // objects have been allocated that we want to take every opportunity
+        // to collect.
+        void setShouldCollectGarbageSoon() { m_shouldCollectGarbageSoon = true; }
+        void clearShouldCollectGarbageSoon() { m_shouldCollectGarbageSoon = false; }
+        bool shouldCollectGarbageSoon() const { return m_shouldCollectGarbageSoon; }
 
     private:
         explicit V8BindingPerIsolateData(v8::Isolate*);
@@ -257,7 +257,7 @@
 #endif
         GCEventData m_gcEventData;
 
-        bool m_lowMemoryNotificationHint;
+        bool m_shouldCollectGarbageSoon;
     };
 
     class ConstructorMode {

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (124430 => 124431)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-02 09:18:58 UTC (rev 124430)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-02 09:26:37 UTC (rev 124431)
@@ -562,9 +562,11 @@
 void V8Proxy::hintForGCIfNecessary()
 {
     V8BindingPerIsolateData* data = ""
-    if (data->isLowMemoryNotificationHint()) {
-        data->clearLowMemoryNotificationHint();
-        v8::V8::LowMemoryNotification();
+    if (data->shouldCollectGarbageSoon()) {
+        const int longIdlePauseInMs = 1000;
+        data->clearShouldCollectGarbageSoon();
+        v8::V8::ContextDisposedNotification();
+        v8::V8::IdleNotification(longIdlePauseInMs);
     }
 }
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp (124430 => 124431)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp	2012-08-02 09:18:58 UTC (rev 124430)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp	2012-08-02 09:26:37 UTC (rev 124431)
@@ -91,7 +91,7 @@
     // want to take an opportunity to get rid of them as soon as possible when we
     // navigate away from pages using them.
     V8BindingPerIsolateData* perIsolateData = V8BindingPerIsolateData::current(args.GetIsolate());
-    perIsolateData->setLowMemoryNotificationHint();
+    perIsolateData->setShouldCollectGarbageSoon();
 
     if (result->is2d())
         return toV8(static_cast<CanvasRenderingContext2D*>(result), args.GetIsolate());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to