Title: [94298] trunk/Source
Revision
94298
Author
[email protected]
Date
2011-09-01 08:09:50 -0700 (Thu, 01 Sep 2011)

Log Message

Source/_javascript_Core: Export fastMallocStatistics and Heap::objectTypeCounts for https://bugs.webkit.org/show_bug.cgi?id=67160.

Reviewed by Darin Adler.

* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:

Source/WebKit2: Gather _javascript_, FastMalloc, icon, font, and glyph page statistics in WebProcess::getWebCoreStatistics().
https://bugs.webkit.org/show_bug.cgi?id=67160

Reviewed by Darin Adler.

Encode and decode the data members in StatisticsData.
* Shared/StatisticsData.cpp:
(WebKit::StatisticsData::encode):
(WebKit::StatisticsData::decode):
(WebKit::StatisticsData::StatisticsData):

Add three data members to StatisticsData:
- statisticsNumbers: Map containing statistics values that are numbers, mapped by their names, such as 
_javascript_ObjectsCount, CachedFontDataCount, etc.
- _javascript_ProtectedObjectTypeCounts
- _javascript_ObjectTypeCounts
* Shared/StatisticsData.h:

Create a WK::Dictionary containing statistics values mapped by their names and return that dictionary
in WebContext::didGetWebCoreStatistics().
* UIProcess/WebContext.cpp:
(WebKit::createDictionaryFromHashMap):
(WebKit::WebContext::didGetWebCoreStatistics):

Package _javascript_, FastMalloc, icon, font, and glyph page statistics into a StatisticsData object
and send it to the UIProcess.
* WebProcess/WebProcess.cpp:
(WebKit::fromCountedSetToHashMap):
(WebKit::WebProcess::getWebCoreStatistics):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (94297 => 94298)


--- trunk/Source/_javascript_Core/ChangeLog	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-09-01 15:09:50 UTC (rev 94298)
@@ -1,3 +1,11 @@
+2011-09-01  Ada Chan  <[email protected]>
+
+        Export fastMallocStatistics and Heap::objectTypeCounts for https://bugs.webkit.org/show_bug.cgi?id=67160.
+
+        Reviewed by Darin Adler.
+
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+
 2011-09-01  Hao Zheng  <[email protected]>
 
         Define PTHREAD_KEYS_MAX to fix Android port build.

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (94297 => 94298)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2011-09-01 15:09:50 UTC (rev 94298)
@@ -162,6 +162,7 @@
     ?fastMalloc@WTF@@YAPAXI@Z
     ?fastMallocMatchFailed@Internal@WTF@@YAXPAX@Z
     ?fastMallocSize@WTF@@YAIPBX@Z
+    ?fastMallocStatistics@WTF@@YA?AUFastMallocStatistics@1@XZ
     ?fastRealloc@WTF@@YAPAXPAXI@Z
     ?fastStrDup@WTF@@YAPADPBD@Z
     ?fastZeroedMalloc@WTF@@YAPAXI@Z
@@ -253,6 +254,7 @@
     ?numberToString@WTF@@YAINQA_W@Z
     ?objectCount@Heap@JSC@@QAEIXZ
     ?objectProtoFuncToString@JSC@@YI_JPAVExecState@1@@Z
+    ?objectTypeCounts@Heap@JSC@@QAE?AV?$PassOwnPtr@V?$HashCountedSet@PBDU?$PtrHash@PBD@WTF@@U?$HashTraits@PBD@2@@WTF@@@WTF@@XZ
     ?parseDateFromNullTerminatedCharacters@WTF@@YANPBD@Z
     ?preventExtensions@JSObject@JSC@@UAEXAAVJSGlobalData@2@@Z
     ?profiler@Profiler@JSC@@SAPAV12@XZ

Modified: trunk/Source/WebKit2/ChangeLog (94297 => 94298)


--- trunk/Source/WebKit2/ChangeLog	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/WebKit2/ChangeLog	2011-09-01 15:09:50 UTC (rev 94298)
@@ -1,3 +1,35 @@
+2011-09-01  Ada Chan  <[email protected]>
+
+        Gather _javascript_, FastMalloc, icon, font, and glyph page statistics in WebProcess::getWebCoreStatistics().
+        https://bugs.webkit.org/show_bug.cgi?id=67160
+
+        Reviewed by Darin Adler.
+
+        Encode and decode the data members in StatisticsData.
+        * Shared/StatisticsData.cpp:
+        (WebKit::StatisticsData::encode):
+        (WebKit::StatisticsData::decode):
+        (WebKit::StatisticsData::StatisticsData):
+
+        Add three data members to StatisticsData:
+        - statisticsNumbers: Map containing statistics values that are numbers, mapped by their names, such as 
+        _javascript_ObjectsCount, CachedFontDataCount, etc.
+        - _javascript_ProtectedObjectTypeCounts
+        - _javascript_ObjectTypeCounts
+        * Shared/StatisticsData.h:
+
+        Create a WK::Dictionary containing statistics values mapped by their names and return that dictionary
+        in WebContext::didGetWebCoreStatistics().
+        * UIProcess/WebContext.cpp:
+        (WebKit::createDictionaryFromHashMap):
+        (WebKit::WebContext::didGetWebCoreStatistics):
+
+        Package _javascript_, FastMalloc, icon, font, and glyph page statistics into a StatisticsData object
+        and send it to the UIProcess.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::fromCountedSetToHashMap):
+        (WebKit::WebProcess::getWebCoreStatistics):
+
 2011-09-01  Xan Lopez  <[email protected]>
 
         [GTK] Add XRender lib dependencies explicitly

