[BlackBerry] Add JSC statistics into about:memory
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 00:08:19 +0000 (00:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jun 2012 00:08:19 +0000 (00:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89779

Patch by Yong Li <yoli@rim.com> on 2012-06-25
Reviewed by Rob Buis.

Source/JavaScriptCore:

Add MemoryStatistics.cpp into build, and fill JITBytes for BlackBerry port.

* PlatformBlackBerry.cmake:
* runtime/MemoryStatistics.cpp:
(JSC::globalMemoryStatistics):

Source/WebKit/blackberry:

Add detailed JS memory statistics to about:memory page.

* WebCoreSupport/AboutData.cpp:
(WebCore::dumpJSCTypeCountSetToTableHTML):
(WebCore):
(WebCore::memoryPage):

Source/WTF:

Turn on WTF_USE_EXPORT_MACROS for BlackBerry port.
This will make macros like JS_EXPORT_PRIVATE work without
extra porting.

* wtf/Platform.h:

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

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/PlatformBlackBerry.cmake
Source/JavaScriptCore/runtime/MemoryStatistics.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebKit/blackberry/ChangeLog
Source/WebKit/blackberry/WebCoreSupport/AboutData.cpp

index 20df558..cdefab9 100644 (file)
@@ -1,3 +1,16 @@
+2012-06-25  Yong Li  <yoli@rim.com>
+
+        [BlackBerry] Add JSC statistics into about:memory
+        https://bugs.webkit.org/show_bug.cgi?id=89779
+
+        Reviewed by Rob Buis.
+
+        Add MemoryStatistics.cpp into build, and fill JITBytes for BlackBerry port.
+
+        * PlatformBlackBerry.cmake:
+        * runtime/MemoryStatistics.cpp:
+        (JSC::globalMemoryStatistics):
+
 2012-06-23  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r121058.
index cc3cfea..f9352cd 100644 (file)
@@ -8,6 +8,7 @@ LIST(REMOVE_ITEM JavaScriptCore_SOURCES
 
 LIST(APPEND JavaScriptCore_SOURCES
     runtime/GCActivityCallbackBlackBerry.cpp
+    runtime/MemoryStatistics.cpp
 )
 
 INSTALL(FILES "wtf/Forward.h" DESTINATION usr/include/browser/webkit/wtf)
index 86101f5..e124d34 100644 (file)
@@ -37,7 +37,7 @@ GlobalMemoryStatistics globalMemoryStatistics()
     GlobalMemoryStatistics stats;
 
     stats.stackBytes = RegisterFile::committedByteCount();
-#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED)
+#if ENABLE(EXECUTABLE_ALLOCATOR_FIXED) || PLATFORM(BLACKBERRY)
     stats.JITBytes = ExecutableAllocator::committedByteCount();
 #else
     stats.JITBytes = 0;
index 10c251f..3c42063 100644 (file)
@@ -1,3 +1,16 @@
+2012-06-25  Yong Li  <yoli@rim.com>
+
+        [BlackBerry] Add JSC statistics into about:memory
+        https://bugs.webkit.org/show_bug.cgi?id=89779
+
+        Reviewed by Rob Buis.
+
+        Turn on WTF_USE_EXPORT_MACROS for BlackBerry port.
+        This will make macros like JS_EXPORT_PRIVATE work without
+        extra porting.
+
+        * wtf/Platform.h:
+
 2012-06-25  Adam Barth  <abarth@webkit.org>
 
         Use InterpolationLow on chromium-android
index 38f06e1..72e66f0 100644 (file)
    since most ports try to support sub-project independence, adding new headers
    to WTF causes many ports to break, and so this way we can address the build
    breakages one port at a time. */
-#if !defined(WTF_USE_EXPORT_MACROS) && (PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(WX))
+#if !defined(WTF_USE_EXPORT_MACROS) && (PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(WX) || PLATFORM(BLACKBERRY))
 #define WTF_USE_EXPORT_MACROS 1
 #endif
 
index f498b60..5919be5 100644 (file)
@@ -1,3 +1,17 @@
+2012-06-25  Yong Li  <yoli@rim.com>
+
+        [BlackBerry] Add JSC statistics into about:memory
+        https://bugs.webkit.org/show_bug.cgi?id=89779
+
+        Reviewed by Rob Buis.
+
+        Add detailed JS memory statistics to about:memory page.
+
+        * WebCoreSupport/AboutData.cpp:
+        (WebCore::dumpJSCTypeCountSetToTableHTML):
+        (WebCore):
+        (WebCore::memoryPage):
+
 2012-06-25  Crystal Zhang  <haizhang@rim.com>
 
         [BlackBerry] Use AIR controls if client doesn't support HTML control
index dc950b3..bc44ccb 100644 (file)
 #include "AboutData.h"
 
 #include "CString.h"
+#include "JSDOMWindow.h"
 #include "MemoryCache.h"
+#include "MemoryStatistics.h"
 #include "SurfacePool.h"
 #include "WebKitVersion.h"
 
 #include <process.h>
 #include <BlackBerryPlatformSettings.h>
+#include <heap/Heap.h>
+#include <runtime/JSGlobalData.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
 
@@ -188,19 +192,28 @@ static String cacheTypeStatisticToHTMLTr(const String& description, const Memory
         + "</tr>";
 }
 
+static void dumpJSCTypeCountSetToTableHTML(String& tableHTML, JSC::TypeCountSet* typeCountSet)
+{
+    if (!typeCountSet)
+        return;
+
+    for (JSC::TypeCountSet::const_iterator iter = typeCountSet->begin(); iter != typeCountSet->end(); ++iter)
+        tableHTML += numberToHTMLTr(iter->first, iter->second);
+}
+
 String memoryPage()
 {
     String page;
 
     // generate memory information
-    page = String("<html><head><title>BlackBerry Browser Memory Information</title></head><body><h2>BlackBerry Browser Memory Information</h2>");
+    page = "<html><head><title>BlackBerry Browser Memory Information</title></head><body><h2>BlackBerry Browser Memory Information</h2>";
 
     // generate cache information
     MemoryCache* cacheInc = memoryCache();
     MemoryCache::Statistics cacheStat = cacheInc->getStatistics();
 
-    page += String("<h2>Cache Information</h2>")
-            "<table align=\"center\" rules=\"all\"><tr> <th>Item</th> <th>Count</th> <th>Size<br>KB</th> <th>Living<br>KB</th> <th>Decoded<br>KB</th></tr>";
+    page += "<h2>Cache Information</h2>"
+            "<table align=\"center\" rules=\"all\"><tr> <th>Item</th> <th>Count</th> <th>Size<br>KB</th> <th>Living<br>KB</th> <th>Decoded<br>KB</th></tr>";
 
     MemoryCache::TypeStatistic total;
     total.count = cacheStat.images.count + cacheStat.cssStyleSheets.count
@@ -224,9 +237,38 @@ String memoryPage()
     page += "</table>";
 
 #if !defined(PUBLIC_BUILD) || !PUBLIC_BUILD
+
+    // JS engine memory usage.
+    JSC::GlobalMemoryStatistics jscMemoryStat = JSC::globalMemoryStatistics();
+    JSC::Heap& mainHeap = JSDOMWindow::commonJSGlobalData()->heap;
+    OwnPtr<JSC::TypeCountSet> objectTypeCounts = mainHeap.objectTypeCounts();
+    OwnPtr<JSC::TypeCountSet> protectedObjectTypeCounts = mainHeap.protectedObjectTypeCounts();
+
+    page += "<h2>JS engine memory usage</h2><table align=\"center\" rules=\"all\">";
+
+    page += numberToHTMLTr("Stack size", jscMemoryStat.stackBytes);
+    page += numberToHTMLTr("JIT memory usage", jscMemoryStat.JITBytes);
+    page += numberToHTMLTr("Main heap capacity", mainHeap.capacity());
+    page += numberToHTMLTr("Main heap size", mainHeap.size());
+    page += numberToHTMLTr("Object count", mainHeap.objectCount());
+    page += numberToHTMLTr("Global object count", mainHeap.globalObjectCount());
+    page += numberToHTMLTr("Protected object count", mainHeap.protectedObjectCount());
+    page += numberToHTMLTr("Protected global object count", mainHeap.protectedGlobalObjectCount());
+
+    page += "</table>";
+
+    page += "<h3>Object type counts</h3><table align=\"center\" rules=\"all\">";
+    dumpJSCTypeCountSetToTableHTML(page, objectTypeCounts.get());
+    page += "</table>";
+
+    page += "<h3>Protected object type counts</h3><table align=\"center\" rules=\"all\">";
+    dumpJSCTypeCountSetToTableHTML(page, protectedObjectTypeCounts.get());
+    page += "</table>";
+
+    // Malloc info.
     struct mallinfo mallocInfo = mallinfo();
 
-    page += String("<h2>Malloc Information</h2>") + "<table align=\"center\" rules=\"all\">";
+    page += "<h2>Malloc Information</h2><table align=\"center\" rules=\"all\">";
 
     page += numberToHTMLTr("Total space in use", mallocInfo.usmblks + mallocInfo.uordblks);
     page += numberToHTMLTr("Total space in free blocks", mallocInfo.fsmblks + mallocInfo.fordblks);