Log some basic memory usage stats at interesting points in time
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 16:15:27 +0000 (16:15 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 16:15:27 +0000 (16:15 +0000)
<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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209181 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/page/MainFrame.cpp
Source/WebCore/page/MainFrame.h
Source/WebCore/page/PerformanceLogging.cpp [new file with mode: 0644]
Source/WebCore/page/PerformanceLogging.h [new file with mode: 0644]
Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm [new file with mode: 0644]
Source/WebCore/platform/Logging.h

index d05c122..dc2d036 100644 (file)
@@ -2067,6 +2067,7 @@ set(WebCore_SOURCES
     page/PageVisibilityState.cpp
     page/Performance.cpp
     page/PerformanceEntry.cpp
+    page/PerformanceLogging.cpp
     page/PerformanceNavigation.cpp
     page/PerformanceResourceTiming.cpp
     page/PerformanceTiming.cpp
index 38f3159..e5a1f6a 100644 (file)
@@ -1,3 +1,48 @@
+2016-12-01  Andreas Kling  <akling@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  <svillar@igalia.com>
 
         [css-grid] Move more attributes from RenderGrid to the new Grid class
index 2dae710..a0a2a38 100644 (file)
                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, ); }; };
                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>"; };
                5D5975B5196362BE00D00878 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               AD5A0C221DECA37E00707054 /* PerformanceLoggingCocoa.mm */,
                                413E007B1DB0E707002341D2 /* MemoryReleaseCocoa.mm */,
                                ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
                                A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
                65BF02180974806300C43196 /* page */ = {
                        isa = PBXGroup;
                        children = (
+                               AD5A0C211DECA10100707054 /* PerformanceLogging.cpp */,
+                               AD5A0C201DECA0B500707054 /* PerformanceLogging.h */,
                                316FE1060E6E1D8400BF6088 /* animation */,
                                5D5975B5196362BE00D00878 /* cocoa */,
                                CE17AD141C58522F005F4799 /* csp */,
                                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 */,
                                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 */,
                                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 */,
index 1443981..bd55437 100644 (file)
@@ -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 @@ void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType t
         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::setProvisionalDocumentLoader(DocumentLoader* loader)
 }
 
 void FrameLoader::setState(FrameState newState)
-{    
+{
+    FrameState oldState = m_state;
     m_state = newState;
     
     if (newState == FrameStateProvisional)
@@ -1737,6 +1741,8 @@ void FrameLoader::setState(FrameState newState)
         frameLoadCompleted();
         if (m_documentLoader)
             m_documentLoader->stopRecordingResponses();
+        if (m_frame.isMainFrame() && oldState != newState)
+            static_cast<MainFrame&>(m_frame).performanceLogging().didReachPointOfInterest(PerformanceLogging::MainFrameLoadCompleted);
     }
 }
 
index 282070e..06cb62d 100644 (file)
@@ -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 @@ inline MainFrame::MainFrame(Page& page, PageConfiguration& configuration)
 #if ENABLE(APPLE_PAY)
     , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient))
 #endif
+    , m_performanceLogging(std::make_unique<PerformanceLogging>(*this))
 {
 }
 
index e3e75cd..3e088f0 100644 (file)
@@ -34,6 +34,7 @@ namespace WebCore {
 class PageConfiguration;
 class PageOverlayController;
 class PaymentCoordinator;
+class PerformanceLogging;
 class ScrollLatchingState;
 class ServicesOverlayController;
 class WheelEventDeltaFilter;
@@ -66,6 +67,8 @@ public:
     PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; }
 #endif
 
+    PerformanceLogging& performanceLogging() const { return *m_performanceLogging; }
+
 private:
     MainFrame(Page&, PageConfiguration&);
 
@@ -86,6 +89,8 @@ private:
 #if ENABLE(APPLE_PAY)
     std::unique_ptr<PaymentCoordinator> m_paymentCoordinator;
 #endif
+
+    std::unique_ptr<PerformanceLogging> m_performanceLogging;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/page/PerformanceLogging.cpp b/Source/WebCore/page/PerformanceLogging.cpp
new file mode 100644 (file)
index 0000000..144b0fd
--- /dev/null
@@ -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
+
+}
diff --git a/Source/WebCore/page/PerformanceLogging.h b/Source/WebCore/page/PerformanceLogging.h
new file mode 100644 (file)
index 0000000..192ae18
--- /dev/null
@@ -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;
+};
+
+}
diff --git a/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm b/Source/WebCore/page/cocoa/PerformanceLoggingCocoa.mm
new file mode 100644 (file)
index 0000000..4d71bfb
--- /dev/null
@@ -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));
+}
+
+}
index 04cf711..f3409d1 100644 (file)
@@ -65,6 +65,7 @@ namespace WebCore {
     M(Network) \
     M(NotYetImplemented) \
     M(PageCache) \
+    M(PerformanceLogging) \
     M(PlatformLeaks) \
     M(Plugins) \
     M(PopupBlocking) \