WebCore shouldn't call collectAllGarbage directly
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Apr 2012 05:08:06 +0000 (05:08 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Apr 2012 05:08:06 +0000 (05:08 +0000)
commit26d3122f7eb582704e659188237e5cb876f641c2
tree9777091babac8b7691dcc5cfc28a5bcc336b8f9c
parent9fc2d47ec2fbe1d3dcecc7263f7a26119a11f720
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: https://svn.webkit.org/repository/webkit/trunk@115288 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
Source/JavaScriptCore/heap/Heap.h
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/bindings/js/GCController.cpp
Source/WebCore/bindings/js/GCController.h
Source/WebCore/bindings/js/ScriptProfiler.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebProcess.cpp