Commit 34edae48 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com

WebCore shouldn't call collectAllGarbage directly

https://bugs.webkit.org/show_bug.cgi?id=84897

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Exported symbol
for reportAbanondedObjectGraph so WebCore can use it.
* heap/Heap.h: Ditto.

Source/WebCore:

No new tests.

Currently, GCController calls Heap::collectAllGarbage directly, which leads
to an overload of collections as the timer in GCController and the timer in
GCActivityCallback compete for collection time and fire independently. As a
result, we end up doing almost 600 full collections during an in-browser run
of SunSpider, or 20 full collections on a single load of TechCrunch.

We can do better by preventing WebCore from calling collectAllGarbage directly
and instead going through Heap::reportAbandonedObjectGraph, since that is what
WebCore is trying to do--notify the Heap that a lot of garbage may have just
been generated when we left a page.

* WebCore.exp.in:
* bindings/js/GCController.cpp: Removed all timer stuff.
(WebCore::GCController::GCController):
(WebCore::GCController::garbageCollectSoon): Changed to call Heap::reportAbandonedObjectGraph.
(WebCore::GCController::garbageCollectNow): Changed to still directly call collectAllGarbage.
We will deprecate this function soon hopefully.
* bindings/js/GCController.h: Removed timer stuff.
(GCController):
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::collectGarbage): Changed to call garbageCollectSoon.

Source/WebKit2:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didClose): Changed to call garbageCollectSoon. This is the
function that causes us to do so much collection on page navigation.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@115288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent dcddfdb7
2012-04-25 Mark Hahnenberg <mhahnenberg@apple.com>
WebCore shouldn't call collectAllGarbage directly
https://bugs.webkit.org/show_bug.cgi?id=84897
Reviewed by Geoffrey Garen.
* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: Exported symbol
for reportAbanondedObjectGraph so WebCore can use it.
* heap/Heap.h: Ditto.
2012-04-25 Oliver Hunt <oliver@apple.com>
Biolab disaster crashes on ToT
......@@ -280,6 +280,7 @@ EXPORTS
?releaseDecommitted@OSAllocator@WTF@@SAXPAXI@Z
?releaseExecutableMemory@JSGlobalData@JSC@@QAEXXZ
?removeBlock@MarkedAllocator@JSC@@QAEXPAVMarkedBlock@2@@Z
?reportAbandonedObjectGraph@Heap@JSC@@QAEXXZ
?reportExtraMemoryCostSlowCase@Heap@JSC@@AAEXI@Z
?reserveAndCommit@OSAllocator@WTF@@SAPAXIW4Usage@12@_N11@Z
?reserveCapacity@StringBuilder@WTF@@QAEXI@Z
......
......@@ -119,7 +119,7 @@ namespace JSC {
void collect(SweepToggle);
void reportExtraMemoryCost(size_t cost);
void reportAbandonedObjectGraph();
JS_EXPORT_PRIVATE void reportAbandonedObjectGraph();
JS_EXPORT_PRIVATE void protect(JSValue);
JS_EXPORT_PRIVATE bool unprotect(JSValue); // True when the protect count drops to 0.
......
2012-04-25 Mark Hahnenberg <mhahnenberg@apple.com>
WebCore shouldn't call collectAllGarbage directly
https://bugs.webkit.org/show_bug.cgi?id=84897
Reviewed by Geoffrey Garen.
No new tests.
Currently, GCController calls Heap::collectAllGarbage directly, which leads
to an overload of collections as the timer in GCController and the timer in
GCActivityCallback compete for collection time and fire independently. As a
result, we end up doing almost 600 full collections during an in-browser run
of SunSpider, or 20 full collections on a single load of TechCrunch.
We can do better by preventing WebCore from calling collectAllGarbage directly
and instead going through Heap::reportAbandonedObjectGraph, since that is what
WebCore is trying to do--notify the Heap that a lot of garbage may have just
been generated when we left a page.
* WebCore.exp.in:
* bindings/js/GCController.cpp: Removed all timer stuff.
(WebCore::GCController::GCController):
(WebCore::GCController::garbageCollectSoon): Changed to call Heap::reportAbandonedObjectGraph.
(WebCore::GCController::garbageCollectNow): Changed to still directly call collectAllGarbage.
We will deprecate this function soon hopefully.
* bindings/js/GCController.h: Removed timer stuff.
(GCController):
* bindings/js/ScriptProfiler.cpp:
(WebCore::ScriptProfiler::collectGarbage): Changed to call garbageCollectSoon.
2012-04-25 James Robinson <jamesr@chromium.org>
[chromium] REGRESSION(112286) Compositor initialization blocks for program compilation / linking
......@@ -250,6 +250,7 @@ __ZN7WebCore12EventHandler8keyEventEP7NSEvent
__ZN7WebCore12EventHandler8keyEventERKNS_21PlatformKeyboardEventE
__ZN7WebCore12EventHandler9mouseDownEP7NSEvent
__ZN7WebCore12GCController17garbageCollectNowEv
__ZN7WebCore12GCController18garbageCollectSoonEv
__ZN7WebCore12GCController43garbageCollectOnAlternateThreadForDebuggingEb
__ZN7WebCore12PopupMenuMacC1EPNS_15PopupMenuClientE
__ZN7WebCore12PrintContext12pagePropertyEPNS_5FrameEPKci
......
......@@ -49,26 +49,20 @@ GCController& gcController()
}
GCController::GCController()
: m_GCTimer(this, &GCController::gcTimerFired)
{
}
void GCController::garbageCollectSoon()
{
if (!m_GCTimer.isActive())
m_GCTimer.startOneShot(0);
}
void GCController::gcTimerFired(Timer<GCController>*)
{
collect(0);
JSLock lock(SilenceAssertionsOnly);
JSDOMWindow::commonJSGlobalData()->heap.reportAbandonedObjectGraph();
}
void GCController::garbageCollectNow()
{
JSLock lock(SilenceAssertionsOnly);
if (!JSDOMWindow::commonJSGlobalData()->heap.isBusy())
collect(0);
JSDOMWindow::commonJSGlobalData()->heap.collectAllGarbage();
}
void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone)
......
......@@ -26,7 +26,8 @@
#ifndef GCController_h
#define GCController_h
#include "Timer.h"
#include <wtf/FastAllocBase.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
......@@ -44,9 +45,6 @@ namespace WebCore {
private:
GCController(); // Use gcController() instead
void gcTimerFired(Timer<GCController>*);
Timer<GCController> m_GCTimer;
};
// Function to obtain the global GC controller.
......
......@@ -43,7 +43,7 @@ namespace WebCore {
void ScriptProfiler::collectGarbage()
{
gcController().garbageCollectNow();
gcController().garbageCollectSoon();
}
ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned)
......
2012-04-25 Mark Hahnenberg <mhahnenberg@apple.com>
WebCore shouldn't call collectAllGarbage directly
https://bugs.webkit.org/show_bug.cgi?id=84897
Reviewed by Geoffrey Garen.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didClose): Changed to call garbageCollectSoon. This is the
function that causes us to do so much collection on page navigation.
2012-04-25 Beth Dakin <bdakin@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=84909
......@@ -686,7 +686,7 @@ void WebProcess::didClose(CoreIPC::Connection*)
pages[i]->close();
pages.clear();
gcController().garbageCollectNow();
gcController().garbageCollectSoon();
memoryCache()->setDisabled(true);
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment