From 32ab4ea83378f8a8e650f88ad00a2a92b2c8e200 Mon Sep 17 00:00:00 2001 From: Terrence Cole Date: Wed, 26 Aug 2015 14:51:43 -0700 Subject: [PATCH] Bug 1196848 - Add Zone::uniqueIds to about:memory reports; r=njn --- js/public/MemoryMetrics.h | 3 ++- js/src/gc/Zone.h | 8 +++++++- js/src/vm/MemoryMetrics.cpp | 3 ++- js/src/vm/TypeInference.cpp | 4 +++- js/xpconnect/src/XPCJSRuntime.cpp | 4 ++++ 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/js/public/MemoryMetrics.h b/js/public/MemoryMetrics.h index c06a4838998..dd1d3ed377f 100644 --- a/js/public/MemoryMetrics.h +++ b/js/public/MemoryMetrics.h @@ -586,7 +586,8 @@ struct ZoneStats macro(Other, GCHeapUsed, objectGroupsGCHeap) \ macro(Other, MallocHeap, objectGroupsMallocHeap) \ macro(Other, MallocHeap, typePool) \ - macro(Other, MallocHeap, baselineStubsOptimized) + macro(Other, MallocHeap, baselineStubsOptimized) \ + macro(Other, MallocHeap, uniqueIdMap) ZoneStats() : FOR_EACH_SIZE(ZERO_SIZE) diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h index 7dd97eb1b49..0fb9b2e0613 100644 --- a/js/src/gc/Zone.h +++ b/js/src/gc/Zone.h @@ -119,6 +119,11 @@ class UniqueIdMap void remove(Cell* cell) { map.remove(Pair(cell, 0)); } + + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { + // All data allocated by |map| is contained in |alloc|. + return alloc.sizeOfExcludingThis(mallocSizeOf); + } }; extern uint64_t NextCellUniqueId(JSRuntime* rt); @@ -183,7 +188,8 @@ struct Zone : public JS::shadow::Zone, void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t* typePool, - size_t* baselineStubsOptimized); + size_t* baselineStubsOptimized, + size_t* uniqueIdMap); void resetGCMallocBytes(); void setGCMaxMallocBytes(size_t value); diff --git a/js/src/vm/MemoryMetrics.cpp b/js/src/vm/MemoryMetrics.cpp index 7d947e682a5..3be957eb97c 100644 --- a/js/src/vm/MemoryMetrics.cpp +++ b/js/src/vm/MemoryMetrics.cpp @@ -311,7 +311,8 @@ StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone) zone->addSizeOfIncludingThis(rtStats->mallocSizeOf_, &zStats.typePool, - &zStats.baselineStubsOptimized); + &zStats.baselineStubsOptimized, + &zStats.uniqueIdMap); } static void diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index 75561634039..50833a9d617 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -4276,13 +4276,15 @@ TypeScript::destroy() void Zone::addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf, size_t* typePool, - size_t* baselineStubsOptimized) + size_t* baselineStubsOptimized, + size_t* uniqueIdMap) { *typePool += types.typeLifoAlloc.sizeOfExcludingThis(mallocSizeOf); if (jitZone()) { *baselineStubsOptimized += jitZone()->optimizedStubSpace()->sizeOfExcludingThis(mallocSizeOf); } + *uniqueIdMap += uniqueIds_.sizeOfExcludingThis(mallocSizeOf); } TypeZone::TypeZone(Zone* zone) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 2930d6a4aca..c4844c776f4 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1883,6 +1883,10 @@ ReportZoneStats(const JS::ZoneStats& zStats, zStats.unusedGCThings.totalSize(), "Unused GC thing cells within non-empty arenas."); + ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("unique-id-map"), + zStats.uniqueIdMap, + "Address-independent cell identities."); + ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/gc-heap"), zStats.lazyScriptsGCHeap, "Scripts that haven't executed yet.");