<!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>[209181] trunk/Source/WebCore</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/209181">209181</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2016-12-01 08:15:27 -0800 (Thu, 01 Dec 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Log some basic memory usage stats at interesting points in time
&lt;https://webkit.org/b/165206&gt;

Reviewed by Antti Koivisto.

This patch adds a mechanism to mark points of interests where we might
want to do performance-related logging:

    class PerformanceLogging {
        enum PointOfInterest {
            MainFrameLoadStarted,
            MainFrameLoadCompleted,
        }
        void didReachPointOfInterest(PointOfInterest)
    }

You get to this object via MainFrame::performanceLogging().

We respond to these callbacks by logging some basic data about memory usage
to the PerformanceLogging channel.

More PointOfInterest values will be added soon.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::setState):
* page/MainFrame.cpp:
(WebCore::MainFrame::MainFrame):
* page/MainFrame.h:
* page/PerformanceLogging.cpp: Added.
(WebCore::toString):
(WebCore::getMemoryUsageStatistics):
(WebCore::PerformanceLogging::PerformanceLogging):
(WebCore::writeLog):
(WebCore::PerformanceLogging::didReachPointOfInterest):
(WebCore::PerformanceLogging::getPlatformMemoryUsageStatistics):
* page/PerformanceLogging.h: Added.
* page/cocoa/PerformanceLoggingCocoa.mm: Added.
(WebCore::PerformanceLogging::getPlatformMemoryUsageStatistics):
* platform/Logging.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageMainFramecpp">trunk/Source/WebCore/page/MainFrame.cpp</a></li>
<li><a href="#trunkSourceWebCorepageMainFrameh">trunk/Source/WebCore/page/MainFrame.h</a></li>
<li><a href="#trunkSourceWebCoreplatformLoggingh">trunk/Source/WebCore/platform/Logging.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepagePerformanceLoggingcpp">trunk/Source/WebCore/page/PerformanceLogging.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePerformanceLoggingh">trunk/Source/WebCore/page/PerformanceLogging.h</a></li>
<li><a href="#trunkSourceWebCorepagecocoaPerformanceLoggingCocoamm">trunk/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -2067,6 +2067,7 @@
</span><span class="cx">     page/PageVisibilityState.cpp
</span><span class="cx">     page/Performance.cpp
</span><span class="cx">     page/PerformanceEntry.cpp
</span><ins>+    page/PerformanceLogging.cpp
</ins><span class="cx">     page/PerformanceNavigation.cpp
</span><span class="cx">     page/PerformanceResourceTiming.cpp
</span><span class="cx">     page/PerformanceTiming.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/ChangeLog        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2016-12-01  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Log some basic memory usage stats at interesting points in time
+        &lt;https://webkit.org/b/165206&gt;
+
+        Reviewed by Antti Koivisto.
+
+        This patch adds a mechanism to mark points of interests where we might
+        want to do performance-related logging:
+
+            class PerformanceLogging {
+                enum PointOfInterest {
+                    MainFrameLoadStarted,
+                    MainFrameLoadCompleted,
+                }
+                void didReachPointOfInterest(PointOfInterest)
+            }
+
+        You get to this object via MainFrame::performanceLogging().
+
+        We respond to these callbacks by logging some basic data about memory usage
+        to the PerformanceLogging channel.
+
+        More PointOfInterest values will be added soon.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::FrameLoader::setState):
+        * page/MainFrame.cpp:
+        (WebCore::MainFrame::MainFrame):
+        * page/MainFrame.h:
+        * page/PerformanceLogging.cpp: Added.
+        (WebCore::toString):
+        (WebCore::getMemoryUsageStatistics):
+        (WebCore::PerformanceLogging::PerformanceLogging):
+        (WebCore::writeLog):
+        (WebCore::PerformanceLogging::didReachPointOfInterest):
+        (WebCore::PerformanceLogging::getPlatformMemoryUsageStatistics):
+        * page/PerformanceLogging.h: Added.
+        * page/cocoa/PerformanceLoggingCocoa.mm: Added.
+        (WebCore::PerformanceLogging::getPlatformMemoryUsageStatistics):
+        * platform/Logging.h:
+
</ins><span class="cx"> 2016-11-28  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [css-grid] Move more attributes from RenderGrid to the new Grid class
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -4511,6 +4511,9 @@
</span><span class="cx">                 AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4495F1141FC08900541EDF /* EventListenerMap.cpp */; };
</span><span class="cx">                 AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4495F2141FC08900541EDF /* EventListenerMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AD49914118F0815100BF0092 /* HTMLUnknownElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                AD5A0C231DECACC000707054 /* PerformanceLoggingCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */; };
+                AD5A0C241DECACC400707054 /* PerformanceLogging.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */; };
+                AD5A0C251DECACCC00707054 /* PerformanceLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = AD5A0C201DECA0B500707054 /* PerformanceLogging.h */; };
</ins><span class="cx">                 AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */; };
</span><span class="cx">                 AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */ = {isa = PBXBuildFile; fileRef = AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */; };
</span><span class="cx">                 AD726FED16DA1171003A4E6D /* JSCSSStyleDeclarationCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -12210,6 +12213,9 @@
</span><span class="cx">                 AD4495F2141FC08900541EDF /* EventListenerMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListenerMap.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD49914118F0815100BF0092 /* HTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLUnknownElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD49914218F0815100BF0092 /* HTMLUnknownElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLUnknownElement.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                AD5A0C201DECA0B500707054 /* PerformanceLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceLogging.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceLogging.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PerformanceLoggingCocoa.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentSharedObjectPool.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentSharedObjectPool.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaListCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -17364,6 +17370,7 @@
</span><span class="cx">                 5D5975B5196362BE00D00878 /* cocoa */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */,
</ins><span class="cx">                                 413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */,
</span><span class="cx">                                 ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
</span><span class="cx">                                 A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
</span><span class="lines">@@ -17819,6 +17826,8 @@
</span><span class="cx">                 65BF02180974806300C43196 /* page */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */,
+                                AD5A0C201DECA0B500707054 /* PerformanceLogging.h */,
</ins><span class="cx">                                 316FE1060E6E1D8400BF6088 /* animation */,
</span><span class="cx">                                 5D5975B5196362BE00D00878 /* cocoa */,
</span><span class="cx">                                 CE17AD141C58522F005F4799 /* csp */,
</span><span class="lines">@@ -27921,6 +27930,7 @@
</span><span class="cx">                                 A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */,
</span><span class="cx">                                 A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,
</span><span class="cx">                                 B2C3DA3A0D006C1D00EF6F26 /* TextCodec.h in Headers */,
</span><ins>+                                AD5A0C251DECACCC00707054 /* PerformanceLogging.h in Headers */,
</ins><span class="cx">                                 26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */,
</span><span class="cx">                                 B2C3DA3C0D006C1D00EF6F26 /* TextCodecICU.h in Headers */,
</span><span class="cx">                                 B2C3DA3E0D006C1D00EF6F26 /* TextCodecLatin1.h in Headers */,
</span><span class="lines">@@ -30246,6 +30256,7 @@
</span><span class="cx">                                 B2FA3D860AB75A6F000E5AC4 /* JSSVGFEMergeElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3D880AB75A6F000E5AC4 /* JSSVGFEMergeNodeElement.cpp in Sources */,
</span><span class="cx">                                 84224183107E77F400766A87 /* JSSVGFEMorphologyElement.cpp in Sources */,
</span><ins>+                                AD5A0C241DECACC400707054 /* PerformanceLogging.cpp in Sources */,
</ins><span class="cx">                                 B2FA3D8A0AB75A6F000E5AC4 /* JSSVGFEOffsetElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3D8C0AB75A6F000E5AC4 /* JSSVGFEPointLightElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3D8E0AB75A6F000E5AC4 /* JSSVGFESpecularLightingElement.cpp in Sources */,
</span><span class="lines">@@ -31318,6 +31329,7 @@
</span><span class="cx">                                 B222798F0D00BF220071B782 /* SVGAnimateElement.cpp in Sources */,
</span><span class="cx">                                 832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */,
</span><span class="cx">                                 B22279920D00BF220071B782 /* SVGAnimateMotionElement.cpp in Sources */,
</span><ins>+                                AD5A0C231DECACC000707054 /* PerformanceLoggingCocoa.mm in Sources */,
</ins><span class="cx">                                 B22279940D00BF220071B782 /* SVGAnimateTransformElement.cpp in Sources */,
</span><span class="cx">                                 B22279970D00BF220071B782 /* SVGAnimationElement.cpp in Sources */,
</span><span class="cx">                                 08FB17C113BC7E9100040086 /* SVGAttributeToPropertyMap.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><span class="cx"> #include &quot;PageTransitionEvent.h&quot;
</span><ins>+#include &quot;PerformanceLogging.h&quot;
</ins><span class="cx"> #include &quot;PlatformStrategies.h&quot;
</span><span class="cx"> #include &quot;PluginData.h&quot;
</span><span class="cx"> #include &quot;PluginDocument.h&quot;
</span><span class="lines">@@ -1421,8 +1422,10 @@
</span><span class="cx">         m_previousURL = m_frame.document()-&gt;url();
</span><span class="cx"> 
</span><span class="cx">     // Log main frame navigation types.
</span><del>-    if (m_frame.isMainFrame())
</del><ins>+    if (m_frame.isMainFrame()) {
</ins><span class="cx">         logNavigation(static_cast&lt;MainFrame&amp;&gt;(m_frame), type);
</span><ins>+        static_cast&lt;MainFrame&amp;&gt;(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadStarted);
+    }
</ins><span class="cx"> 
</span><span class="cx">     policyChecker().setLoadType(type);
</span><span class="cx">     RefPtr&lt;FormState&gt; formState = prpFormState;
</span><span class="lines">@@ -1728,7 +1731,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameLoader::setState(FrameState newState)
</span><del>-{    
</del><ins>+{
+    FrameState oldState = m_state;
</ins><span class="cx">     m_state = newState;
</span><span class="cx">     
</span><span class="cx">     if (newState == FrameStateProvisional)
</span><span class="lines">@@ -1737,6 +1741,8 @@
</span><span class="cx">         frameLoadCompleted();
</span><span class="cx">         if (m_documentLoader)
</span><span class="cx">             m_documentLoader-&gt;stopRecordingResponses();
</span><ins>+        if (m_frame.isMainFrame() &amp;&amp; oldState != newState)
+            static_cast&lt;MainFrame&amp;&gt;(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageMainFramecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/MainFrame.cpp (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MainFrame.cpp        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/page/MainFrame.cpp        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include &quot;PageConfiguration.h&quot;
</span><span class="cx"> #include &quot;PageOverlayController.h&quot;
</span><span class="cx"> #include &quot;PaymentCoordinator.h&quot;
</span><ins>+#include &quot;PerformanceLogging.h&quot;
</ins><span class="cx"> #include &quot;ScrollLatchingState.h&quot;
</span><span class="cx"> #include &quot;WheelEventDeltaFilter.h&quot;
</span><span class="cx"> #include &lt;wtf/NeverDestroyed.h&gt;
</span><span class="lines">@@ -52,6 +53,7 @@
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx">     , m_paymentCoordinator(std::make_unique&lt;PaymentCoordinator&gt;(*configuration.paymentCoordinatorClient))
</span><span class="cx"> #endif
</span><ins>+    , m_performanceLogging(std::make_unique&lt;PerformanceLogging&gt;(*this))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageMainFrameh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/MainFrame.h (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/MainFrame.h        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/page/MainFrame.h        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> class PageConfiguration;
</span><span class="cx"> class PageOverlayController;
</span><span class="cx"> class PaymentCoordinator;
</span><ins>+class PerformanceLogging;
</ins><span class="cx"> class ScrollLatchingState;
</span><span class="cx"> class ServicesOverlayController;
</span><span class="cx"> class WheelEventDeltaFilter;
</span><span class="lines">@@ -66,6 +67,8 @@
</span><span class="cx">     PaymentCoordinator&amp; paymentCoordinator() const { return *m_paymentCoordinator; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    PerformanceLogging&amp; performanceLogging() const { return *m_performanceLogging; }
+
</ins><span class="cx"> private:
</span><span class="cx">     MainFrame(Page&amp;, PageConfiguration&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -86,6 +89,8 @@
</span><span class="cx"> #if ENABLE(APPLE_PAY)
</span><span class="cx">     std::unique_ptr&lt;PaymentCoordinator&gt; m_paymentCoordinator;
</span><span class="cx"> #endif
</span><ins>+
+    std::unique_ptr&lt;PerformanceLogging&gt; m_performanceLogging;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepagePerformanceLoggingcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/PerformanceLogging.cpp (0 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PerformanceLogging.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/PerformanceLogging.cpp        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;PerformanceLogging.h&quot;
+
+#include &quot;DOMWindow.h&quot;
+#include &quot;Document.h&quot;
+#include &quot;FrameLoaderClient.h&quot;
+#include &quot;JSDOMWindow.h&quot;
+#include &quot;Logging.h&quot;
+#include &quot;MainFrame.h&quot;
+#include &quot;PageCache.h&quot;
+
+namespace WebCore {
+
+#if !RELEASE_LOG_DISABLED
+static const char* toString(PerformanceLogging::PointOfInterest poi)
+{
+    switch (poi) {
+    case PerformanceLogging::MainFrameLoadStarted:
+        return &quot;MainFrameLoadStarted&quot;;
+    case PerformanceLogging::MainFrameLoadCompleted:
+        return &quot;MainFrameLoadCompleted&quot;;
+    }
+}
+
+static void getMemoryUsageStatistics(HashMap&lt;const char*, size_t&gt;&amp; stats)
+{
+    auto&amp; vm = JSDOMWindow::commonVM();
+    stats.set(&quot;javascript_gc_heap_capacity&quot;, vm.heap.capacity());
+
+    auto&amp; pageCache = PageCache::singleton();
+    stats.set(&quot;pagecache_page_count&quot;, pageCache.pageCount());
+
+    stats.set(&quot;document_count&quot;, Document::allDocuments().size());
+}
+#endif
+
+PerformanceLogging::PerformanceLogging(MainFrame&amp; mainFrame)
+    : m_mainFrame(mainFrame)
+{
+}
+
+void PerformanceLogging::didReachPointOfInterest(PointOfInterest poi)
+{
+#if RELEASE_LOG_DISABLED
+    UNUSED_PARAM(poi);
+#else
+    // Ignore synthetic main frames used internally by SVG and web inspector.
+    if (m_mainFrame.loader().client().isEmptyFrameLoaderClient())
+        return;
+
+    HashMap&lt;const char*, size_t&gt; stats;
+    getMemoryUsageStatistics(stats);
+    getPlatformMemoryUsageStatistics(stats);
+
+    RELEASE_LOG(PerformanceLogging, &quot;Memory usage info dump at %s:&quot;, toString(poi));
+    for (auto&amp; it : stats)
+        RELEASE_LOG(PerformanceLogging, &quot;  %s: %zu&quot;, it.key, it.value);
+#endif
+}
+
+#if !PLATFORM(COCOA)
+void PerformanceLogging::getPlatformMemoryUsageStatistics(HashMap&lt;const char*, size_t&gt;&amp;) { }
+#endif
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorepagePerformanceLoggingh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/PerformanceLogging.h (0 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PerformanceLogging.h                                (rev 0)
+++ trunk/Source/WebCore/page/PerformanceLogging.h        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include &lt;wtf/HashMap.h&gt;
+
+namespace WebCore {
+
+class MainFrame;
+
+class PerformanceLogging {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(PerformanceLogging);
+public:
+    explicit PerformanceLogging(MainFrame&amp;);
+
+    enum PointOfInterest {
+        MainFrameLoadStarted,
+        MainFrameLoadCompleted,
+    };
+    void didReachPointOfInterest(PointOfInterest);
+
+private:
+    static void getPlatformMemoryUsageStatistics(HashMap&lt;const char*, size_t&gt;&amp;);
+
+    MainFrame&amp; m_mainFrame;
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCorepagecocoaPerformanceLoggingCocoamm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm (0 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm                                (rev 0)
+++ trunk/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;PerformanceLogging.h&quot;
+
+#import &lt;mach/mach.h&gt;
+#import &lt;mach/task_info.h&gt;
+
+namespace WebCore {
+
+void PerformanceLogging::getPlatformMemoryUsageStatistics(HashMap&lt;const char*, size_t&gt;&amp; stats)
+{
+    task_vm_info_data_t vmInfo;
+    mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
+    kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &amp;vmInfo, &amp;count);
+    if (err != KERN_SUCCESS)
+        return;
+    stats.set(&quot;internal&quot;, static_cast&lt;size_t&gt;(vmInfo.internal));
+    stats.set(&quot;compressed&quot;, static_cast&lt;size_t&gt;(vmInfo.compressed));
+    stats.set(&quot;phys_footprint&quot;, static_cast&lt;size_t&gt;(vmInfo.phys_footprint));
+    stats.set(&quot;resident_size&quot;, static_cast&lt;size_t&gt;(vmInfo.resident_size));
+    stats.set(&quot;virtual_size&quot;, static_cast&lt;size_t&gt;(vmInfo.virtual_size));
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformLoggingh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Logging.h (209180 => 209181)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Logging.h        2016-12-01 11:05:22 UTC (rev 209180)
+++ trunk/Source/WebCore/platform/Logging.h        2016-12-01 16:15:27 UTC (rev 209181)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     M(Network) \
</span><span class="cx">     M(NotYetImplemented) \
</span><span class="cx">     M(PageCache) \
</span><ins>+    M(PerformanceLogging) \
</ins><span class="cx">     M(PlatformLeaks) \
</span><span class="cx">     M(Plugins) \
</span><span class="cx">     M(PopupBlocking) \
</span></span></pre>
</div>
</div>

</body>
</html>