GC (almost) immediately when navigating under memory pressure.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 01:06:45 +0000 (01:06 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Feb 2015 01:06:45 +0000 (01:06 +0000)
commit5bb11813f06eea071f3932eefa52b99278b9c1d7
tree1cd5f04760f9c716308596b3b5bd9f53c784ef1d
parent752ee4c583f9cc567f89bd7edf4683d280a9f751
GC (almost) immediately when navigating under memory pressure.
<https://webkit.org/b/141663>

Reviewed by Geoffrey Garen.

Since the PageCache is already disabled in memory pressure situations,
we know that detaching the old window shell on navigation is basically
guaranteed to generate a bunch of garbage, we can soften the memory
peak a bit by doing a GC right away instead of scheduling one for soon(tm).

* bindings/js/GCController.cpp:
(WebCore::GCController::GCController):
(WebCore::GCController::garbageCollectSoon):
(WebCore::GCController::garbageCollectOnNextRunLoop):
(WebCore::GCController::gcTimerFired):
* bindings/js/GCController.h:

    Add a GCController::garbageCollectOnNextRunLoop() complement to the
    "soon" and "now" options. There was already a zero timer in here for
    non-CF builds, so I just used that same timer to implement this
    and have the non-CF code path call garbageCollectOnNextRunLoop().

* bindings/js/ScriptController.cpp:
(WebCore::collectGarbageAfterWindowShellDestruction):
(WebCore::ScriptController::~ScriptController):
(WebCore::ScriptController::clearWindowShell):

    Under system memory pressure conditions, schedule a full GC on next
    runloop iteration instead of just asking for it to happen soon.
    We do it on next runloop to ensure that there's no pointer to the
    window object on the stack.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180192 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/GCController.cpp
Source/WebCore/bindings/js/GCController.h
Source/WebCore/bindings/js/ScriptController.cpp