<!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>[167277] 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/167277">167277</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-04-14 16:03:54 -0700 (Mon, 14 Apr 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Do more things under memory pressure on non-iOS platforms.
&lt;https://webkit.org/b/131625&gt;

Reviewed by Antti Koivisto.

Rename hasReceivedMemoryPressure() to isUnderMemoryPressure() and
make it use std::atomic&lt;bool&gt; instead of OSAtomic primitives.

Unmask most of the PLATFORM(IOS) blocks so all platforms can take
advantage of optimizations done while under pressure. Note that
isUnderMemoryPressure() will still always return false on platforms
other than iOS/WK1, but this will change soon.

* history/PageCache.cpp:
(WebCore::PageCache::canCache):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::commitProvisionalLoad):
* page/FrameView.cpp:
(WebCore::FrameView::willPaintContents):
(WebCore::FrameView::didPaintContents):
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::MemoryPressureHandler):
* platform/MemoryPressureHandler.h:
(WebCore::MemoryPressureHandler::isUnderMemoryPressure):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::setReceivedMemoryPressure):
(WebCore::MemoryPressureHandler::clearMemoryPressure):
(WebCore::MemoryPressureHandler::respondToMemoryPressureIfNeeded):
(WebCore::MemoryPressureHandler::hasReceivedMemoryPressure): Deleted.
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::purgeInactiveFontDataIfNeeded):
* platform/ios/LegacyTileCache.mm:
(WebCore::LegacyTileCache::createTilesInActiveGrid):
* platform/ios/LegacyTileGrid.mm:
(WebCore::LegacyTileGrid::shouldUseMinimalTileCoverage):
* platform/ios/LegacyTileLayerPool.mm:
(WebCore::LegacyTileLayerPool::addLayer):
* platform/ios/TileControllerMemoryHandlerIOS.cpp:
(WebCore::TileControllerMemoryHandler::tileControllerGainedUnparentedTiles):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorehistoryPageCachecpp">trunk/Source/WebCore/history/PageCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlercpp">trunk/Source/WebCore/platform/MemoryPressureHandler.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformMemoryPressureHandlerh">trunk/Source/WebCore/platform/MemoryPressureHandler.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm">trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsFontCachecpp">trunk/Source/WebCore/platform/graphics/FontCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileCachemm">trunk/Source/WebCore/platform/ios/LegacyTileCache.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileGridmm">trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLegacyTileLayerPoolmm">trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformiosTileControllerMemoryHandlerIOScpp">trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/ChangeLog        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2014-04-14  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Do more things under memory pressure on non-iOS platforms.
+        &lt;https://webkit.org/b/131625&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Rename hasReceivedMemoryPressure() to isUnderMemoryPressure() and
+        make it use std::atomic&lt;bool&gt; instead of OSAtomic primitives.
+
+        Unmask most of the PLATFORM(IOS) blocks so all platforms can take
+        advantage of optimizations done while under pressure. Note that
+        isUnderMemoryPressure() will still always return false on platforms
+        other than iOS/WK1, but this will change soon.
+
+        * history/PageCache.cpp:
+        (WebCore::PageCache::canCache):
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::willPaintContents):
+        (WebCore::FrameView::didPaintContents):
+        * platform/MemoryPressureHandler.cpp:
+        (WebCore::MemoryPressureHandler::MemoryPressureHandler):
+        * platform/MemoryPressureHandler.h:
+        (WebCore::MemoryPressureHandler::isUnderMemoryPressure):
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::setReceivedMemoryPressure):
+        (WebCore::MemoryPressureHandler::clearMemoryPressure):
+        (WebCore::MemoryPressureHandler::respondToMemoryPressureIfNeeded):
+        (WebCore::MemoryPressureHandler::hasReceivedMemoryPressure): Deleted.
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontCache::purgeInactiveFontDataIfNeeded):
+        * platform/ios/LegacyTileCache.mm:
+        (WebCore::LegacyTileCache::createTilesInActiveGrid):
+        * platform/ios/LegacyTileGrid.mm:
+        (WebCore::LegacyTileGrid::shouldUseMinimalTileCoverage):
+        * platform/ios/LegacyTileLayerPool.mm:
+        (WebCore::LegacyTileLayerPool::addLayer):
+        * platform/ios/TileControllerMemoryHandlerIOS.cpp:
+        (WebCore::TileControllerMemoryHandler::tileControllerGainedUnparentedTiles):
+
</ins><span class="cx"> 2014-04-14  Beth Dakin  &lt;bdakin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         RenderLayerCompositor's m_layerForOverhangAreas should be offset by the 
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -2557,7 +2557,6 @@
</span><span class="cx"> __ZN7WebCore20previousWordPositionERKNS_15VisiblePositionE
</span><span class="cx"> __ZN7WebCore21DeviceOrientationData6createEbdbdbdbdbd
</span><span class="cx"> __ZN7WebCore21MemoryPressureHandler19clearMemoryPressureEv
</span><del>-__ZN7WebCore21MemoryPressureHandler25hasReceivedMemoryPressureEv
</del><span class="cx"> __ZN7WebCore21MemoryPressureHandler25installMemoryReleaseBlockEU13block_pointerFvvEb
</span><span class="cx"> __ZN7WebCore21MemoryPressureHandler25setReceivedMemoryPressureENS_20MemoryPressureReasonE
</span><span class="cx"> __ZN7WebCore21MemoryPressureHandler31shouldWaitForMemoryClearMessageEv
</span></span></pre></div>
<a id="trunkSourceWebCorehistoryPageCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/history/PageCache.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/history/PageCache.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/history/PageCache.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -45,6 +45,7 @@
</span><span class="cx"> #include &quot;HistoryItem.h&quot;
</span><span class="cx"> #include &quot;Logging.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><ins>+#include &quot;MemoryPressureHandler.h&quot;
</ins><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;SharedWorkerRepository.h&quot;
</span><span class="lines">@@ -360,10 +361,8 @@
</span><span class="cx">     logCanCachePageDecision(page);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    if (memoryPressureHandler().hasReceivedMemoryPressure())
</del><ins>+    if (memoryPressureHandler().isUnderMemoryPressure())
</ins><span class="cx">         return false;
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     // Cache the page, if possible.
</span><span class="cx">     // Don't write to the cache if in the middle of a redirect, since we will want to
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -1757,7 +1757,7 @@
</span><span class="cx">     // page cache. We could still preemptively prune the page cache while navigating to a cached page if capacity &gt; 1.
</span><span class="cx">     // See &lt;rdar://problem/11779846&gt; for more details.
</span><span class="cx">     if (!cachedPage) {
</span><del>-        if (memoryPressureHandler().hasReceivedMemoryPressure()) {
</del><ins>+        if (memoryPressureHandler().isUnderMemoryPressure()) {
</ins><span class="cx">             LOG(MemoryPressure, &quot;Pruning page cache because under memory pressure at: %s&quot;, __PRETTY_FUNCTION__);
</span><span class="cx">             LOG(PageCache, &quot;Pruning page cache to 0 due to memory pressure&quot;);
</span><span class="cx">             // Don't cache any page if we are under memory pressure.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx"> #include &quot;InspectorController.h&quot;
</span><span class="cx"> #include &quot;InspectorInstrumentation.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><ins>+#include &quot;MemoryCache.h&quot;
+#include &quot;MemoryPressureHandler.h&quot;
</ins><span class="cx"> #include &quot;OverflowEvent.h&quot;
</span><span class="cx"> #include &quot;ProgressTracker.h&quot;
</span><span class="cx"> #include &quot;RenderEmbeddedObject.h&quot;
</span><span class="lines">@@ -3446,16 +3448,14 @@
</span><span class="cx"> 
</span><span class="cx">     paintingState.isTopLevelPainter = !sCurrentPaintTimeStamp;
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
-    if (paintingState.isTopLevelPainter &amp;&amp; memoryPressureHandler().hasReceivedMemoryPressure()) {
</del><ins>+    if (paintingState.isTopLevelPainter &amp;&amp; memoryPressureHandler().isUnderMemoryPressure()) {
</ins><span class="cx">         LOG(MemoryPressure, &quot;Under memory pressure: %s&quot;, __PRETTY_FUNCTION__);
</span><span class="cx"> 
</span><span class="cx">         // To avoid unnecessary image decoding, we don't prune recently-decoded live resources here since
</span><span class="cx">         // we might need some live bitmaps on painting.
</span><span class="cx">         memoryCache()-&gt;prune();
</span><span class="cx">     }
</span><del>-#endif
</del><ins>+
</ins><span class="cx">     if (paintingState.isTopLevelPainter)
</span><span class="cx">         sCurrentPaintTimeStamp = monotonicallyIncreasingTime();
</span><span class="cx"> 
</span><span class="lines">@@ -3490,13 +3490,10 @@
</span><span class="cx">     m_paintBehavior = paintingState.paintBehavior;
</span><span class="cx">     m_lastPaintTime = monotonicallyIncreasingTime();
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
</del><span class="cx">     // Painting can lead to decoding of large amounts of bitmaps
</span><span class="cx">     // If we are low on memory, wipe them out after the paint.
</span><del>-    // FIXME: Remove PLATFORM(IOS)-guard once we upstream the iOS changes to MemoryPressureHandler.h.
-    if (paintingState.isTopLevelPainter &amp;&amp; memoryPressureHandler().hasReceivedMemoryPressure())
</del><ins>+    if (paintingState.isTopLevelPainter &amp;&amp; memoryPressureHandler().isUnderMemoryPressure())
</ins><span class="cx">         memoryCache()-&gt;pruneLiveResources(true);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx">     // Regions may have changed as a result of the visibility/z-index of element changing.
</span><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -54,9 +54,9 @@
</span><span class="cx">     : m_installed(false)
</span><span class="cx">     , m_lastRespondTime(0)
</span><span class="cx">     , m_lowMemoryHandler(releaseMemory)
</span><ins>+    , m_underMemoryPressure(false)
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // FIXME: Can we share more of this with OpenSource?
</span><del>-    , m_receivedMemoryPressure(0)
</del><span class="cx">     , m_memoryPressureReason(MemoryPressureReasonNone)
</span><span class="cx">     , m_clearPressureOnMemoryRelease(true)
</span><span class="cx">     , m_releaseMemoryBlock(0)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformMemoryPressureHandlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/MemoryPressureHandler.h        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #ifndef MemoryPressureHandler_h
</span><span class="cx"> #define MemoryPressureHandler_h
</span><span class="cx"> 
</span><ins>+#include &lt;atomic&gt;
</ins><span class="cx"> #include &lt;time.h&gt;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -58,11 +59,12 @@
</span><span class="cx">         m_lowMemoryHandler = handler;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    bool isUnderMemoryPressure() const { return m_underMemoryPressure; }
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     // FIXME: Can we share more of this with OpenSource?
</span><span class="cx">     void installMemoryReleaseBlock(void (^releaseMemoryBlock)(), bool clearPressureOnMemoryRelease = true);
</span><span class="cx">     void setReceivedMemoryPressure(MemoryPressureReason);
</span><del>-    bool hasReceivedMemoryPressure();
</del><span class="cx">     void clearMemoryPressure();
</span><span class="cx">     bool shouldWaitForMemoryClearMessage();
</span><span class="cx">     void respondToMemoryPressureIfNeeded();
</span><span class="lines">@@ -84,8 +86,9 @@
</span><span class="cx">     time_t m_lastRespondTime;
</span><span class="cx">     LowMemoryHandler m_lowMemoryHandler;
</span><span class="cx"> 
</span><ins>+    std::atomic&lt;bool&gt; m_underMemoryPressure;
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><del>-    uint32_t m_receivedMemoryPressure;
</del><span class="cx">     uint32_t m_memoryPressureReason;
</span><span class="cx">     bool m_clearPressureOnMemoryRelease;
</span><span class="cx">     void (^m_releaseMemoryBlock)();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaMemoryPressureHandlerCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #import &quot;SystemMemory.h&quot;
</span><span class="cx"> #import &quot;WebCoreThread.h&quot;
</span><del>-#import &lt;libkern/OSAtomic.h&gt;
</del><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -177,7 +176,7 @@
</span><span class="cx"> 
</span><span class="cx"> void MemoryPressureHandler::setReceivedMemoryPressure(MemoryPressureReason reason)
</span><span class="cx"> {
</span><del>-    OSAtomicTestAndSet(0, &amp;m_receivedMemoryPressure);
</del><ins>+    m_underMemoryPressure = true;
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         MutexLocker locker(m_observerMutex);
</span><span class="lines">@@ -191,14 +190,9 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool MemoryPressureHandler::hasReceivedMemoryPressure()
-{
-    return OSAtomicOr32(0, &amp;m_receivedMemoryPressure);
-}
-
</del><span class="cx"> void MemoryPressureHandler::clearMemoryPressure()
</span><span class="cx"> {
</span><del>-    OSAtomicTestAndClear(0, &amp;m_receivedMemoryPressure);
</del><ins>+    m_underMemoryPressure = false;
</ins><span class="cx"> 
</span><span class="cx">     {
</span><span class="cx">         MutexLocker locker(m_observerMutex);
</span><span class="lines">@@ -221,7 +215,7 @@
</span><span class="cx">         m_observer = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (hasReceivedMemoryPressure()) {
</del><ins>+    if (isUnderMemoryPressure()) {
</ins><span class="cx">         ASSERT(m_releaseMemoryBlock);
</span><span class="cx">         LOG(MemoryPressure, &quot;Handle memory pressure at %s&quot;, __PRETTY_FUNCTION__);
</span><span class="cx">         m_releaseMemoryBlock();
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsFontCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/FontCache.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #include &quot;FontGlyphs.h&quot;
</span><span class="cx"> #include &quot;FontPlatformData.h&quot;
</span><span class="cx"> #include &quot;FontSelector.h&quot;
</span><ins>+#include &quot;MemoryPressureHandler.h&quot;
</ins><span class="cx"> #include &quot;WebKitFontFamilyNames.h&quot;
</span><span class="cx"> #include &lt;wtf/HashMap.h&gt;
</span><span class="cx"> #include &lt;wtf/ListHashSet.h&gt;
</span><span class="lines">@@ -47,7 +48,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-#include &quot;MemoryPressureHandler.h&quot;
</del><span class="cx"> #include &lt;wtf/Noncopyable.h&gt;
</span><span class="cx"> 
</span><span class="cx"> // FIXME: We may be able to simplify this code using C++11 threading primitives, including std::call_once().
</span><span class="lines">@@ -361,12 +361,14 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> const int cMaxInactiveFontData = 120;
</span><span class="cx"> const int cTargetInactiveFontData = 100;
</span><del>-const int cMaxUnderMemoryPressureInactiveFontData = 50;
-const int cTargetUnderMemoryPressureInactiveFontData = 30;
</del><span class="cx"> #else
</span><span class="cx"> const int cMaxInactiveFontData = 225;
</span><span class="cx"> const int cTargetInactiveFontData = 200;
</span><span class="cx"> #endif
</span><ins>+
+const int cMaxUnderMemoryPressureInactiveFontData = 50;
+const int cTargetUnderMemoryPressureInactiveFontData = 30;
+
</ins><span class="cx"> static ListHashSet&lt;RefPtr&lt;SimpleFontData&gt;&gt;* gInactiveFontData = 0;
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;SimpleFontData&gt; FontCache::getCachedFontData(const FontDescription&amp; fontDescription, const AtomicString&amp; family, bool checkingAlternateName, ShouldRetain shouldRetain)
</span><span class="lines">@@ -448,17 +450,12 @@
</span><span class="cx"> 
</span><span class="cx"> void FontCache::purgeInactiveFontDataIfNeeded()
</span><span class="cx"> {
</span><del>-#if PLATFORM(IOS)
-    bool underMemoryPressure = memoryPressureHandler().hasReceivedMemoryPressure();
</del><ins>+    bool underMemoryPressure = memoryPressureHandler().isUnderMemoryPressure();
</ins><span class="cx">     int inactiveFontDataLimit = underMemoryPressure ? cMaxUnderMemoryPressureInactiveFontData : cMaxInactiveFontData;
</span><span class="cx">     int targetFontDataLimit = underMemoryPressure ? cTargetUnderMemoryPressureInactiveFontData : cTargetInactiveFontData;
</span><span class="cx"> 
</span><span class="cx">     if (gInactiveFontData &amp;&amp; !m_purgePreventCount &amp;&amp; gInactiveFontData-&gt;size() &gt; inactiveFontDataLimit)
</span><span class="cx">         purgeInactiveFontData(gInactiveFontData-&gt;size() - targetFontDataLimit);
</span><del>-#else
-    if (gInactiveFontData &amp;&amp; !m_purgePreventCount &amp;&amp; gInactiveFontData-&gt;size() &gt; cMaxInactiveFontData)
-        purgeInactiveFontData(gInactiveFontData-&gt;size() - cTargetInactiveFontData);
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FontCache::purgeInactiveFontData(int count)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileCachemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileCache.mm (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileCache.mm        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/ios/LegacyTileCache.mm        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -424,7 +424,7 @@
</span><span class="cx"> 
</span><span class="cx"> void LegacyTileCache::createTilesInActiveGrid(SynchronousTileCreationMode mode)
</span><span class="cx"> {
</span><del>-    if (memoryPressureHandler().hasReceivedMemoryPressure()) {
</del><ins>+    if (memoryPressureHandler().isUnderMemoryPressure()) {
</ins><span class="cx">         LOG(MemoryPressure, &quot;Under memory pressure at: %s&quot;, __PRETTY_FUNCTION__);
</span><span class="cx">         removeAllNonVisibleTilesInternal();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileGridmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/ios/LegacyTileGrid.mm        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -391,7 +391,7 @@
</span><span class="cx"> {
</span><span class="cx">     return m_tileCache-&gt;tilingMode() == LegacyTileCache::Minimal
</span><span class="cx">         || !m_tileCache-&gt;isSpeculativeTileCreationEnabled()
</span><del>-        || memoryPressureHandler().hasReceivedMemoryPressure();
</del><ins>+        || memoryPressureHandler().isUnderMemoryPressure();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect LegacyTileGrid::adjustCoverRectForPageBounds(const IntRect&amp; rect) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLegacyTileLayerPoolmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/ios/LegacyTileLayerPool.mm        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">     if (!canReuseLayerWithSize(layerSize))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (memoryPressureHandler().hasReceivedMemoryPressure()) {
</del><ins>+    if (memoryPressureHandler().isUnderMemoryPressure()) {
</ins><span class="cx">         LOG(MemoryPressure, &quot;Under memory pressure: %s, totalBytes: %d&quot;, __PRETTY_FUNCTION__, m_totalBytes);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosTileControllerMemoryHandlerIOScpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebCore/platform/ios/TileControllerMemoryHandlerIOS.cpp        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     m_tileControllers.appendOrMoveToLast(controller);
</span><span class="cx"> 
</span><span class="cx">     // If we are under memory pressure, remove all unparented tiles now.
</span><del>-    if (memoryPressureHandler().hasReceivedMemoryPressure()) {
</del><ins>+    if (memoryPressureHandler().isUnderMemoryPressure()) {
</ins><span class="cx">         trimUnparentedTilesToTarget(0);
</span><span class="cx">         return;
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (167276 => 167277)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2014-04-14 22:46:22 UTC (rev 167276)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2014-04-14 23:03:54 UTC (rev 167277)
</span><span class="lines">@@ -1601,7 +1601,7 @@
</span><span class="cx"> 
</span><span class="cx"> + (BOOL)_isUnderMemoryPressure
</span><span class="cx"> {
</span><del>-    return memoryPressureHandler().hasReceivedMemoryPressure();
</del><ins>+    return memoryPressureHandler().isUnderMemoryPressure();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> + (void)_clearMemoryPressure
</span></span></pre>
</div>
</div>

</body>
</html>