[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:23:46 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 0e8293c52583ea23e332c3b0c05d1efae7b81426
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 5 15:36:14 2009 +0000

    2009-11-05  Anton Muhin  <antonm at chromium.org>
    
            Reviewed by Adam Barth.
    
            If high memory usage is detected, hint to V8 that it might be due
            to external objects retained by V8 objects.
            https://bugs.webkit.org/show_bug.cgi?id=31051
    
            * bindings/v8/V8GCController.cpp:
            (WebCore::GetMemoryUsageInMB):
            (WebCore::V8GCController::gcEpilogue):
            (WebCore::V8GCController::checkMemoryUsage):
            * bindings/v8/V8GCController.h:
            * bindings/v8/V8Proxy.cpp:
            (WebCore::V8Proxy::evaluate):
            (WebCore::V8Proxy::runScript):
            (WebCore::V8Proxy::callFunction):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50562 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b99dc2a..f35b349 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,21 @@
+2009-11-05  Anton Muhin  <antonm at chromium.org>
+
+        Reviewed by Adam Barth.
+
+        If high memory usage is detected, hint to V8 that it might be due
+        to external objects retained by V8 objects.
+        https://bugs.webkit.org/show_bug.cgi?id=31051
+
+        * bindings/v8/V8GCController.cpp:
+        (WebCore::GetMemoryUsageInMB):
+        (WebCore::V8GCController::gcEpilogue):
+        (WebCore::V8GCController::checkMemoryUsage):
+        * bindings/v8/V8GCController.h:
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::evaluate):
+        (WebCore::V8Proxy::runScript):
+        (WebCore::V8Proxy::callFunction):
+
 2009-11-05  Jeff Schiller  <codedread at gmail.com>
 
         Reviewed by Simon Fraser.
diff --git a/WebCore/bindings/v8/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp
index a1dc819..bd545bb 100644
--- a/WebCore/bindings/v8/V8GCController.cpp
+++ b/WebCore/bindings/v8/V8GCController.cpp
@@ -416,6 +416,17 @@ ACTIVE_DOM_OBJECT_TYPES(MAKE_CASE)
     }
 };
 
+int V8GCController::workingSetEstimateMB = 0;
+
+namespace {
+
+int getMemoryUsageInMB()
+{
+    return ChromiumBridge::memoryUsageMB();
+}
+
+}  // anonymous namespace
+
 void V8GCController::gcEpilogue()
 {
     v8::HandleScope scope;
@@ -425,6 +436,8 @@ void V8GCController::gcEpilogue()
     GCEpilogueVisitor epilogueVisitor;
     visitActiveDOMObjectsInCurrentThread(&epilogueVisitor);
 
+    workingSetEstimateMB = getMemoryUsageInMB();
+
 #ifndef NDEBUG
     // Check all survivals are weak.
     DOMObjectVisitor domObjectVisitor;
@@ -438,4 +451,16 @@ void V8GCController::gcEpilogue()
 #endif
 }
 
+void V8GCController::checkMemoryUsage()
+{
+    const int lowUsageMB = 256;  // If memory usage is below this threshold, do not bother forcing GC.
+    const int highUsageMB = 1024;  // If memory usage is above this threshold, force GC more aggresively.
+    const int highUsageDeltaMB = 128;  // Delta of memory usage growth (vs. last workingSetEstimateMB) to force GC when memory usage is high.
+
+    int memoryUsageMB = getMemoryUsageInMB();
+    if ((memoryUsageMB > lowUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB))
+        v8::V8::LowMemoryNotification();
+}
+
+
 }  // namespace WebCore
diff --git a/WebCore/bindings/v8/V8GCController.h b/WebCore/bindings/v8/V8GCController.h
index 7441bf0..484be24 100644
--- a/WebCore/bindings/v8/V8GCController.h
+++ b/WebCore/bindings/v8/V8GCController.h
@@ -78,6 +78,12 @@ namespace WebCore {
 
         static void gcPrologue();
         static void gcEpilogue();
+
+        static void checkMemoryUsage();
+
+    private:
+        // Estimate of current working set.
+        static int workingSetEstimateMB;
     };
 
 }
diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp
index defdb27..161d630 100644
--- a/WebCore/bindings/v8/V8Proxy.cpp
+++ b/WebCore/bindings/v8/V8Proxy.cpp
@@ -374,6 +374,8 @@ v8::Local<v8::Value> V8Proxy::evaluate(const ScriptSourceCode& source, Node* nod
 {
     ASSERT(v8::Context::InContext());
 
+    V8GCController::checkMemoryUsage();
+
 #if ENABLE(INSPECTOR)
     if (InspectorTimelineAgent* timelineAgent = m_frame->page() ? m_frame->page()->inspectorTimelineAgent() : 0)
         timelineAgent->willEvaluateScript(source.url().isNull() ? String() : source.url().string(), source.startLine());
@@ -418,6 +420,7 @@ v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script, bool isIn
     if (script.IsEmpty())
         return notHandledByInterceptor();
 
+    V8GCController::checkMemoryUsage();
     // Compute the source string and prevent against infinite recursion.
     if (m_recursion >= kMaxRecursionDepth) {
         v8::Local<v8::String> code = v8ExternalString("throw RangeError('Recursion too deep')");
@@ -472,6 +475,7 @@ v8::Local<v8::Value> V8Proxy::runScript(v8::Handle<v8::Script> script, bool isIn
 
 v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8::Handle<v8::Object> receiver, int argc, v8::Handle<v8::Value> args[])
 {
+    V8GCController::checkMemoryUsage();
     v8::Local<v8::Value> result;
     {
         V8ConsoleMessage::Scope scope;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list