Bug 1119482, part 3 - Move the Hold and DropJSObjects implementations to a new HoldDropJSObjects.cpp file. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Tue, 10 Mar 2015 16:41:38 -0700
changeset 232914 6efde76492aec4498d8c913641ccfd13f4024f7d
parent 232913 a91f48050ad1695120259feeac6287c95dec5b48
child 232915 6df619aca8397154d2db902b249a9401629c7708
push id28396
push usercbook@mozilla.com
push dateWed, 11 Mar 2015 11:49:38 +0000
treeherdermozilla-central@b574129dcac0 [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 3 - Move the Hold and DropJSObjects implementations to a new HoldDropJSObjects.cpp file. r=smaug
xpcom/base/HoldDropJSObjects.cpp
xpcom/base/HoldDropJSObjects.h
xpcom/base/moz.build
xpcom/base/nsCycleCollector.cpp
new file mode 100644
--- /dev/null
+++ b/xpcom/base/HoldDropJSObjects.cpp
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "mozilla/HoldDropJSObjects.h"
+
+#include "mozilla/Assertions.h"
+#include "mozilla/CycleCollectedJSRuntime.h"
+
+namespace mozilla {
+namespace cyclecollector {
+
+void
+HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* 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!");
+  MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
+             "The result of QIing a JS holder should be the same as ToSupports");
+
+  HoldJSObjectsImpl(aHolder, participant);
+}
+
+void
+DropJSObjectsImpl(void* 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);
+  MOZ_ASSERT(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
+  MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
+             "The result of QIing a JS holder should be the same as ToSupports");
+#endif
+  DropJSObjectsImpl(static_cast<void*>(aHolder));
+}
+
+} // namespace cyclecollector
+} // namespace mozilla
--- a/xpcom/base/HoldDropJSObjects.h
+++ b/xpcom/base/HoldDropJSObjects.h
@@ -13,17 +13,16 @@
 class nsISupports;
 class nsScriptObjectTracer;
 
 // Only HoldJSObjects and DropJSObjects should be called directly.
 
 namespace mozilla {
 namespace cyclecollector {
 
-// These methods are defined in nsCycleCollector.cpp
 void HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* aTracer);
 void HoldJSObjectsImpl(nsISupports* aHolder);
 void DropJSObjectsImpl(void* aHolder);
 void DropJSObjectsImpl(nsISupports* aHolder);
 
 } // namespace cyclecollector
 
 
--- a/xpcom/base/moz.build
+++ b/xpcom/base/moz.build
@@ -95,16 +95,17 @@ SOURCES += [
 SOURCES['nsDebugImpl.cpp'].no_pgo = True
 
 UNIFIED_SOURCES += [
     'AvailableMemoryTracker.cpp',
     'ClearOnShutdown.cpp',
     'CycleCollectedJSRuntime.cpp',
     'Debug.cpp',
     'ErrorNames.cpp',
+    'HoldDropJSObjects.cpp',
     'nsConsoleMessage.cpp',
     'nsConsoleService.cpp',
     'nsCycleCollector.cpp',
     'nsDumpUtils.cpp',
     'nsErrorService.cpp',
     'nsGZFileWriter.cpp',
     'nsInterfaceRequestorAgg.cpp',
     'nsMemoryImpl.cpp',
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3907,57 +3907,16 @@ CycleCollectedJSRuntime::Get()
   }
   return nullptr;
 }
 
 
 namespace mozilla {
 namespace cyclecollector {
 
-void
-HoldJSObjectsImpl(void* aHolder, nsScriptObjectTracer* 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!");
-  MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
-             "The result of QIing a JS holder should be the same as ToSupports");
-
-  HoldJSObjectsImpl(aHolder, participant);
-}
-
-void
-DropJSObjectsImpl(void* 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);
-  MOZ_ASSERT(participant, "Failed to QI to nsXPCOMCycleCollectionParticipant!");
-  MOZ_ASSERT(participant->CheckForRightISupports(aHolder),
-             "The result of QIing a JS holder should be the same as ToSupports");
-#endif
-  DropJSObjectsImpl(static_cast<void*>(aHolder));
-}
-
 #ifdef DEBUG
 bool
 IsJSHolder(void* aHolder)
 {
   CycleCollectedJSRuntime* rt = CycleCollectedJSRuntime::Get();
   MOZ_ASSERT(rt, "Should have a CycleCollectedJSRuntime by now");
   return rt->IsJSHolder(aHolder);
 }