Bug 946781 - part 5 - measure the proto and iface cache from within xpconnect; r=bholley,njn
authorNathan Froyd <froydnj@mozilla.com>
Fri, 06 Dec 2013 13:08:45 -0500
changeset 160150 f9149f2fc278284e1d6279bf379f26a6ba6bde58
parent 160149 93672f14794435a9f9a5e5ecdd0aec6bac1cedef
child 160151 0af44c4131fb538d6bea82f40c193e668956e673
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbholley, njn
bugs946781
milestone29.0a1
Bug 946781 - part 5 - measure the proto and iface cache from within xpconnect; r=bholley,njn
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -2723,16 +2723,20 @@ JSReporter::CollectReports(WindowPaths *
     REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/runtime"),
                  KIND_HEAP, xpconnect,
                  "Memory used by XPConnect runtime.");
 
     REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/scopes"),
                  KIND_HEAP, sizeInfo.mScopeAndMapSize,
                  "Memory used by XPConnect scopes.");
 
+    REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/proto-iface-cache"),
+                 KIND_HEAP, sizeInfo.mProtoAndIfaceCacheSize,
+                 "Memory used for prototype and interface binding caches.");
+
     REPORT_BYTES(NS_LITERAL_CSTRING("explicit/xpconnect/js-component-loader"),
                  KIND_HEAP, jsComponentLoaderSize,
                  "Memory used by XPConnect's JS component loader.");
 
     return NS_OK;
 }
 
 static nsresult
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -674,12 +674,18 @@ void
 XPCWrappedNativeScope::AddSizeOfIncludingThis(ScopeSizeInfo* scopeSizeInfo)
 {
     scopeSizeInfo->mScopeAndMapSize += scopeSizeInfo->mMallocSizeOf(this);
     scopeSizeInfo->mScopeAndMapSize +=
         mWrappedNativeMap->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
     scopeSizeInfo->mScopeAndMapSize +=
         mWrappedNativeProtoMap->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
 
+    if (dom::HasProtoAndIfaceArray(mGlobalJSObject)) {
+        dom::ProtoAndIfaceArray* cache = dom::GetProtoAndIfaceArray(mGlobalJSObject);
+        scopeSizeInfo->mProtoAndIfaceCacheSize +=
+            cache->SizeOfIncludingThis(scopeSizeInfo->mMallocSizeOf);
+    }
+
     // There are other XPCWrappedNativeScope members that could be measured;
     // the above ones have been seen by DMD to be worth measuring.  More stuff
     // may be added later.
 }
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -1134,20 +1134,24 @@ public:
     static void
     DebugDumpAllScopes(int16_t depth);
 
     void
     DebugDump(int16_t depth);
 
     struct ScopeSizeInfo {
         ScopeSizeInfo(mozilla::MallocSizeOf mallocSizeOf)
-            : mMallocSizeOf(mallocSizeOf), mScopeAndMapSize(0) {}
+            : mMallocSizeOf(mallocSizeOf),
+              mScopeAndMapSize(0),
+              mProtoAndIfaceCacheSize(0)
+        {}
 
         mozilla::MallocSizeOf mMallocSizeOf;
         size_t mScopeAndMapSize;
+        size_t mProtoAndIfaceCacheSize;
     };
 
     static void
     AddSizeOfAllScopesIncludingThis(ScopeSizeInfo* scopeSizeInfo);
 
     void
     AddSizeOfIncludingThis(ScopeSizeInfo* scopeSizeInfo);