<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185387] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185387">185387</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-06-09 15:15:36 -0700 (Tue, 09 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Allow one sync GC per gcTimer interval on critical memory pressure warning
https://bugs.webkit.org/show_bug.cgi?id=145773

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

On critical memory pressure warning, we were calling GCController::garbageCollectSoon(),
which does not offer any guarantee on when the garbage collection will actually take
place.

On critical memory pressure, we need to free up memory as soon as possible to avoid
getting killed so this is an issue. Also, the fact that we clear the PageCache on
critical memory pressure means a GC would likely be useful, even if the last
collection did not free much memory.

This patch adds a new GCController::garbageCollectNowIfNotDoneRecently() API that allows
one synchronous GC per gcTimer interval on critical memory pressure warning. This makes
us more responsive to critical memory pressure and avoids doing synchronous GCs too
often.

* heap/FullGCActivityCallback.cpp:
(JSC::FullGCActivityCallback::doCollection):
* heap/FullGCActivityCallback.h:
(JSC::GCActivityCallback::createFullTimer):
* heap/GCActivityCallback.h:
* heap/Heap.cpp:
(JSC::Heap::collectAllGarbageIfNotDoneRecently):
* heap/Heap.h:

* heap/IncrementalSweeper.cpp:
(JSC::IncrementalSweeper::doWork): Deleted.
* heap/IncrementalSweeper.h:

Drop fullSweep() API as it no longer seems useful. garbageCollectNow()
already does a sweep after the full collection.

Source/WebCore:

* bindings/js/GCController.cpp:
(WebCore::GCController::garbageCollectNowIfNotDoneRecently):

Add new GCController::garbageCollectNowIfNotDoneRecently() API that
allows one synchronous GC per full GC timer interval. If called more
than once per interval, it becomes equivalent to garbageCollectSoon()
and merely accelerates the next collection.

* bindings/js/GCController.h:
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseCriticalMemory):

