Title: [209181] trunk/Source/WebCore
Revision
209181
Author
akl...@apple.com
Date
2016-12-01 08:15:27 -0800 (Thu, 01 Dec 2016)

Log Message

Log some basic memory usage stats at interesting points in time
<https://webkit.org/b/165206>

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:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (209180 => 209181)


--- 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)
@@ -2067,6 +2067,7 @@
     page/PageVisibilityState.cpp
     page/Performance.cpp
     page/PerformanceEntry.cpp
+    page/PerformanceLogging.cpp
     page/PerformanceNavigation.cpp
     page/PerformanceResourceTiming.cpp
     page/PerformanceTiming.cpp

Modified: trunk/Source/WebCore/ChangeLog (209180 => 209181)


--- 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)
@@ -1,3 +1,48 @@
+2016-12-01  Andreas Kling  <akl...@apple.com>
+
+        Log some basic memory usage stats at interesting points in time
+        <https://webkit.org/b/165206>
+
+        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:
+
 2016-11-28  Sergio Villar Senin  <svil...@igalia.com>
 
         [css-grid] Move more attributes from RenderGrid to the new Grid class

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (209180 => 209181)


--- 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)
@@ -4511,6 +4511,9 @@
 		AD4495F3141FC08900541EDF /* EventListenerMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4495F1141FC08900541EDF /* EventListenerMap.cpp */; };
 		AD4495F4141FC08900541EDF /* EventListenerMap.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4495F2141FC08900541EDF /* EventListenerMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AD49914318F0815100BF0092 /* HTMLUnknownElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AD49914118F0815100BF0092 /* HTMLUnknownElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		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 */; };
 		AD6E71AC1668899D00320C13 /* DocumentSharedObjectPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */; };
 		AD6E71AD1668899D00320C13 /* DocumentSharedObjectPool.h in Headers */ = {isa = PBXBuildFile; fileRef = AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */; };
 		AD726FED16DA1171003A4E6D /* JSCSSStyleDeclarationCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -12210,6 +12213,9 @@
 		AD4495F2141FC08900541EDF /* EventListenerMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventListenerMap.h; sourceTree = "<group>"; };
 		AD49914118F0815100BF0092 /* HTMLUnknownElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLUnknownElement.h; sourceTree = "<group>"; };
 		AD49914218F0815100BF0092 /* HTMLUnknownElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLUnknownElement.idl; sourceTree = "<group>"; };
+		AD5A0C201DECA0B500707054 /* PerformanceLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceLogging.h; sourceTree = "<group>"; };
+		AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceLogging.cpp; sourceTree = "<group>"; };
+		AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PerformanceLoggingCocoa.mm; sourceTree = "<group>"; };
 		AD6E71AA1668899D00320C13 /* DocumentSharedObjectPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentSharedObjectPool.cpp; sourceTree = "<group>"; };
 		AD6E71AB1668899D00320C13 /* DocumentSharedObjectPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentSharedObjectPool.h; sourceTree = "<group>"; };
 		AD726FE716D9F204003A4E6D /* JSMediaListCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaListCustom.h; sourceTree = "<group>"; };
@@ -17364,6 +17370,7 @@
 		5D5975B5196362BE00D00878 /* cocoa */ = {
 			isa = PBXGroup;
 			children = (
+				AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */,
 				413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */,
 				ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
 				A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
@@ -17819,6 +17826,8 @@
 		65BF02180974806300C43196 /* page */ = {
 			isa = PBXGroup;
 			children = (
+				AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */,
+				AD5A0C201DECA0B500707054 /* PerformanceLogging.h */,
 				316FE1060E6E1D8400BF6088 /* animation */,
 				5D5975B5196362BE00D00878 /* cocoa */,
 				CE17AD141C58522F005F4799 /* csp */,
@@ -27921,6 +27930,7 @@
 				A77D0012133B0AEB00D6658C /* TextChecking.h in Headers */,
 				A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */,
 				B2C3DA3A0D006C1D00EF6F26 /* TextCodec.h in Headers */,
+				AD5A0C251DECACCC00707054 /* PerformanceLogging.h in Headers */,
 				26E98A10130A9FCA008EB7B2 /* TextCodecASCIIFastPath.h in Headers */,
 				B2C3DA3C0D006C1D00EF6F26 /* TextCodecICU.h in Headers */,
 				B2C3DA3E0D006C1D00EF6F26 /* TextCodecLatin1.h in Headers */,
@@ -30246,6 +30256,7 @@
 				B2FA3D860AB75A6F000E5AC4 /* JSSVGFEMergeElement.cpp in Sources */,
 				B2FA3D880AB75A6F000E5AC4 /* JSSVGFEMergeNodeElement.cpp in Sources */,
 				84224183107E77F400766A87 /* JSSVGFEMorphologyElement.cpp in Sources */,
+				AD5A0C241DECACC400707054 /* PerformanceLogging.cpp in Sources */,
 				B2FA3D8A0AB75A6F000E5AC4 /* JSSVGFEOffsetElement.cpp in Sources */,
 				B2FA3D8C0AB75A6F000E5AC4 /* JSSVGFEPointLightElement.cpp in Sources */,
 				B2FA3D8E0AB75A6F000E5AC4 /* JSSVGFESpecularLightingElement.cpp in Sources */,
@@ -31318,6 +31329,7 @@
 				B222798F0D00BF220071B782 /* SVGAnimateElement.cpp in Sources */,
 				832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */,
 				B22279920D00BF220071B782 /* SVGAnimateMotionElement.cpp in Sources */,
+				AD5A0C231DECACC000707054 /* PerformanceLoggingCocoa.mm in Sources */,
 				B22279940D00BF220071B782 /* SVGAnimateTransformElement.cpp in Sources */,
 				B22279970D00BF220071B782 /* SVGAnimationElement.cpp in Sources */,
 				08FB17C113BC7E9100040086 /* SVGAttributeToPropertyMap.cpp in Sources */,

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (209180 => 209181)


--- 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)
@@ -89,6 +89,7 @@
 #include "Page.h"
 #include "PageCache.h"
 #include "PageTransitionEvent.h"
+#include "PerformanceLogging.h"
 #include "PlatformStrategies.h"
 #include "PluginData.h"
 #include "PluginDocument.h"
@@ -1421,8 +1422,10 @@
         m_previousURL = m_frame.document()->url();
 
     // Log main frame navigation types.
-    if (m_frame.isMainFrame())
+    if (m_frame.isMainFrame()) {
         logNavigation(static_cast<MainFrame&>(m_frame), type);
+        static_cast<MainFrame&>(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadStarted);
+    }
 
     policyChecker().setLoadType(type);
     RefPtr<FormState> formState = prpFormState;
@@ -1728,7 +1731,8 @@
 }
 
 void FrameLoader::setState(FrameState newState)
-{    
+{
+    FrameState oldState = m_state;
     m_state = newState;
     
     if (newState == FrameStateProvisional)
@@ -1737,6 +1741,8 @@
         frameLoadCompleted();
         if (m_documentLoader)
             m_documentLoader->stopRecordingResponses();
+        if (m_frame.isMainFrame() && oldState != newState)
+            static_cast<MainFrame&>(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
     }
 }
 

Modified: trunk/Source/WebCore/page/MainFrame.cpp (209180 => 209181)


--- 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)
@@ -31,6 +31,7 @@
 #include "PageConfiguration.h"
 #include "PageOverlayController.h"
 #include "PaymentCoordinator.h"
+#include "PerformanceLogging.h"
 #include "ScrollLatchingState.h"
 #include "WheelEventDeltaFilter.h"
 #include <wtf/NeverDestroyed.h>
@@ -52,6 +53,7 @@
 #if ENABLE(APPLE_PAY)
     , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient))
 #endif
