Bug 832026 - Measure JSRuntime::bumpAlloc_ in the JS memory reporter. r=sstangl.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 17 Jan 2013 17:50:21 -0800
changeset 129884 4f0b7a4daacf6405c06030b303e25e1d4ed82c7e
parent 129883 074f935b494a81e1aba3bcdb6fae3490aee35455
child 129885 4e7658d7727cd57f6cce532d420d2cdb4a92d14d
push id317
push userbbajaj@mozilla.com
push dateTue, 07 May 2013 01:20:33 +0000
treeherdermozilla-release@159a10910249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs832026
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 832026 - Measure JSRuntime::bumpAlloc_ in the JS memory reporter. r=sstangl.
content/svg/content/src/DOMSVGPoint.cpp
js/public/MemoryMetrics.h
js/src/jit-test/jit_test.py
js/src/jscntxt.cpp
js/src/yarr/BumpPointerAllocator.h
js/xpconnect/src/XPCJSRuntime.cpp
layout/reftests/css-calc/background-image-gradient-1-ref.html
layout/reftests/css-calc/background-image-gradient-1.html
layout/reftests/css-calc/reftest.list
layout/reftests/text/auto-hyphenation-10.html
layout/reftests/text/auto-hyphenation-8.html
layout/reftests/text/auto-hyphenation-9.html
services/sync/SyncComponents.manifest
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -115,42 +115,28 @@ struct HugeStringInfo
     // string so we can use a char[] instead of a jschar[] here.
     char buffer[32];
 };
 
 // These measurements relate directly to the JSRuntime, and not to
 // compartments within it.
 struct RuntimeSizes
 {
-    RuntimeSizes()
-      : object(0)
-      , atomsTable(0)
-      , contexts(0)
-      , dtoa(0)
-      , temporary(0)
-      , jaegerCode(0)
-      , ionCode(0)
-      , regexpCode(0)
-      , unusedCode(0)
-      , stack(0)
-      , gcMarker(0)
-      , mathCache(0)
-      , scriptFilenames(0)
-      , scriptSources(0)
-    {}
+    RuntimeSizes() { memset(this, 0, sizeof(RuntimeSizes)); }
 
     size_t object;
     size_t atomsTable;
     size_t contexts;
     size_t dtoa;
     size_t temporary;
     size_t jaegerCode;
     size_t ionCode;
     size_t regexpCode;
     size_t unusedCode;
+    size_t regexpData;
     size_t stack;
     size_t gcMarker;
     size_t mathCache;
     size_t scriptFilenames;
     size_t scriptSources;
 };
 
 struct CompartmentStats
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -129,39 +129,44 @@ JSRuntime::sizeOfIncludingThis(JSMallocS
                                &rtSizes->unusedCode);
     } else {
         rtSizes->jaegerCode = 0;
         rtSizes->ionCode    = 0;
         rtSizes->regexpCode = 0;
         rtSizes->unusedCode = 0;
     }
 
+    rtSizes->regexpData = bumpAlloc_ ? bumpAlloc_->sizeOfNonHeapData() : 0;
+
     rtSizes->stack = stackSpace.sizeOf();
 
     rtSizes->gcMarker = gcMarker.sizeOfExcludingThis(mallocSizeOf);
 
     rtSizes->mathCache = mathCache_ ? mathCache_->sizeOfIncludingThis(mallocSizeOf) : 0;
 
     rtSizes->scriptFilenames = scriptFilenameTable.sizeOfExcludingThis(mallocSizeOf);
     for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
         rtSizes->scriptFilenames += mallocSizeOf(r.front());
 }
 
 size_t
 JSRuntime::sizeOfExplicitNonHeap()
 {
-    size_t size = stackSpace.sizeOf();
+    size_t n = stackSpace.sizeOf();
 
     if (execAlloc_) {
         size_t jaegerCode, ionCode, regexpCode, unusedCode;
         execAlloc_->sizeOfCode(&jaegerCode, &ionCode, &regexpCode, &unusedCode);
-        size += jaegerCode + ionCode + regexpCode + unusedCode;
+        n += jaegerCode + ionCode + regexpCode + unusedCode;
     }
 
-    return size;
+    if (bumpAlloc_)
+        n += bumpAlloc_->sizeOfNonHeapData();
+
+    return n;
 }
 
 void
 JSRuntime::triggerOperationCallback()
 {
     /*
      * Invalidate ionTop to trigger its over-recursion check. Note this must be
      * set before interrupt, to avoid racing with js_InvokeOperationCallback,
--- a/js/src/yarr/BumpPointerAllocator.h
+++ b/js/src/yarr/BumpPointerAllocator.h
@@ -91,16 +91,28 @@ public:
         if ((position >= m_start) && (position <= static_cast<void*>(this))) {
             ASSERT(position <= m_current);
             m_current = position;
             return this;
         }
         return deallocCrossPool(this, position);
     }
 
+    size_t sizeOfNonHeapData() const
+    {
+        ASSERT(!m_previous);
+        size_t n = 0;
+        const BumpPointerPool *curr = this;
+        while (curr) {
+            n += m_allocation.size();
+            curr = curr->m_next;
+        }
+        return n;
+    }
+
 private:
     // Placement operator new, returns the last 'size' bytes of allocation for use as this.
     void* operator new(size_t size, const PageAllocation& allocation)
     {
         ASSERT(size < allocation.size());
         return reinterpret_cast<char*>(reinterpret_cast<intptr_t>(allocation.base()) + allocation.size()) - size;
     }
 
@@ -244,16 +256,21 @@ public:
     }
 
     void stopAllocator()
     {
         if (m_head)
             m_head->shrink();
     }
 
+    size_t sizeOfNonHeapData() const
+    {
+        return m_head ? m_head->sizeOfNonHeapData() : 0;
+    }
+
 private:
     BumpPointerPool* m_head;
 };
 
 }
 
 using WTF::BumpPointerAllocator;
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1852,16 +1852,20 @@ ReportJSRuntimeExplicitTreeStats(const J
                   nsIMemoryReporter::KIND_NONHEAP, rtStats.runtime.regexpCode,
                   "Memory used by the regexp JIT to hold generated code.");
 
     RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/unused-code"),
                   nsIMemoryReporter::KIND_NONHEAP, rtStats.runtime.unusedCode,
                   "Memory allocated by one of the JITs to hold the "
                   "runtime's code, but which is currently unused.");
 
+    RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/regexp-data"),
+                  nsIMemoryReporter::KIND_NONHEAP, rtStats.runtime.regexpData,
+                  "Memory used by the regexp JIT to hold data.");
+
     RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/stack"),
                   nsIMemoryReporter::KIND_NONHEAP, rtStats.runtime.stack,
                   "Memory used for the JS call stack.  This is the committed "
                   "portion of the stack on Windows; on *nix, it is the resident "
                   "portion of the stack.  Therefore, on *nix, if part of the "
                   "stack is swapped out to disk, we do not count it here.\n\n"
                   "Note that debug builds usually have stack poisoning enabled, "
                   "which causes the whole stack to be committed (and likely "