#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>
+ "</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
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);