Modified: trunk/Source/WebKit2/Shared/StatisticsData.cpp (94297 => 94298)


--- trunk/Source/WebKit2/Shared/StatisticsData.cpp	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/WebKit2/Shared/StatisticsData.cpp	2011-09-01 15:09:50 UTC (rev 94298)
@@ -32,18 +32,25 @@
 
 void StatisticsData::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
-    // FIXME: To be implemented.
+    encoder->encode(statisticsNumbers);
+    encoder->encode(_javascript_ProtectedObjectTypeCounts);
+    encoder->encode(_javascript_ObjectTypeCounts);
 }
 
 bool StatisticsData::decode(CoreIPC::ArgumentDecoder* decoder, StatisticsData& statisticsData)
 {
-    // FIXME: To be implemented.
+    if (!decoder->decode(statisticsData.statisticsNumbers))
+        return false;
+    if (!decoder->decode(statisticsData._javascript_ProtectedObjectTypeCounts))
+        return false;
+    if (!decoder->decode(statisticsData._javascript_ObjectTypeCounts))
+        return false;
+
     return true;
 }
 
 StatisticsData::StatisticsData()
 {    
-    // FIXME: To be implemented.
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/Shared/StatisticsData.h (94297 => 94298)


--- trunk/Source/WebKit2/Shared/StatisticsData.h	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/WebKit2/Shared/StatisticsData.h	2011-09-01 15:09:50 UTC (rev 94298)
@@ -28,6 +28,9 @@
 
 #include "ArgumentDecoder.h"
 #include "ArgumentEncoder.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
@@ -35,6 +38,10 @@
     void encode(CoreIPC::ArgumentEncoder*) const;
     static bool decode(CoreIPC::ArgumentDecoder*, StatisticsData&);
     
+    HashMap<String, uint64_t> statisticsNumbers;
+    HashMap<String, uint64_t> _javascript_ProtectedObjectTypeCounts;
+    HashMap<String, uint64_t> _javascript_ObjectTypeCounts;    
+    
     StatisticsData();
 };
 

Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (94297 => 94298)


--- trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp	2011-09-01 15:09:50 UTC (rev 94298)
@@ -30,8 +30,10 @@
 #include "ImmutableArray.h"
 #include "InjectedBundleMessageKinds.h"
 #include "Logging.h"
+#include "MutableDictionary.h"
 #include "RunLoop.h"
 #include "SandboxExtension.h"
+#include "StatisticsData.h"
 #include "TextChecker.h"
 #include "WKContextPrivate.h"
 #include "WebApplicationCacheManagerProxy.h"
@@ -796,6 +798,16 @@
     process()->send(Messages::WebProcess::GetWebCoreStatistics(callbackID), 0);
 }
 
+static PassRefPtr<MutableDictionary> createDictionaryFromHashMap(const HashMap<String, uint64_t>& map)
+{
+    RefPtr<MutableDictionary> result = MutableDictionary::create();
+    HashMap<String, uint64_t>::const_iterator end = map.end();
+    for (HashMap<String, uint64_t>::const_iterator it = map.begin(); it != end; ++it)
+        result->set(it->first, RefPtr<WebUInt64>(WebUInt64::create(it->second)).get());
+    
+    return result;
+}
+
 void WebContext::didGetWebCoreStatistics(const StatisticsData& statisticsData, uint64_t callbackID)
 {
     RefPtr<DictionaryCallback> callback = m_dictionaryCallbacks.take(callbackID);
@@ -803,9 +815,11 @@
         // FIXME: Log error or assert.
         return;
     }
-     
-    // FIXME: Store statistics data into a dictionary.
-    RefPtr<ImmutableDictionary> statistics = ImmutableDictionary::create();
+
+    RefPtr<MutableDictionary> statistics = createDictionaryFromHashMap(statisticsData.statisticsNumbers);
+    statistics->set("_javascript_ProtectedObjectTypeCounts", createDictionaryFromHashMap(statisticsData._javascript_ProtectedObjectTypeCounts).get());
+    statistics->set("_javascript_ObjectTypeCounts", createDictionaryFromHashMap(statisticsData._javascript_ObjectTypeCounts).get());
+    
     callback->performCallbackWithReturnValue(statistics.get());
 }
     

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (94297 => 94298)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-09-01 14:41:47 UTC (rev 94297)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2011-09-01 15:09:50 UTC (rev 94298)
@@ -52,10 +52,16 @@
 #include "WebProcessMessages.h"
 #include "WebProcessProxyMessages.h"
 #include "WebResourceCacheManager.h"
