Bug 882162: Part 11 - Push the final uses of mJSHolders down into mozilla::CycleCollectedJSRuntime and make it private. r=mccr8
authorKyle Huey <khuey@kylehuey.com>
Tue, 18 Jun 2013 12:02:16 -0700
changeset 147016 a2c9078d8b297f17b3867b36a14df997a66c971e
parent 147015 fa15cd24a711355b58d0b2abc8c02401d7e2b6fb
child 147017 089b861c6688313d079d106a97cdeff53c5700ad
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs882162
milestone24.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 882162: Part 11 - Push the final uses of mJSHolders down into mozilla::CycleCollectedJSRuntime and make it private. r=mccr8
js/xpconnect/src/XPCJSRuntime.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/CycleCollectedJSRuntime.h
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -520,28 +520,21 @@ XPCJSRuntime::TraverseAdditionalNativeRo
             CanSkipWrappedJS(wrappedJS)) {
             continue;
         }
 
         cb.NoteXPCOMRoot(static_cast<nsIXPConnectWrappedJS *>(wrappedJS));
     }
 }
 
-static PLDHashOperator
-UnmarkJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
-{
-    tracer->CanSkip(holder, true);
-    return PL_DHASH_NEXT;
-}
-
 void
 XPCJSRuntime::UnmarkSkippableJSHolders()
 {
     XPCAutoLock lock(mMapLock);
-    mJSHolders.Enumerate(UnmarkJSHolder, nullptr);
+    CycleCollectedJSRuntime::UnmarkSkippableJSHolders();
 }
 
 void
 xpc_UnmarkSkippableJSHolders()
 {
     if (nsXPConnect::XPConnect()->GetRuntime()) {
         nsXPConnect::XPConnect()->GetRuntime()->UnmarkSkippableJSHolders();
     }
@@ -1108,19 +1101,17 @@ XPCJSRuntime::SizeOfIncludingThis(nsMall
 {
     size_t n = 0;
     n += mallocSizeOf(this);
     n += mWrappedJSMap->SizeOfIncludingThis(mallocSizeOf);
     n += mIID2NativeInterfaceMap->SizeOfIncludingThis(mallocSizeOf);
     n += mClassInfo2NativeSetMap->ShallowSizeOfIncludingThis(mallocSizeOf);
     n += mNativeSetMap->SizeOfIncludingThis(mallocSizeOf);
 
-    // NULL for the second arg;  we're not measuring anything hanging off the
-    // entries in mJSHolders.
-    n += mJSHolders.SizeOfExcludingThis(nullptr, mallocSizeOf);
+    n += CycleCollectedJSRuntime::SizeOfExcludingThis(mallocSizeOf);
 
     // There are other XPCJSRuntime members that could be measured; the above
     // ones have been seen by DMD to be worth measuring.  More stuff may be
     // added later.
 
     return n;
 }
 
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -474,16 +474,41 @@ CycleCollectedJSRuntime::CycleCollectedJ
 CycleCollectedJSRuntime::~CycleCollectedJSRuntime()
 {
   nsCycleCollector_forgetJSRuntime();
 
   JS_DestroyRuntime(mJSRuntime);
   mJSRuntime = nullptr;
 }
 
+size_t
+CycleCollectedJSRuntime::SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const
+{
+  size_t n = 0;
+
+  // NULL for the second arg;  we're not measuring anything hanging off the
+  // entries in mJSHolders.
+  n += mJSHolders.SizeOfExcludingThis(nullptr, aMallocSizeOf);
+
+  return n;
+}
+
+static PLDHashOperator
+UnmarkJSHolder(void* holder, nsScriptObjectTracer*& tracer, void* arg)
+{
+  tracer->CanSkip(holder, true);
+  return PL_DHASH_NEXT;
+}
+
+void
+CycleCollectedJSRuntime::UnmarkSkippableJSHolders()
+{
+  mJSHolders.Enumerate(UnmarkJSHolder, nullptr);
+}
+
 void
 CycleCollectedJSRuntime::MaybeTraceGlobals(JSTracer* aTracer) const
 {
   JSContext* iter = nullptr;
   while (JSContext* acx = JS_ContextIterator(Runtime(), &iter)) {
     MOZ_ASSERT(js::HasUnrootedGlobal(acx) == mExpectUnrootedGlobals);
     if (!js::HasUnrootedGlobal(acx)) {
       continue;
--- a/xpcom/base/CycleCollectedJSRuntime.h
+++ b/xpcom/base/CycleCollectedJSRuntime.h
@@ -83,16 +83,19 @@ protected:
   virtual ~CycleCollectedJSRuntime();
 
   JSRuntime* Runtime() const
   {
     MOZ_ASSERT(mJSRuntime);
     return mJSRuntime;
   }
 
+  size_t SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
+  void UnmarkSkippableJSHolders();
+
   virtual void TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& aCb) = 0;
   virtual void TraceAdditionalNativeGrayRoots(JSTracer* aTracer) = 0;
 
 private:
 
   void
   DescribeGCThing(bool aIsMarked, void* aThing, JSGCTraceKind aTraceKind,
                   nsCycleCollectionTraversalCallback& aCb) const;
@@ -163,29 +166,27 @@ public:
   void NotifyLeaveCycleCollectionThread() const;
   void NotifyEnterMainThread() const;
   nsresult BeginCycleCollection(nsCycleCollectionNoteRootCallback &aCb);
   bool UsefulToMergeZones() const;
   void FixWeakMappingGrayBits() const;
   bool NeedCollect() const;
   void Collect(uint32_t reason) const;
 
-// XXXkhuey should be private
-protected:
-  nsDataHashtable<nsPtrHashKey<void>, nsScriptObjectTracer*> mJSHolders;
-
 private:
   typedef const CCParticipantVTable<JSGCThingParticipant>::Type GCThingParticipantVTable;
   const GCThingParticipantVTable mGCThingCycleCollectorGlobal;
 
   typedef const CCParticipantVTable<JSZoneParticipant>::Type JSZoneParticipantVTable;
   const JSZoneParticipantVTable mJSZoneCycleCollectorGlobal;
 
   JSRuntime* mJSRuntime;
 
+  nsDataHashtable<nsPtrHashKey<void>, nsScriptObjectTracer*> mJSHolders;
+
 #ifdef DEBUG
   void* mObjectToUnlink;
   bool mExpectUnrootedGlobals;
 #endif
 };
 
 } // namespace mozilla