Bug 1119482, part 1 - Use CycleCollectedJSRuntime::Get() in the various CC wrapper methods. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Tue, 10 Mar 2015 16:41:38 -0700
changeset 232892 1da20013ecf69abbc1543b90dd8d7634c1bc3cb9
parent 232891 ba1cb75846f36bc22243d3d3b1f595fb880bf429
child 232893 a91f48050ad1695120259feeac6287c95dec5b48
push id56674
push useramccreight@mozilla.com
push dateTue, 10 Mar 2015 23:41:54 +0000
treeherdermozilla-inbound@6df619aca839 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1119482
milestone39.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 1119482, part 1 - Use CycleCollectedJSRuntime::Get() in the various CC wrapper methods. r=smaug It is a little cleaner to use this helper method if we only care about the CCJSRuntime pointer, and it will let us move some of these methods out of this file more easily.
xpcom/base/nsCycleCollector.cpp
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3910,25 +3910,19 @@ CycleCollectedJSRuntime::Get()
 
 
 namespace mozilla {
 namespace cyclecollector {
 
 void
 HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer)
 {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now.
-  MOZ_ASSERT(data);
-  MOZ_ASSERT(data->mCollector);
-  // And we should have a runtime.
-  MOZ_ASSERT(data->mRuntime);
-
-  data->mRuntime->AddJSHolder(aHolder, aTracer);
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
+  rt->AddJSHolder(aHolder, aTracer);
 }
 
 void
 HoldJSObjectsImpl(nsISupports* aHolder)
 {
   nsXPCOMCycleCollectionParticipant* participant = nullptr;
   CallQueryInterface(aHolder, &participant);
   MOZ_ASSERT(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
@@ -3936,25 +3930,19 @@ HoldJSObjectsImpl(nsISupports* aHolder)
              "The result of QIing a JS holder should be the same as ToSupports");
 
   HoldJSObjectsImpl(aHolder, participant);
 }
 
 void
 DropJSObjectsImpl(void* aHolder)
 {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now, and not completely
-  // shut down.
-  MOZ_ASSERT(data);
-  // And we should have a runtime.
-  MOZ_ASSERT(data->mRuntime);
-
-  data->mRuntime->RemoveJSHolder(aHolder);
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
+  rt->RemoveJSHolder(aHolder);
 }
 
 void
 DropJSObjectsImpl(nsISupports* aHolder)
 {
 #ifdef DEBUG
   nsXPCOMCycleCollectionParticipant* participant = nullptr;
   CallQueryInterface(aHolder, &participant);
@@ -3964,56 +3952,38 @@ DropJSObjectsImpl(nsISupports* aHolder)
 #endif
   DropJSObjectsImpl(static_cast<void*>(aHolder));
 }
 
 #ifdef DEBUG
 bool
 IsJSHolder(void* aHolder)
 {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now, and not completely
-  // shut down.
-  MOZ_ASSERT(data);
-  // And we should have a runtime.
-  MOZ_ASSERT(data->mRuntime);
-
-  return data->mRuntime->IsJSHolder(aHolder);
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
+  return rt->IsJSHolder(aHolder);
 }
 #endif
 
 void
 DeferredFinalize(nsISupports* aSupports)
 {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now, and not completely
-  // shut down.
-  MOZ_ASSERT(data);
-  // And we should have a runtime.
-  MOZ_ASSERT(data->mRuntime);
-
-  data->mRuntime->DeferredFinalize(aSupports);
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
+  rt->DeferredFinalize(aSupports);
 }
 
 void
 DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc,
                  DeferredFinalizeFunction aFunc,
                  void* aThing)
 {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now, and not completely
-  // shut down.
-  MOZ_ASSERT(data);
-  // And we should have a runtime.
-  MOZ_ASSERT(data->mRuntime);
-
-  data->mRuntime->DeferredFinalize(aAppendFunc, aFunc, aThing);
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
+  rt->DeferredFinalize(aAppendFunc, aFunc, aThing);
 }
 
 } // namespace cyclecollector
 } // namespace mozilla
 
 
 MOZ_NEVER_INLINE static void
 SuspectAfterShutdown(void* aPtr, nsCycleCollectionParticipant* aCp,
@@ -4133,23 +4103,20 @@ nsCycleCollector_forgetSkippable(bool aR
   data->mCollector->ForgetSkippable(aRemoveChildlessNodes,
                                     aAsyncSnowWhiteFreeing);
   timeLog.Checkpoint("ForgetSkippable()");
 }
 
 void
 nsCycleCollector_dispatchDeferredDeletion(bool aContinuation)
 {
-  CollectorData* data = sCollectorData.get();
-
-  if (!data || !data->mRuntime) {
-    return;
+  CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
+  if (rt) {
+    rt->DispatchDeferredDeletion(aContinuation);
   }
-
-  data->mRuntime->DispatchDeferredDeletion(aContinuation);
 }
 
 bool
 nsCycleCollector_doDeferredDeletion()
 {
   CollectorData* data = sCollectorData.get();
 
   // We should have started the cycle collector by now.