+#include <_javascript_Core/JSLock.h>
+#include <_javascript_Core/MemoryStatistics.h>
 #include <WebCore/AXObjectCache.h>
 #include <WebCore/ApplicationCacheStorage.h>
 #include <WebCore/CrossOriginPreflightResultCache.h>
 #include <WebCore/Font.h>
+#include <WebCore/FontCache.h>
+#include <WebCore/GlyphPageTreeNode.h>
+#include <WebCore/IconDatabase.h>
+#include <WebCore/JSDOMWindow.h>
 #include <WebCore/Language.h>
 #include <WebCore/Logging.h>
 #include <WebCore/MemoryCache.h>
@@ -68,6 +74,7 @@
 #include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
 #include <WebCore/StorageTracker.h>
+#include <wtf/HashCountedSet.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RandomNumber.h>
 
@@ -83,6 +90,7 @@
 #include "NetscapePluginModule.h"
 #endif
 
+using namespace JSC;
 using namespace WebCore;
 
 namespace WebKit {
@@ -818,12 +826,56 @@
 }
 #endif
     
+static void fromCountedSetToHashMap(TypeCountSet* countedSet, HashMap<String, uint64_t>& map)
+{
+    TypeCountSet::const_iterator end = countedSet->end();
+    for (TypeCountSet::const_iterator it = countedSet->begin(); it != end; ++it)
+        map.set(it->first, it->second);
+}
+
 void WebProcess::getWebCoreStatistics(uint64_t callbackID)
 {
     StatisticsData data;
     
-    // FIXME: Gather performance data.
+    // Gather _javascript_ statistics.
+    {
+        JSLock lock(SilenceAssertionsOnly);
+        data.statisticsNumbers.set("_javascript_ObjectsCount", JSDOMWindow::commonJSGlobalData()->heap.objectCount());
+        data.statisticsNumbers.set("_javascript_GlobalObjectsCount", JSDOMWindow::commonJSGlobalData()->heap.globalObjectCount());
+        data.statisticsNumbers.set("_javascript_ProtectedObjectsCount", JSDOMWindow::commonJSGlobalData()->heap.protectedObjectCount());
+        data.statisticsNumbers.set("_javascript_ProtectedGlobalObjectsCount", JSDOMWindow::commonJSGlobalData()->heap.protectedGlobalObjectCount());
+        
+        OwnPtr<TypeCountSet> protectedObjectTypeCounts(JSDOMWindow::commonJSGlobalData()->heap.protectedObjectTypeCounts());
+        fromCountedSetToHashMap(protectedObjectTypeCounts.get(), data._javascript_ProtectedObjectTypeCounts);
+        
+        OwnPtr<TypeCountSet> objectTypeCounts(JSDOMWindow::commonJSGlobalData()->heap.objectTypeCounts());
+        fromCountedSetToHashMap(objectTypeCounts.get(), data._javascript_ObjectTypeCounts);
+        
+        uint64_t _javascript_HeapSize = JSDOMWindow::commonJSGlobalData()->heap.size();
+        data.statisticsNumbers.set("_javascript_HeapSize", _javascript_HeapSize);
+        data.statisticsNumbers.set("_javascript_FreeSize", JSDOMWindow::commonJSGlobalData()->heap.capacity() - _javascript_HeapSize);
+    }
+
+    WTF::FastMallocStatistics fastMallocStatistics = WTF::fastMallocStatistics();
+    data.statisticsNumbers.set("FastMallocReservedVMBytes", fastMallocStatistics.reservedVMBytes);
+    data.statisticsNumbers.set("FastMallocCommittedVMBytes", fastMallocStatistics.committedVMBytes);
+    data.statisticsNumbers.set("FastMallocFreeListBytes", fastMallocStatistics.freeListBytes);
     
+    // Gather icon statistics.
+    data.statisticsNumbers.set("IconPageURLMappingCount", iconDatabase().pageURLMappingCount());
+    data.statisticsNumbers.set("IconRetainedPageURLCount", iconDatabase().retainedPageURLCount());
+    data.statisticsNumbers.set("IconRecordCount", iconDatabase().iconRecordCount());
+    data.statisticsNumbers.set("IconsWithDataCount", iconDatabase().iconRecordCountWithData());
+    
+    // Gather font statistics.
+    data.statisticsNumbers.set("CachedFontDataCount", fontCache()->fontDataCount());
+    data.statisticsNumbers.set("CachedFontDataInactiveCount", fontCache()->inactiveFontDataCount());
+    
+    // Gather glyph page statistics.
+    data.statisticsNumbers.set("GlyphPageCount", GlyphPageTreeNode::treeGlyphPageCount());
+    
+    // FIXME: Gather WebCore cache statistics.
+    
     m_connection->send(Messages::WebContext::DidGetWebCoreStatistics(data, callbackID), 0);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to