Call the new GCController::garbageCollectNowIfNotDoneRecently() on
critical memory pressure instead of garbageCollectionSoon() to try
as do a synchronous GC if one wasn't already done recently.
Also drop call to fullSweep() as GCController::garbageCollectNow*()
already do a sweep after the collection.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapFullGCActivityCallbackcpp">trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapFullGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/GCActivityCallback.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeapcpp">trunk/Source/JavaScriptCore/heap/Heap.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapHeaph">trunk/Source/JavaScriptCore/heap/Heap.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapIncrementalSweepercpp">trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapIncrementalSweeperh">trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsGCControllercpp">trunk/Source/WebCore/bindings/js/GCController.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsGCControllerh">trunk/Source/WebCore/bindings/js/GCController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlercpp">trunk/Source/WebCore/platform/MemoryPressureHandler.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-06-09  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Allow one sync GC per gcTimer interval on critical memory pressure warning
+        https://bugs.webkit.org/show_bug.cgi?id=145773
+
+        Reviewed by Geoffrey Garen.
+
+        On critical memory pressure warning, we were calling GCController::garbageCollectSoon(),
+        which does not offer any guarantee on when the garbage collection will actually take
+        place.
+
+        On critical memory pressure, we need to free up memory as soon as possible to avoid
+        getting killed so this is an issue. Also, the fact that we clear the PageCache on
+        critical memory pressure means a GC would likely be useful, even if the last
+        collection did not free much memory.
+
+        This patch adds a new GCController::garbageCollectNowIfNotDoneRecently() API that allows
+        one synchronous GC per gcTimer interval on critical memory pressure warning. This makes
+        us more responsive to critical memory pressure and avoids doing synchronous GCs too
+        often.
+
+        * heap/FullGCActivityCallback.cpp:
+        (JSC::FullGCActivityCallback::doCollection):
+        * heap/FullGCActivityCallback.h:
+        (JSC::GCActivityCallback::createFullTimer):
+        * heap/GCActivityCallback.h:
+        * heap/Heap.cpp:
+        (JSC::Heap::collectAllGarbageIfNotDoneRecently):
+        * heap/Heap.h:
+
+        * heap/IncrementalSweeper.cpp:
+        (JSC::IncrementalSweeper::doWork): Deleted.
+        * heap/IncrementalSweeper.h:
+
+        Drop fullSweep() API as it no longer seems useful. garbageCollectNow()
+        already does a sweep after the full collection.
+
</ins><span class="cx"> 2015-06-09  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] CodeBlock::m_constantRegisters should be sized-to-fit.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapFullGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.cpp        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -43,18 +43,19 @@
</span><span class="cx"> 
</span><span class="cx"> void FullGCActivityCallback::doCollection()
</span><span class="cx"> {
</span><del>-    Heap* heap = &amp;m_vm-&gt;heap;
</del><ins>+    Heap&amp; heap = m_vm-&gt;heap;
+    m_didSyncGCRecently = false;
</ins><span class="cx"> 
</span><span class="cx"> #if !PLATFORM(IOS)
</span><span class="cx">     double startTime = WTF::monotonicallyIncreasingTime();
</span><del>-    if (heap-&gt;isPagedOut(startTime + pagingTimeOut)) {
</del><ins>+    if (heap.isPagedOut(startTime + pagingTimeOut)) {
</ins><span class="cx">         cancel();
</span><del>-        heap-&gt;increaseLastFullGCLength(pagingTimeOut);
</del><ins>+        heap.increaseLastFullGCLength(pagingTimeOut);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    heap-&gt;collect(FullCollection);
</del><ins>+    heap.collect(FullCollection);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double FullGCActivityCallback::lastGCLength()
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapFullGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/FullGCActivityCallback.h        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -36,6 +36,9 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void doCollection() override;
</span><span class="cx"> 
</span><ins>+    bool didSyncGCRecently() const { return m_didSyncGCRecently; }
+    void setDidSyncGCRecently() { m_didSyncGCRecently = true; }
+
</ins><span class="cx"> protected:
</span><span class="cx"> #if USE(CF)
</span><span class="cx">     FullGCActivityCallback(Heap* heap, CFRunLoopRef runLoop)
</span><span class="lines">@@ -47,9 +50,11 @@
</span><span class="cx">     virtual double lastGCLength() override;
</span><span class="cx">     virtual double gcTimeSlice(size_t bytes) override;
</span><span class="cx">     virtual double deathRate() override;
</span><ins>+
+    bool m_didSyncGCRecently { false };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline RefPtr&lt;GCActivityCallback&gt; GCActivityCallback::createFullTimer(Heap* heap)
</del><ins>+inline RefPtr&lt;FullGCActivityCallback&gt; GCActivityCallback::createFullTimer(Heap* heap)
</ins><span class="cx"> {
</span><span class="cx">     return s_shouldCreateGCTimer ? adoptRef(new FullGCActivityCallback(heap)) : nullptr;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/GCActivityCallback.h (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -38,12 +38,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace JSC {
</span><span class="cx"> 
</span><ins>+class FullGCActivityCallback;
</ins><span class="cx"> class Heap;
</span><span class="cx"> 
</span><span class="cx"> class JS_EXPORT_PRIVATE GCActivityCallback : public HeapTimer, public ThreadSafeRefCounted&lt;GCActivityCallback&gt; {
</span><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>-    static RefPtr&lt;GCActivityCallback&gt; createFullTimer(Heap*);
</del><ins>+    static RefPtr&lt;FullGCActivityCallback&gt; createFullTimer(Heap*);
</ins><span class="cx">     static RefPtr&lt;GCActivityCallback&gt; createEdenTimer(Heap*);
</span><span class="cx"> 
</span><span class="cx">     GCActivityCallback(Heap*);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeapcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.cpp (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.cpp        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/Heap.cpp        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -1408,6 +1408,23 @@
</span><span class="cx">     m_compiledCode.append(executable);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Heap::collectAllGarbageIfNotDoneRecently()
+{
+    if (!m_fullActivityCallback) {
+        collectAllGarbage();
+        return;
+    }
+
+    if (m_fullActivityCallback-&gt;didSyncGCRecently()) {
+        // A synchronous GC was already requested recently so we merely accelerate next collection.
+        reportAbandonedObjectGraph();
+        return;
+    }
+
+    m_fullActivityCallback-&gt;setDidSyncGCRecently();
+    collectAllGarbage();
+}
+
</ins><span class="cx"> class Zombify : public MarkedBlock::VoidFunctor {
</span><span class="cx"> public:
</span><span class="cx">     inline void visit(JSCell* cell)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapHeaph"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/Heap.h (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/Heap.h        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/Heap.h        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -154,6 +154,7 @@
</span><span class="cx">     void notifyIsSafeToCollect() { m_isSafeToCollect = true; }
</span><span class="cx">     bool isSafeToCollect() const { return m_isSafeToCollect; }
</span><span class="cx"> 
</span><ins>+    JS_EXPORT_PRIVATE void collectAllGarbageIfNotDoneRecently();
</ins><span class="cx">     void collectAllGarbage() { collectAndSweep(FullCollection); }
</span><span class="cx">     JS_EXPORT_PRIVATE void collectAndSweep(HeapOperation collectionType = AnyCollection);
</span><span class="cx">     bool shouldCollect();
</span><span class="lines">@@ -394,7 +395,7 @@
</span><span class="cx">     Vector&lt;WeakBlock*&gt; m_logicallyEmptyWeakBlocks;
</span><span class="cx">     size_t m_indexOfNextLogicallyEmptyWeakBlockToSweep { WTF::notFound };
</span><span class="cx">     
</span><del>-    RefPtr&lt;GCActivityCallback&gt; m_fullActivityCallback;
</del><ins>+    RefPtr&lt;FullGCActivityCallback&gt; m_fullActivityCallback;
</ins><span class="cx">     RefPtr&lt;GCActivityCallback&gt; m_edenActivityCallback;
</span><span class="cx">     std::unique_ptr&lt;IncrementalSweeper&gt; m_sweeper;
</span><span class="cx">     Vector&lt;MarkedBlock*&gt; m_blockSnapshot;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapIncrementalSweepercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/IncrementalSweeper.cpp        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -59,11 +59,6 @@
</span><span class="cx">     CFRunLoopTimerSetNextFireDate(m_timer.get(), CFAbsoluteTimeGetCurrent() + s_decade);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IncrementalSweeper::fullSweep()
-{
-    while (sweepNextBlock()) { }
-}
-
</del><span class="cx"> void IncrementalSweeper::doWork()
</span><span class="cx"> {
</span><span class="cx">     doSweep(WTF::monotonicallyIncreasingTime());
</span><span class="lines">@@ -132,10 +127,6 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void IncrementalSweeper::fullSweep()
-{
-}
-
</del><span class="cx"> bool IncrementalSweeper::sweepNextBlock()
</span><span class="cx"> {
</span><span class="cx">     return false;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapIncrementalSweeperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/JavaScriptCore/heap/IncrementalSweeper.h        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -43,7 +43,6 @@
</span><span class="cx">     explicit IncrementalSweeper(VM*);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    JS_EXPORT_PRIVATE void fullSweep();
</del><span class="cx">     void startSweeping();
</span><span class="cx"> 
</span><span class="cx">     JS_EXPORT_PRIVATE virtual void doWork() override;
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/WebCore/ChangeLog        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2015-06-09  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Allow one sync GC per gcTimer interval on critical memory pressure warning
+        https://bugs.webkit.org/show_bug.cgi?id=145773
+
+        Reviewed by Geoffrey Garen.
+
+        * bindings/js/GCController.cpp:
+        (WebCore::GCController::garbageCollectNowIfNotDoneRecently):
+
+        Add new GCController::garbageCollectNowIfNotDoneRecently() API that
+        allows one synchronous GC per full GC timer interval. If called more
+        than once per interval, it becomes equivalent to garbageCollectSoon()
+        and merely accelerates the next collection.
+
+        * bindings/js/GCController.h:
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+
+        Call the new GCController::garbageCollectNowIfNotDoneRecently() on
+        critical memory pressure instead of garbageCollectionSoon() to try
+        as do a synchronous GC if one wasn't already done recently.
+        Also drop call to fullSweep() as GCController::garbageCollectNow*()
+        already do a sweep after the collection.
+
</ins><span class="cx"> 2015-06-09  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Follow-up fix for:
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsGCControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/GCController.cpp (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/GCController.cpp        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/WebCore/bindings/js/GCController.cpp        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -90,6 +90,17 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GCController::garbageCollectNowIfNotDoneRecently()
+{
+#if USE(CF)
+    JSLockHolder lock(JSDOMWindow::commonVM());
+    if (!JSDOMWindow::commonVM().heap.isBusy())
+        JSDOMWindow::commonVM().heap.collectAllGarbageIfNotDoneRecently();
+#else
+    garbageCollectSoon();
+#endif
+}
+
</ins><span class="cx"> void GCController::garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone)
</span><span class="cx"> {
</span><span class="cx">     ThreadIdentifier threadID = createThread(collect, 0, &quot;WebCore: GCController&quot;);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsGCControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/GCController.h (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/GCController.h        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/WebCore/bindings/js/GCController.h        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -40,6 +40,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void garbageCollectSoon();
</span><span class="cx">     WEBCORE_EXPORT void garbageCollectNow(); // It's better to call garbageCollectSoon, unless you have a specific reason not to.
</span><ins>+    WEBCORE_EXPORT void garbageCollectNowIfNotDoneRecently();
</ins><span class="cx">     void garbageCollectOnNextRunLoop();
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT void garbageCollectOnAlternateThreadForDebugging(bool waitUntilDone); // Used for stress testing.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (185386 => 185387)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2015-06-09 22:12:41 UTC (rev 185386)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2015-06-09 22:15:36 UTC (rev 185387)
</span><span class="lines">@@ -139,19 +139,8 @@
</span><span class="cx">     if (synchronous == Synchronous::Yes) {
</span><span class="cx">         ReliefLogger log(&quot;Collecting JavaScript garbage&quot;);
</span><span class="cx">         GCController::singleton().garbageCollectNow();
</span><del>-    } else {
-        // FIXME: We should do a garbage sweep and prune dead resources from the MemoryCache
-        // after the garbage collection has completed to free up more memory.
-        GCController::singleton().garbageCollectSoon();
-
-        // Do a full sweep of collected objects. garbageCollectNow() already does this so we only
-        // need to do this if it isn't called.
-        {
-            ReliefLogger log(&quot;Full JavaScript garbage sweep&quot;);
-            JSC::JSLockHolder lock(JSDOMWindow::commonVM());
-            JSDOMWindow::commonVM().heap.sweeper()-&gt;fullSweep();
-        }
-    }
</del><ins>+    } else
+        GCController::singleton().garbageCollectNowIfNotDoneRecently();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MemoryPressureHandler::releaseMemory(Critical critical, Synchronous synchronous)
</span></span></pre>
</div>
</div>

</body>
</html>