+    , m_performanceLogging(std::make_unique<PerformanceLogging>(*this))
 {
 }
 

Modified: trunk/Source/WebCore/page/MainFrame.h (209180 => 209181)


--- 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)
@@ -34,6 +34,7 @@
 class PageConfiguration;
 class PageOverlayController;
 class PaymentCoordinator;
+class PerformanceLogging;
 class ScrollLatchingState;
 class ServicesOverlayController;
 class WheelEventDeltaFilter;
@@ -66,6 +67,8 @@
     PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; }
 #endif
 
+    PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
+
 private:
     MainFrame(Page&, PageConfiguration&);
 
@@ -86,6 +89,8 @@
 #if ENABLE(APPLE_PAY)
     std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
 #endif
+
+    std::unique_ptr<PerformanceLogging> m_performanceLogging;
 };
 
 } // namespace WebCore

Added: trunk/Source/WebCore/page/PerformanceLogging.cpp (0 => 209181)


--- trunk/Source/WebCore/page/PerformanceLogging.cpp	                        (rev 0)
+++ trunk/Source/WebCore/page/PerformanceLogging.cpp	2016-12-01 16:15:27 UTC (rev 209181)
@@ -0,0 +1,90 @@
+/*
+ * 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 "config.h"
+#include "PerformanceLogging.h"
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "FrameLoaderClient.h"
+#include "JSDOMWindow.h"
+#include "Logging.h"
+#include "MainFrame.h"
+#include "PageCache.h"
+
+namespace WebCore {
+
+#if !RELEASE_LOG_DISABLED
+static const char* toString(PerformanceLogging::PointOfInterest poi)
+{
+    switch (poi) {
+    case PerformanceLogging::MainFrameLoadStarted:
+        return "MainFrameLoadStarted";
+    case PerformanceLogging::MainFrameLoadCompleted:
+        return "MainFrameLoadCompleted";
+    }
+}
+
+static void getMemoryUsageStatistics(HashMap<const char*, size_t>& stats)
+{
+    auto& vm = JSDOMWindow::commonVM();
+    stats.set("_javascript__gc_heap_capacity", vm.heap.capacity());
+
+    auto& pageCache = PageCache::singleton();
+    stats.set("pagecache_page_count", pageCache.pageCount());
+
+    stats.set("document_count", Document::allDocuments().size());
+}
+#endif
+
+PerformanceLogging::PerformanceLogging(MainFrame& 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<const char*, size_t> stats;
+    getMemoryUsageStatistics(stats);
+    getPlatformMemoryUsageStatistics(stats);
+
+    RELEASE_LOG(PerformanceLogging, "Memory usage info dump at %s:", toString(poi));
+    for (auto& it : stats)
+        RELEASE_LOG(PerformanceLogging, "  %s: %zu", it.key, it.value);
+#endif
+}
+
+#if !PLATFORM(COCOA)
+void PerformanceLogging::getPlatformMemoryUsageStatistics(HashMap<const char*, size_t>&) { }
+#endif
+
+}

Added: trunk/Source/WebCore/page/PerformanceLogging.h (0 => 209181)


--- trunk/Source/WebCore/page/PerformanceLogging.h	                        (rev 0)
+++ trunk/Source/WebCore/page/PerformanceLogging.h	2016-12-01 16:15:27 UTC (rev 209181)
@@ -0,0 +1,52 @@
+/*
+ * 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 <wtf/HashMap.h>
+
+namespace WebCore {
+
+class MainFrame;
+
+class PerformanceLogging {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(PerformanceLogging);
+public:
+    explicit PerformanceLogging(MainFrame&);
+
+    enum PointOfInterest {
+        MainFrameLoadStarted,
+        MainFrameLoadCompleted,
+    };
+    void didReachPointOfInterest(PointOfInterest);
+
+private:
+    static void getPlatformMemoryUsageStatistics(HashMap<const char*, size_t>&);
+
+    MainFrame& m_mainFrame;
+};
+
+}

Added: trunk/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm (0 => 209181)


--- 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)
@@ -0,0 +1,48 @@
+/*
+ * 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 "config.h"
+#import "PerformanceLogging.h"
+
+#import <mach/mach.h>
+#import <mach/task_info.h>
+
+namespace WebCore {
+
+void PerformanceLogging::getPlatformMemoryUsageStatistics(HashMap<const char*, size_t>& 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) &vmInfo, &count);
+    if (err != KERN_SUCCESS)
+        return;
+    stats.set("internal", static_cast<size_t>(vmInfo.internal));
+    stats.set("compressed", static_cast<size_t>(vmInfo.compressed));
+    stats.set("phys_footprint", static_cast<size_t>(vmInfo.phys_footprint));
+    stats.set("resident_size", static_cast<size_t>(vmInfo.resident_size));
+    stats.set("virtual_size", static_cast<size_t>(vmInfo.virtual_size));
+}
+
+}

Modified: trunk/Source/WebCore/platform/Logging.h (209180 => 209181)


--- 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)
@@ -65,6 +65,7 @@
     M(Network) \
     M(NotYetImplemented) \
     M(PageCache) \
+    M(PerformanceLogging) \
     M(PlatformLeaks) \
     M(Plugins) \
     M(PopupBlocking) \
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to