From 3d1624e9a0bdcf130fe435e062fa4c8c2f08abc1 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 17 Jan 2013 17:50:21 -0800 Subject: [PATCH] Bug 832026 - Measure JSRuntime::bumpAlloc_ in the JS memory reporter. r=sstangl. --HG-- rename : js/src/tests/lib/jittests.py => js/src/jit-test/jit_test.py rename : layout/reftests/w3c-css/submitted/values3/calc-background-image-gradient-1-ref.html => layout/reftests/css-calc/background-image-gradient-1-ref.html rename : layout/reftests/w3c-css/submitted/values3/calc-background-image-gradient-1.html => layout/reftests/css-calc/background-image-gradient-1.html rename : layout/reftests/w3c-css/submitted/values3/reftest.list => layout/reftests/css-calc/reftest.list rename : layout/reftests/text/auto-hyphenation-10-ref.html => layout/reftests/text/auto-hyphenation-10.html rename : layout/reftests/text/auto-hyphenation-8-ref.html => layout/reftests/text/auto-hyphenation-8.html rename : layout/reftests/text/auto-hyphenation-9-ref.html => layout/reftests/text/auto-hyphenation-9.html rename : services/common/servicesComponents.manifest => services/sync/SyncComponents.manifest extra : rebase_source : 6b9d955241e189e52c6145f3fb4c3169ec834b78 --- js/public/MemoryMetrics.h | 18 ++---------------- js/src/jscntxt.cpp | 11 ++++++++--- js/src/yarr/BumpPointerAllocator.h | 17 +++++++++++++++++ js/xpconnect/src/XPCJSRuntime.cpp | 4 ++++ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index 4c2fb0d29f5d..17a05d4f050f 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -120,22 +120,7 @@ struct HugeStringInfo // 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; @@ -146,6 +131,7 @@ struct RuntimeSizes size_t ionCode; size_t regexpCode; size_t unusedCode; + size_t regexpData; size_t stack; size_t gcMarker; size_t mathCache; diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index d3e56cdf2075..4e24d59a1c8f 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -134,6 +134,8 @@ JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtS rtSizes->unusedCode = 0; } + rtSizes->regexpData = bumpAlloc_ ? bumpAlloc_->sizeOfNonHeapData() : 0; + rtSizes->stack = stackSpace.sizeOf(); rtSizes->gcMarker = gcMarker.sizeOfExcludingThis(mallocSizeOf); @@ -148,15 +150,18 @@ JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtS 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, ®expCode, &unusedCode); - size += jaegerCode + ionCode + regexpCode + unusedCode; + n += jaegerCode + ionCode + regexpCode + unusedCode; } - return size; + if (bumpAlloc_) + n += bumpAlloc_->sizeOfNonHeapData(); + + return n; } void diff --git a/js/src/yarr/BumpPointerAllocator.h b/js/src/yarr/BumpPointerAllocator.h index 50610e2d9048..6d23a684831e 100644 --- a/js/src/yarr/BumpPointerAllocator.h +++ b/js/src/yarr/BumpPointerAllocator.h @@ -96,6 +96,18 @@ public: 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) @@ -249,6 +261,11 @@ public: m_head->shrink(); } + size_t sizeOfNonHeapData() const + { + return m_head ? m_head->sizeOfNonHeapData() : 0; + } + private: BumpPointerPool* m_head; }; diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index ed3f77374d67..bda89011dff6 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1857,6 +1857,10 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats, "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 "