Bug 884061 - Part 3y: Use NS_DECL_THREADSAFE_ISUPPORTS in xpcom/, r=bsmedberg
authorJoshua Cranmer <Pidgeot18@gmail.com>
Thu, 18 Jul 2013 21:31:26 -0500
changeset 139623 b3533aba6520d7066c9063250e7350f5c7d6abfb
parent 139622 c027e7494a86ac75fd8843a93648f21d6582f6c9
child 139624 83c90466810a5c5f6f657c36c37a1d96243f4567
push id24998
push userryanvm@gmail.com
push dateWed, 24 Jul 2013 00:38:35 +0000
treeherdermozilla-central@2983ca6d4d1a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs884061
milestone25.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 884061 - Part 3y: Use NS_DECL_THREADSAFE_ISUPPORTS in xpcom/, r=bsmedberg
xpcom/base/MapsMemoryReporter.cpp
xpcom/base/nsConsoleMessage.cpp
xpcom/base/nsConsoleMessage.h
xpcom/base/nsConsoleService.cpp
xpcom/base/nsConsoleService.h
xpcom/base/nsExceptionService.cpp
xpcom/base/nsExceptionService.h
xpcom/base/nsIMemoryReporter.idl
xpcom/base/nsInterfaceRequestorAgg.cpp
xpcom/base/nsMemoryInfoDumper.cpp
xpcom/base/nsMemoryReporterManager.cpp
xpcom/base/nsMemoryReporterManager.h
xpcom/base/nsUUIDGenerator.cpp
xpcom/base/nsUUIDGenerator.h
xpcom/components/ModuleUtils.h
xpcom/components/nsComponentManager.cpp
xpcom/components/nsComponentManager.h
xpcom/ds/nsAtomService.cpp
xpcom/ds/nsAtomService.h
xpcom/ds/nsHashPropertyBag.cpp
xpcom/ds/nsHashPropertyBag.h
xpcom/ds/nsObserverService.cpp
xpcom/ds/nsObserverService.h
xpcom/ds/nsPersistentProperties.cpp
xpcom/ds/nsPersistentProperties.h
xpcom/ds/nsSupportsArray.cpp
xpcom/ds/nsSupportsArray.h
xpcom/ds/nsSupportsPrimitives.cpp
xpcom/ds/nsSupportsPrimitives.h
xpcom/glue/GenericFactory.cpp
xpcom/glue/GenericFactory.h
xpcom/glue/GenericModule.cpp
xpcom/glue/nsProxyRelease.h
xpcom/glue/nsThreadUtils.cpp
xpcom/glue/nsThreadUtils.h
xpcom/io/nsAppFileLocationProvider.cpp
xpcom/io/nsAppFileLocationProvider.h
xpcom/io/nsDirectoryService.cpp
xpcom/io/nsDirectoryService.h
xpcom/io/nsIOUtil.cpp
xpcom/io/nsIOUtil.h
xpcom/io/nsInputStreamTee.cpp
xpcom/io/nsLocalFileOS2.cpp
xpcom/io/nsLocalFileOS2.h
xpcom/io/nsLocalFileUnix.cpp
xpcom/io/nsLocalFileUnix.h
xpcom/io/nsLocalFileWin.cpp
xpcom/io/nsLocalFileWin.h
xpcom/io/nsMultiplexInputStream.cpp
xpcom/io/nsPipe3.cpp
xpcom/io/nsStorageStream.cpp
xpcom/io/nsStorageStream.h
xpcom/io/nsStreamUtils.cpp
xpcom/io/nsStringStream.cpp
xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h
xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
xpcom/reflect/xptinfo/src/xptiprivate.h
xpcom/tests/TestPipes.cpp
xpcom/tests/TestRacingServiceManager.cpp
xpcom/tests/TestThreadPool.cpp
xpcom/tests/TestThreadPoolListener.cpp
xpcom/tests/TestThreads.cpp
xpcom/tests/TestTimers.cpp
xpcom/threads/LazyIdleThread.cpp
xpcom/threads/LazyIdleThread.h
xpcom/threads/TimerThread.cpp
xpcom/threads/TimerThread.h
xpcom/threads/nsEnvironment.cpp
xpcom/threads/nsEnvironment.h
xpcom/threads/nsProcess.h
xpcom/threads/nsProcessCommon.cpp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
xpcom/threads/nsThreadPool.cpp
xpcom/threads/nsThreadPool.h
xpcom/threads/nsTimerImpl.cpp
xpcom/threads/nsTimerImpl.h
--- a/xpcom/base/MapsMemoryReporter.cpp
+++ b/xpcom/base/MapsMemoryReporter.cpp
@@ -111,17 +111,17 @@ struct CategoriesSeen {
 
 } // anonymous namespace
 
 class MapsReporter MOZ_FINAL : public nsIMemoryMultiReporter
 {
 public:
   MapsReporter();
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_IMETHOD GetName(nsACString &aName)
   {
       aName.AssignLiteral("smaps");
       return NS_OK;
   }
 
   NS_IMETHOD
@@ -153,17 +153,17 @@ private:
                nsISupports *aClosure,
                CategoriesSeen *aCategoriesSeen);
 
   bool mSearchedForLibxul;
   nsCString mLibxulDir;
   nsTHashtable<nsCStringHashKey> mMozillaLibraries;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(MapsReporter, nsIMemoryMultiReporter)
+NS_IMPL_ISUPPORTS1(MapsReporter, nsIMemoryMultiReporter)
 
 MapsReporter::MapsReporter()
   : mSearchedForLibxul(false)
 {
   const uint32_t len = ArrayLength(mozillaLibraries);
   mMozillaLibraries.Init(len);
   for (uint32_t i = 0; i < len; i++) {
     nsAutoCString str;
--- a/xpcom/base/nsConsoleMessage.cpp
+++ b/xpcom/base/nsConsoleMessage.cpp
@@ -6,17 +6,17 @@
 /*
  * Base implementation for console messages.
  */
 
 #include "nsConsoleMessage.h"
 #include "nsReadableUtils.h"
 #include "jsapi.h"
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage)
+NS_IMPL_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage)
 
 nsConsoleMessage::nsConsoleMessage()
     :  mTimeStamp(0),
        mMessage()
 {
 }
 
 nsConsoleMessage::nsConsoleMessage(const PRUnichar *message)
--- a/xpcom/base/nsConsoleMessage.h
+++ b/xpcom/base/nsConsoleMessage.h
@@ -11,17 +11,17 @@
 #include "nsIConsoleMessage.h"
 #include "nsString.h"
 
 class nsConsoleMessage MOZ_FINAL : public nsIConsoleMessage {
 public:
     nsConsoleMessage();
     nsConsoleMessage(const PRUnichar *message);
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSICONSOLEMESSAGE
 
 private:
     ~nsConsoleMessage() {}
 
     int64_t mTimeStamp;
     nsString mMessage;
 };
--- a/xpcom/base/nsConsoleService.cpp
+++ b/xpcom/base/nsConsoleService.cpp
@@ -26,18 +26,18 @@
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
 #endif
 
 using namespace mozilla;
 
-NS_IMPL_THREADSAFE_ADDREF(nsConsoleService)
-NS_IMPL_THREADSAFE_RELEASE(nsConsoleService)
+NS_IMPL_ADDREF(nsConsoleService)
+NS_IMPL_RELEASE(nsConsoleService)
 NS_IMPL_CLASSINFO(nsConsoleService, NULL, nsIClassInfo::THREADSAFE | nsIClassInfo::SINGLETON, NS_CONSOLESERVICE_CID)
 NS_IMPL_QUERY_INTERFACE1_CI(nsConsoleService, nsIConsoleService)
 NS_IMPL_CI_INTERFACE_GETTER1(nsConsoleService, nsIConsoleService)
 
 static bool sLoggingEnabled = true;
 static bool sLoggingBuffered = true;
 
 nsConsoleService::nsConsoleService()
--- a/xpcom/base/nsConsoleService.h
+++ b/xpcom/base/nsConsoleService.h
@@ -20,17 +20,17 @@
 #include "nsIConsoleService.h"
 
 class nsConsoleService MOZ_FINAL : public nsIConsoleService
 {
 public:
     nsConsoleService();
     nsresult Init();
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSICONSOLESERVICE
 
     void SetIsDelivering() {
         MOZ_ASSERT(NS_IsMainThread());
         MOZ_ASSERT(!mDeliveringMessage);
         mDeliveringMessage = true;
     }
 
--- a/xpcom/base/nsExceptionService.cpp
+++ b/xpcom/base/nsExceptionService.cpp
@@ -37,17 +37,17 @@ public:
   }
   uint32_t GetValue() { return mKey; }
 };
 
 /** Exception Manager definition **/
 class nsExceptionManager MOZ_FINAL : public nsIExceptionManager
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEXCEPTIONMANAGER
 
   nsExceptionManager(nsExceptionService *svc);
   /* additional members */
   nsCOMPtr<nsIException> mCurrentException;
   nsExceptionManager *mNextThread; // not ref-counted.
   nsExceptionService *mService; // not ref-counted
 #ifdef DEBUG
@@ -62,17 +62,17 @@ private:
 #ifdef DEBUG
 int32_t nsExceptionManager::totalInstances = 0;
 #endif
 
 // Note this object is single threaded - the service itself ensures
 // one per thread.
 // An exception if the destructor, which may be called on
 // the thread shutting down xpcom
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
+NS_IMPL_ISUPPORTS1(nsExceptionManager, nsIExceptionManager)
 
 nsExceptionManager::nsExceptionManager(nsExceptionService *svc) :
   mNextThread(nullptr),
   mService(svc)
 {
   /* member initializers and constructor code */
 #ifdef DEBUG
   PR_ATOMIC_INCREMENT(&totalInstances);
@@ -117,20 +117,20 @@ NS_IMETHODIMP nsExceptionManager::GetExc
 unsigned nsExceptionService::tlsIndex = BAD_TLS_INDEX;
 Mutex *nsExceptionService::sLock = nullptr;
 nsExceptionManager *nsExceptionService::firstThread = nullptr;
 
 #ifdef DEBUG
 int32_t nsExceptionService::totalInstances = 0;
 #endif
 
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsExceptionService,
-                              nsIExceptionService,
-                              nsIExceptionManager,
-                              nsIObserver)
+NS_IMPL_ISUPPORTS3(nsExceptionService,
+                   nsIExceptionService,
+                   nsIExceptionManager,
+                   nsIObserver)
 
 nsExceptionService::nsExceptionService()
   : mProviders(4, true) /* small, thread-safe hashtable */
 {
 #ifdef DEBUG
   if (PR_ATOMIC_INCREMENT(&totalInstances)!=1) {
     NS_ERROR("The nsExceptionService is a singleton!");
   }
--- a/xpcom/base/nsExceptionService.h
+++ b/xpcom/base/nsExceptionService.h
@@ -16,17 +16,17 @@
 #include "nsIObserver.h"
 
 class nsExceptionManager;
 
 /** Exception Service definition **/
 class nsExceptionService MOZ_FINAL : public nsIExceptionService, public nsIObserver
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEXCEPTIONSERVICE
   NS_DECL_NSIEXCEPTIONMANAGER
   NS_DECL_NSIOBSERVER
 
   nsExceptionService();
 
   /* additional members */
   nsresult DoGetExceptionFromProvider(nsresult errCode,
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -305,40 +305,40 @@ interface nsIMemoryReporterManager : nsI
 // The NS_*MEMORY_REPORTER_IMPLEMENT* macros are the deprecated short-cut way
 // of defining memory reporters.   You should instead subclass the
 // MemoryReporterBase class below.
 
 // Note that this defaults 'process' to "", which is usually what's desired.
 #define NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_classname, _path, _kind, _units, _amountFunction, _desc, _ts) \
     class MemoryReporter_##_classname MOZ_FINAL : public nsIMemoryReporter {                  \
     public:                                                                                   \
-      NS_DECL_ISUPPORTS                                                                       \
+      NS_DECL##_ts##ISUPPORTS                                                                 \
       NS_IMETHOD GetProcess(nsACString &process) { process.Truncate(); return NS_OK; }        \
       NS_IMETHOD GetPath(nsACString &memoryPath) { memoryPath.AssignLiteral(_path); return NS_OK; }  \
       NS_IMETHOD GetKind(int *kind) { *kind = _kind; return NS_OK; }                          \
       NS_IMETHOD GetUnits(int *units) { *units = _units; return NS_OK; }                      \
       NS_IMETHOD GetAmount(int64_t *amount) { *amount = _amountFunction(); return NS_OK; }    \
       NS_IMETHOD GetDescription(nsACString &desc) { desc.AssignLiteral(_desc); return NS_OK; }       \
     };                                                                                        \
-    NS_IMPL##_ts##ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
+    NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
 
 // The only difference between this and NS_MEMORY_REPORTER_IMPLEMENT_HELPER
 // is that the function used to implement GetAmount is fallible.
 #define NS_FALLIBLE_MEMORY_REPORTER_IMPLEMENT_HELPER(_classname, _path, _kind, _units, _amountFunction, _desc, _ts) \
     class MemoryReporter_##_classname MOZ_FINAL : public nsIMemoryReporter {                  \
     public:                                                                                   \
-      NS_DECL_ISUPPORTS                                                                       \
+      NS_DECL##_ts##ISUPPORTS                                                                 \
       NS_IMETHOD GetProcess(nsACString &process) { process.Truncate(); return NS_OK; }        \
       NS_IMETHOD GetPath(nsACString &memoryPath) { memoryPath.AssignLiteral(_path); return NS_OK; }  \
       NS_IMETHOD GetKind(int32_t *kind) { *kind = _kind; return NS_OK; }                      \
       NS_IMETHOD GetUnits(int32_t *units) { *units = _units; return NS_OK; }                  \
       NS_IMETHOD GetAmount(int64_t *amount) { return _amountFunction(amount); }               \
       NS_IMETHOD GetDescription(nsACString &desc) { desc.AssignLiteral(_desc); return NS_OK; }\
     };                                                                                        \
-    NS_IMPL##_ts##ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
+    NS_IMPL_ISUPPORTS1(MemoryReporter_##_classname, nsIMemoryReporter)
 
 #define NS_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
         NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _)
 #define NS_THREADSAFE_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
         NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _THREADSAFE_)
 #define NS_FALLIBLE_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
         NS_FALLIBLE_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _)
 #define NS_FALLIBLE_THREADSAFE_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
@@ -443,17 +443,17 @@ public:
     : mPath(aPath)
     , mKind(aKind)
     , mUnits(aUnits)
     , mDescription(aDescription)
   {}
 
   virtual ~MemoryReporterBase() {}
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_IMETHOD GetProcess(nsACString& aProcess)
   {
     aProcess.Truncate();
     return NS_OK;
   }
 
   NS_IMETHOD GetPath(nsACString& aPath)
--- a/xpcom/base/nsInterfaceRequestorAgg.cpp
+++ b/xpcom/base/nsInterfaceRequestorAgg.cpp
@@ -6,17 +6,18 @@
 #include "nsCOMPtr.h"
 #include "mozilla/Attributes.h"
 #include "nsThreadUtils.h"
 #include "nsProxyRelease.h"
 
 class nsInterfaceRequestorAgg MOZ_FINAL : public nsIInterfaceRequestor
 {
 public:
-  NS_DECL_ISUPPORTS
+  // XXX This needs to support threadsafe refcounting until we fix bug 243591.
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIINTERFACEREQUESTOR
 
   nsInterfaceRequestorAgg(nsIInterfaceRequestor *aFirst,
                           nsIInterfaceRequestor *aSecond,
                           nsIEventTarget *aConsumerTarget = nullptr)
     : mFirst(aFirst)
     , mSecond(aSecond)
     , mConsumerTarget(aConsumerTarget)
@@ -27,18 +28,17 @@ public:
   }
   ~nsInterfaceRequestorAgg();
 
 private:
   nsCOMPtr<nsIInterfaceRequestor> mFirst, mSecond;
   nsCOMPtr<nsIEventTarget> mConsumerTarget;
 };
 
-// XXX This needs to support threadsafe refcounting until we fix bug 243591.
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsInterfaceRequestorAgg, nsIInterfaceRequestor)
+NS_IMPL_ISUPPORTS1(nsInterfaceRequestorAgg, nsIInterfaceRequestor)
 
 NS_IMETHODIMP
 nsInterfaceRequestorAgg::GetInterface(const nsIID &aIID, void **aResult)
 {
   nsresult rv = NS_ERROR_NO_INTERFACE;
   if (mFirst)
     rv = mFirst->GetInterface(aIID, aResult);
   if (mSecond && NS_FAILED(rv))
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -186,17 +186,17 @@ public:
 
   /**
    * Called when you can read() from the fd without blocking.  Note that this
    * function is also called when you're at eof (read() returns 0 in this case).
    */
   virtual void OnFileCanReadWithoutBlocking(int aFd) = 0;
   virtual void OnFileCanWriteWithoutBlocking(int aFd) {};
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   /**
    * Initialize this object.  This should be called right after the object is
    * constructed.  (This would go in the constructor, except we interact with
    * XPCOM, which we can't do from a constructor because our refcount is 0 at
    * that point.)
    */
   void Init()
@@ -253,17 +253,17 @@ public:
     XRE_GetIOMessageLoop()->PostTask(
         FROM_HERE,
         NewRunnableMethod(this, &FdWatcher::StopWatching));
 
     return NS_OK;
   }
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(FdWatcher, nsIObserver);
+NS_IMPL_ISUPPORTS1(FdWatcher, nsIObserver);
 
 class SignalPipeWatcher : public FdWatcher
 {
 public:
   static void Create()
   {
     nsRefPtr<SignalPipeWatcher> sw = new SignalPipeWatcher();
     sw->Init();
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -677,17 +677,17 @@ NS_IMPL_ISUPPORTS1(DMDMultiReporter, nsI
 } // namespace mozilla
 
 #endif  // MOZ_DMD
 
 /**
  ** nsMemoryReporterManager implementation
  **/
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager)
+NS_IMPL_ISUPPORTS1(nsMemoryReporterManager, nsIMemoryReporterManager)
 
 NS_IMETHODIMP
 nsMemoryReporterManager::Init()
 {
 #if defined(HAVE_JEMALLOC_STATS) && defined(XP_LINUX)
     if (!jemalloc_stats)
         return NS_ERROR_FAILURE;
 #endif
@@ -1194,17 +1194,17 @@ nsMemoryReporterManager::MinimizeMemoryU
   NS_ADDREF(*result = runnable);
 
   return NS_DispatchToMainThread(runnable);
 }
 
 // Most memory reporters don't need thread safety, but some do.  Make them all
 // thread-safe just to be safe.  Memory reporters are created and destroyed
 // infrequently enough that the performance cost should be negligible.
-NS_IMPL_THREADSAFE_ISUPPORTS1(MemoryReporterBase, nsIMemoryReporter)
+NS_IMPL_ISUPPORTS1(MemoryReporterBase, nsIMemoryReporter)
 
 nsresult
 NS_RegisterMemoryReporter (nsIMemoryReporter *reporter)
 {
     nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
     if (mgr == nullptr)
         return NS_ERROR_FAILURE;
     return mgr->RegisterReporter(reporter);
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -11,17 +11,17 @@
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 using mozilla::Mutex;
 
 class nsMemoryReporterManager : public nsIMemoryReporterManager
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIMEMORYREPORTERMANAGER
 
   nsMemoryReporterManager();
   virtual ~nsMemoryReporterManager();
 
 private:
   nsresult RegisterReporterHelper(nsIMemoryReporter *reporter, bool aForce);
   nsresult RegisterMultiReporterHelper(nsIMemoryMultiReporter *reporter,
--- a/xpcom/base/nsUUIDGenerator.cpp
+++ b/xpcom/base/nsUUIDGenerator.cpp
@@ -14,17 +14,17 @@
 #endif
 
 #include "nsMemory.h"
 
 #include "nsUUIDGenerator.h"
 
 using namespace mozilla;
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsUUIDGenerator, nsIUUIDGenerator)
+NS_IMPL_ISUPPORTS1(nsUUIDGenerator, nsIUUIDGenerator)
 
 nsUUIDGenerator::nsUUIDGenerator()
     : mLock("nsUUIDGenerator.mLock")
 {
 }
 
 nsUUIDGenerator::~nsUUIDGenerator()
 {
--- a/xpcom/base/nsUUIDGenerator.h
+++ b/xpcom/base/nsUUIDGenerator.h
@@ -10,17 +10,17 @@
 #include "mozilla/Mutex.h"
 
 #include "nsIUUIDGenerator.h"
 
 class nsUUIDGenerator MOZ_FINAL : public nsIUUIDGenerator {
 public:
     nsUUIDGenerator();
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_DECL_NSIUUIDGENERATOR
 
     nsresult Init();
 
 private:
     ~nsUUIDGenerator();
 
--- a/xpcom/components/ModuleUtils.h
+++ b/xpcom/components/ModuleUtils.h
@@ -105,17 +105,17 @@ namespace mozilla {
 class GenericModule MOZ_FINAL : public nsIModule
 {
 public:
     GenericModule(const mozilla::Module* aData)
         : mData(aData)
     {
     }
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIMODULE
 
 private:
     const mozilla::Module* mData;
 };
 
 } // namespace mozilla
 
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -829,22 +829,22 @@ nsComponentManagerImpl::~nsComponentMana
     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Beginning destruction."));
 
     if (SHUTDOWN_COMPLETE != mStatus)
         Shutdown();
 
     PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Destroyed."));
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS5(nsComponentManagerImpl,
-                              nsIComponentManager,
-                              nsIServiceManager,
-                              nsIComponentRegistrar,
-                              nsISupportsWeakReference,
-                              nsIInterfaceRequestor)
+NS_IMPL_ISUPPORTS5(nsComponentManagerImpl,
+                   nsIComponentManager,
+                   nsIServiceManager,
+                   nsIComponentRegistrar,
+                   nsISupportsWeakReference,
+                   nsIInterfaceRequestor)
 
 
 nsresult
 nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result)
 {
     NS_WARNING("This isn't supported");
     // fall through to QI as anything QIable is a superset of what can be
     // got via the GetInterface()
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -121,17 +121,17 @@ typedef mozilla::BaseAutoUnlock<SafeMute
 class nsComponentManagerImpl MOZ_FINAL
     : public nsIComponentManager
     , public nsIServiceManager
     , public nsSupportsWeakReference
     , public nsIComponentRegistrar
     , public nsIInterfaceRequestor
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINTERFACEREQUESTOR
     NS_DECL_NSICOMPONENTMANAGER
     NS_DECL_NSICOMPONENTREGISTRAR
 
     static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
     nsresult RegistryLocationForFile(nsIFile* aFile,
                                      nsCString& aResult);
--- a/xpcom/ds/nsAtomService.cpp
+++ b/xpcom/ds/nsAtomService.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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 "nsAtomService.h"
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsAtomService, nsIAtomService)
+NS_IMPL_ISUPPORTS1(nsAtomService, nsIAtomService)
 
 nsAtomService::nsAtomService()
 {
 }
 
 nsresult
 nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult)
 {
--- a/xpcom/ds/nsAtomService.h
+++ b/xpcom/ds/nsAtomService.h
@@ -8,17 +8,17 @@
 
 #include "nsIAtomService.h"
 #include "mozilla/Attributes.h"
 
 class nsAtomService MOZ_FINAL : public nsIAtomService
 {
  public:
   nsAtomService();
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
     
   NS_DECL_NSIATOMSERVICE
 
  private:
   ~nsAtomService() {}
 };
 
 #endif
--- a/xpcom/ds/nsHashPropertyBag.cpp
+++ b/xpcom/ds/nsHashPropertyBag.cpp
@@ -31,18 +31,18 @@ NS_NewHashPropertyBag(nsIWritablePropert
     *_retval = hpb;
     return NS_OK;
 }
 
 /*
  * nsHashPropertyBag impl
  */
 
-NS_IMPL_THREADSAFE_ADDREF(nsHashPropertyBag)
-NS_IMPL_THREADSAFE_RELEASE(nsHashPropertyBag)
+NS_IMPL_ADDREF(nsHashPropertyBag)
+NS_IMPL_RELEASE(nsHashPropertyBag)
 NS_INTERFACE_MAP_BEGIN(nsHashPropertyBag)
   NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWritablePropertyBag)
   NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2)
   NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2)
 NS_INTERFACE_MAP_END
 
--- a/xpcom/ds/nsHashPropertyBag.h
+++ b/xpcom/ds/nsHashPropertyBag.h
@@ -18,17 +18,17 @@ class nsHashPropertyBag : public nsIWrit
                                , public nsIWritablePropertyBag2
 {
 public:
     nsHashPropertyBag() { }
     virtual ~nsHashPropertyBag() {}
 
     nsresult Init();
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_DECL_NSIPROPERTYBAG
 
     NS_DECL_NSIPROPERTYBAG2
 
     NS_DECL_NSIWRITABLEPROPERTYBAG
 
     NS_DECL_NSIWRITABLEPROPERTYBAG2
--- a/xpcom/ds/nsObserverService.cpp
+++ b/xpcom/ds/nsObserverService.cpp
@@ -43,17 +43,17 @@ GetObserverServiceLog()
 #else
   #define LOG(x)
 #endif /* PR_LOGGING */
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsObserverService Implementation
 
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsObserverService, nsIObserverService, nsObserverService)
+NS_IMPL_ISUPPORTS2(nsObserverService, nsIObserverService, nsObserverService)
 
 nsObserverService::nsObserverService() :
     mShuttingDown(false)
 {
     mObserverTopicTable.Init();
 }
 
 nsObserverService::~nsObserverService(void)
--- a/xpcom/ds/nsObserverService.h
+++ b/xpcom/ds/nsObserverService.h
@@ -16,17 +16,17 @@
     { 0xd07f5195, 0xe3d1, 0x11d2, { 0x8a, 0xcd, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
 
 class nsObserverService MOZ_FINAL : public nsIObserverService {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_OBSERVERSERVICE_CID)
 
   nsObserverService();
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVERSERVICE
   
   void Shutdown();
 
   static nsresult
   Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
   // Unmark any strongly held observers implemented in JS so the cycle
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -489,17 +489,17 @@ nsPersistentProperties::Create(nsISuppor
   nsresult rv = props->Init();
   if (NS_SUCCEEDED(rv))
     rv = props->QueryInterface(aIID, aResult);
 
   NS_RELEASE(props);
   return rv;
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties)
+NS_IMPL_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties)
 
 NS_IMETHODIMP
 nsPersistentProperties::Load(nsIInputStream *aIn)
 {
   nsresult rv = nsSimpleUnicharStreamFactory::GetInstance()->
     CreateInstanceFromUTF8Stream(aIn, getter_AddRefs(mIn));
 
   if (rv != NS_OK) {
--- a/xpcom/ds/nsPersistentProperties.h
+++ b/xpcom/ds/nsPersistentProperties.h
@@ -17,17 +17,17 @@
 
 
 class nsPersistentProperties MOZ_FINAL : public nsIPersistentProperties
 {
 public:
   nsPersistentProperties();
   nsresult Init();
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPROPERTIES
   NS_DECL_NSIPERSISTENTPROPERTIES
 
   static nsresult
   Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
 private:
   ~nsPersistentProperties();
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -169,17 +169,17 @@ nsSupportsArray::Create(nsISupports *aOu
   if (aOuter)
     return NS_ERROR_NO_AGGREGATION;
 
   nsCOMPtr<nsISupportsArray> it = new nsSupportsArray();
 
   return it->QueryInterface(aIID, aResult);
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable)
+NS_IMPL_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable)
 
 NS_IMETHODIMP
 nsSupportsArray::Read(nsIObjectInputStream *aStream)
 {
   nsresult rv;
 
   uint32_t newArraySize;
   rv = aStream->Read32(&newArraySize);
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -16,17 +16,17 @@ static const uint32_t kAutoArraySize = 8
 class nsSupportsArray MOZ_FINAL : public nsISupportsArray {
 public:
   nsSupportsArray(void);
   ~nsSupportsArray(void); // nonvirtual since we're not subclassed
 
   static nsresult
   Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_DECL_NSISERIALIZABLE
 
   // nsICollection methods:
   NS_IMETHOD Count(uint32_t *result) { *result = mCount; return NS_OK; }
   NS_IMETHOD GetElementAt(uint32_t aIndex, nsISupports* *result);
   NS_IMETHOD QueryElementAt(uint32_t aIndex, const nsIID & aIID, void * *aResult) {
     if (aIndex < mCount) {
--- a/xpcom/ds/nsSupportsPrimitives.cpp
+++ b/xpcom/ds/nsSupportsPrimitives.cpp
@@ -141,18 +141,18 @@ NS_IMETHODIMP nsSupportsStringImpl::ToSt
 NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData)
 {
     mData = aData;
     return NS_OK;
 }
 
 /***************************************************************************/
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
-                              nsISupportsPrimitive)
+NS_IMPL_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool,
+                   nsISupportsPrimitive)
 
 nsSupportsPRBoolImpl::nsSupportsPRBoolImpl()
     : mData(false)
 {
 }
 
 NS_IMETHODIMP nsSupportsPRBoolImpl::GetType(uint16_t *aType)
 {
@@ -678,18 +678,18 @@ NS_IMETHODIMP nsSupportsDoubleImpl::ToSt
                                 (strlen(buf)+1)*sizeof(char));
     *_retval = result;
     return  result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
-                              nsISupportsPrimitive)
+NS_IMPL_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid,
+                   nsISupportsPrimitive)
 
 nsSupportsVoidImpl::nsSupportsVoidImpl()
     : mData(nullptr)
 {
 }
 
 NS_IMETHODIMP nsSupportsVoidImpl::GetType(uint16_t *aType)
 {
@@ -720,19 +720,19 @@ NS_IMETHODIMP nsSupportsVoidImpl::ToStri
     char* result = (char*) nsMemory::Clone(str, sizeof(str));
     *_retval = result;
     return  result ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }  
 
 /***************************************************************************/
 
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl,
-                              nsISupportsInterfacePointer,
-                              nsISupportsPrimitive)
+NS_IMPL_ISUPPORTS2(nsSupportsInterfacePointerImpl,
+                   nsISupportsInterfacePointer,
+                   nsISupportsPrimitive)
 
 nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl()
     : mIID(nullptr)
 {
 }
 
 nsSupportsInterfacePointerImpl::~nsSupportsInterfacePointerImpl()
 {
--- a/xpcom/ds/nsSupportsPrimitives.h
+++ b/xpcom/ds/nsSupportsPrimitives.h
@@ -62,17 +62,17 @@ private:
     nsString mData;
 };
 
 /***************************************************************************/
 
 class nsSupportsPRBoolImpl MOZ_FINAL : public nsISupportsPRBool
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISUPPORTSPRIMITIVE
     NS_DECL_NSISUPPORTSPRBOOL
 
     nsSupportsPRBoolImpl();
 
 private:
     ~nsSupportsPRBoolImpl() {}
 
@@ -266,34 +266,34 @@ private:
     double mData;
 };
 
 /***************************************************************************/
 
 class nsSupportsVoidImpl MOZ_FINAL : public nsISupportsVoid
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISUPPORTSPRIMITIVE
     NS_DECL_NSISUPPORTSVOID
 
     nsSupportsVoidImpl();
 
 private:
     ~nsSupportsVoidImpl() {}
 
     void* mData;
 };
 
 /***************************************************************************/
 
 class nsSupportsInterfacePointerImpl MOZ_FINAL : public nsISupportsInterfacePointer
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISUPPORTSPRIMITIVE
     NS_DECL_NSISUPPORTSINTERFACEPOINTER
 
     nsSupportsInterfacePointerImpl();
 
 private:
     ~nsSupportsInterfacePointerImpl();
 
--- a/xpcom/glue/GenericFactory.cpp
+++ b/xpcom/glue/GenericFactory.cpp
@@ -2,17 +2,17 @@
 /* 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/GenericFactory.h"
 
 namespace mozilla {
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(GenericFactory, nsIFactory)
+NS_IMPL_ISUPPORTS1(GenericFactory, nsIFactory)
 
 NS_IMETHODIMP
 GenericFactory::CreateInstance(nsISupports* aOuter, REFNSIID aIID,
 			       void** aResult)
 {
   return mCtor(aOuter, aIID, aResult);
 }
 
--- a/xpcom/glue/GenericFactory.h
+++ b/xpcom/glue/GenericFactory.h
@@ -17,17 +17,17 @@ namespace mozilla {
  * This class is intended for use by the component manager and the generic
  * module.
  */
 class GenericFactory MOZ_FINAL : public nsIFactory
 {
 public:
   typedef Module::ConstructorProcPtr ConstructorProcPtr;
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIFACTORY
 
   GenericFactory(ConstructorProcPtr ctor)
     : mCtor(ctor)
   {
     NS_ASSERTION(mCtor, "GenericFactory with no constructor");
   }
 
--- a/xpcom/glue/GenericModule.cpp
+++ b/xpcom/glue/GenericModule.cpp
@@ -10,17 +10,17 @@
 #include "nsIComponentManager.h"
 #include "nsIComponentRegistrar.h"
 #include "nsServiceManagerUtils.h"
 #include "nsXPCOMCID.h"
 #include "nsStringAPI.h"
 
 namespace mozilla {
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(GenericModule, nsIModule)
+NS_IMPL_ISUPPORTS1(GenericModule, nsIModule)
 
 NS_IMETHODIMP
 GenericModule::GetClassObject(nsIComponentManager* aCompMgr,
                               const nsCID& aCID,
                               const nsIID& aIID,
                               void** aResult)
 {
   for (const Module::CIDEntry* e = mData->mCIDs; e->cid; ++e) {
--- a/xpcom/glue/nsProxyRelease.h
+++ b/xpcom/glue/nsProxyRelease.h
@@ -137,41 +137,32 @@ public:
       NS_ERROR("Can't dereference nsMainThreadPtrHolder off main thread");
       MOZ_CRASH();
     }
     return mRawPtr;
   }
 
   bool operator==(const nsMainThreadPtrHolder<T>& aOther) const { return mRawPtr == aOther.mRawPtr; }
 
-  NS_IMETHOD_(nsrefcnt) Release();
-  NS_IMETHOD_(nsrefcnt) AddRef();
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsMainThreadPtrHolder<T>)
 
 private:
-  // This class is threadsafe and reference-counted.
-  nsAutoRefCnt mRefCnt;
-
   // Our wrapped pointer.
   T* mRawPtr;
 
   // Whether to strictly enforce thread invariants in this class.
   bool mStrict;
 
   // Copy constructor and operator= not implemented. Once constructed, the
   // holder is immutable.
   T& operator=(nsMainThreadPtrHolder& other);
   nsMainThreadPtrHolder(const nsMainThreadPtrHolder& other);
 };
 
 template<class T>
-NS_IMPL_THREADSAFE_ADDREF(nsMainThreadPtrHolder<T>)
-template<class T>
-NS_IMPL_THREADSAFE_RELEASE(nsMainThreadPtrHolder<T>)
-
-template<class T>
 class nsMainThreadPtrHandle
 {
   nsRefPtr<nsMainThreadPtrHolder<T> > mPtr;
 
   public:
   nsMainThreadPtrHandle() : mPtr(NULL) {}
   nsMainThreadPtrHandle(nsMainThreadPtrHolder<T> *aHolder) : mPtr(aHolder) {}
   nsMainThreadPtrHandle(const nsMainThreadPtrHandle& aOther) : mPtr(aOther.mPtr) {}
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -23,26 +23,26 @@
 #include <sys/resource.h>
 #endif
 
 #include <pratom.h>
 #include <prthread.h>
 
 #ifndef XPCOM_GLUE_AVOID_NSPR
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsRunnable, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsRunnable, nsIRunnable)
 
 NS_IMETHODIMP
 nsRunnable::Run()
 {
   // Do nothing
   return NS_OK;
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsCancelableRunnable, nsICancelableRunnable,
+NS_IMPL_ISUPPORTS2(nsCancelableRunnable, nsICancelableRunnable,
                               nsIRunnable)
 
 NS_IMETHODIMP
 nsCancelableRunnable::Run()
 {
   // Do nothing
   return NS_OK;
 }
@@ -242,24 +242,24 @@ NS_ProcessNextEvent(nsIThread *thread, b
 
 namespace {
 
 class nsNameThreadRunnable MOZ_FINAL : public nsIRunnable
 {
 public:
   nsNameThreadRunnable(const nsACString &name) : mName(name) { }
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
 
 protected:
   const nsCString mName;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsNameThreadRunnable, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsNameThreadRunnable, nsIRunnable)
 
 NS_IMETHODIMP
 nsNameThreadRunnable::Run()
 {
   PR_SetCurrentThreadName(mName.BeginReading());
   return NS_OK;
 }
 
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -231,32 +231,32 @@ extern NS_COM_GLUE nsIThread *NS_GetCurr
 
 #undef  IMETHOD_VISIBILITY
 #define IMETHOD_VISIBILITY NS_COM_GLUE
 
 // This class is designed to be subclassed.
 class NS_COM_GLUE nsRunnable : public nsIRunnable
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
 
   nsRunnable() {
   }
 
 protected:
   virtual ~nsRunnable() {
   }
 };
 
 // This class is designed to be subclassed.
 class NS_COM_GLUE nsCancelableRunnable : public nsICancelableRunnable
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSICANCELABLERUNNABLE
 
   nsCancelableRunnable() {
   }
 
 protected:
   virtual ~nsCancelableRunnable() {
--- a/xpcom/io/nsAppFileLocationProvider.cpp
+++ b/xpcom/io/nsAppFileLocationProvider.cpp
@@ -73,17 +73,17 @@
 nsAppFileLocationProvider::nsAppFileLocationProvider()
 {
 }
 
 //*****************************************************************************
 // nsAppFileLocationProvider::nsISupports
 //*****************************************************************************
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsAppFileLocationProvider, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
+NS_IMPL_ISUPPORTS2(nsAppFileLocationProvider, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
 
 //*****************************************************************************
 // nsAppFileLocationProvider::nsIDirectoryServiceProvider
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsAppFileLocationProvider::GetFile(const char *prop, bool *persistent, nsIFile **_retval)
 {
--- a/xpcom/io/nsAppFileLocationProvider.h
+++ b/xpcom/io/nsAppFileLocationProvider.h
@@ -13,17 +13,17 @@ class nsIFile;
 // class nsAppFileLocationProvider
 //*****************************************************************************   
 
 class nsAppFileLocationProvider MOZ_FINAL : public nsIDirectoryServiceProvider2
 {
 public:
                         nsAppFileLocationProvider();
 
-   NS_DECL_ISUPPORTS
+   NS_DECL_THREADSAFE_ISUPPORTS
    NS_DECL_NSIDIRECTORYSERVICEPROVIDER
    NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
 
 private:
                         ~nsAppFileLocationProvider() {}
 
 protected:
    NS_METHOD            CloneMozBinDirectory(nsIFile **aLocalFile);
--- a/xpcom/io/nsDirectoryService.cpp
+++ b/xpcom/io/nsDirectoryService.cpp
@@ -283,17 +283,17 @@ nsDirectoryService::ReleaseValues(nsHash
     NS_IF_RELEASE(value);
     return true;
 }
 
 nsDirectoryService::~nsDirectoryService()
 {
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
+NS_IMPL_ISUPPORTS4(nsDirectoryService, nsIProperties, nsIDirectoryService, nsIDirectoryServiceProvider, nsIDirectoryServiceProvider2)
 
 
 NS_IMETHODIMP
 nsDirectoryService::Undefine(const char* prop)
 {
     NS_ENSURE_ARG(prop);
 
     nsCStringKey key(prop);
--- a/xpcom/io/nsDirectoryService.h
+++ b/xpcom/io/nsDirectoryService.h
@@ -19,17 +19,17 @@
 
 class nsDirectoryService MOZ_FINAL : public nsIDirectoryService,
                                      public nsIProperties,
                                      public nsIDirectoryServiceProvider2
 {
   public:
 
   // nsISupports interface
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   NS_DECL_NSIPROPERTIES  
 
   NS_DECL_NSIDIRECTORYSERVICE
 
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER
   
   NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
--- a/xpcom/io/nsIOUtil.cpp
+++ b/xpcom/io/nsIOUtil.cpp
@@ -3,17 +3,17 @@
  * 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 "nsIOUtil.h"
 #include "nsIInputStream.h"
 #include "nsIOutputStream.h"
 #include "nsStreamUtils.h"
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsIOUtil, nsIIOUtil)
+NS_IMPL_ISUPPORTS1(nsIOUtil, nsIIOUtil)
 
 NS_IMETHODIMP
 nsIOUtil::InputStreamIsBuffered(nsIInputStream* aStream, bool* _retval)
 {
   NS_ENSURE_ARG_POINTER(aStream);
   *_retval = NS_InputStreamIsBuffered(aStream);
   return NS_OK;
 }
--- a/xpcom/io/nsIOUtil.h
+++ b/xpcom/io/nsIOUtil.h
@@ -12,13 +12,13 @@
 
 
 #include "nsIIOUtil.h"
 #include "mozilla/Attributes.h"
 
 class nsIOUtil MOZ_FINAL : public nsIIOUtil
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIIOUTIL
 };
 
 #endif /* nsIOUtil_h__ */
--- a/xpcom/io/nsInputStreamTee.cpp
+++ b/xpcom/io/nsInputStreamTee.cpp
@@ -30,17 +30,17 @@ GetTeeLog()
 #define LOG(args) PR_LOG(GetTeeLog(), PR_LOG_DEBUG, args)
 #else
 #define LOG(args)
 #endif
 
 class nsInputStreamTee MOZ_FINAL : public nsIInputStreamTee
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIINPUTSTREAMTEE
 
     nsInputStreamTee();
     bool SinkIsValid();
     void InvalidateSink();
 
 private:
@@ -200,19 +200,19 @@ nsInputStreamTee::WriteSegmentFun(nsIInp
         NS_ASSERTION((NS_FAILED(rv) ? (*writeCount == 0) : true),
                 "writer returned an error with non-zero writeCount");
         return rv;
     }
 
     return tee->TeeSegment(fromSegment, *writeCount);
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsInputStreamTee,
-                              nsIInputStreamTee,
-                              nsIInputStream)
+NS_IMPL_ISUPPORTS2(nsInputStreamTee,
+                   nsIInputStreamTee,
+                   nsIInputStream)
 NS_IMETHODIMP
 nsInputStreamTee::Close()
 {
     NS_ENSURE_TRUE(mSource, NS_ERROR_NOT_INITIALIZED);
     nsresult rv = mSource->Close();
     mSource = 0;
     mSink = 0;
     return rv;
--- a/xpcom/io/nsLocalFileOS2.cpp
+++ b/xpcom/io/nsLocalFileOS2.cpp
@@ -575,21 +575,21 @@ nsLocalFile::nsLocalFileConstructor(nsIS
     return NS_OK;
 }
 
 
 //-----------------------------------------------------------------------------
 // nsLocalFile::nsISupports
 //-----------------------------------------------------------------------------
 
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
-                              nsILocalFile,
-                              nsIFile,
-                              nsILocalFileOS2,
-                              nsIHashable)
+NS_IMPL_ISUPPORTS4(nsLocalFile,
+                   nsILocalFile,
+                   nsIFile,
+                   nsILocalFileOS2,
+                   nsIHashable)
 
 
 //-----------------------------------------------------------------------------
 // nsLocalFile <private>
 //-----------------------------------------------------------------------------
 
 nsLocalFile::nsLocalFile(const nsLocalFile& other)
   : mDirty(true)
--- a/xpcom/io/nsLocalFileOS2.h
+++ b/xpcom/io/nsLocalFileOS2.h
@@ -39,17 +39,17 @@ class nsLocalFile : public nsILocalFileO
 public:
     NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
 
     nsLocalFile();
 
     static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
     // nsISupports interface
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     // nsIFile interface
     NS_DECL_NSIFILE
 
     // nsILocalFile interface
     NS_DECL_NSILOCALFILE
 
     // nsILocalFileOS2 interface
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -234,26 +234,26 @@ nsLocalFile::nsLocalFile()
 }
 
 nsLocalFile::nsLocalFile(const nsLocalFile& other)
   : mPath(other.mPath)
 {
 }
 
 #ifdef MOZ_WIDGET_COCOA
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
-                              nsILocalFileMac,
-                              nsILocalFile,
-                              nsIFile,
-                              nsIHashable)
+NS_IMPL_ISUPPORTS4(nsLocalFile,
+                   nsILocalFileMac,
+                   nsILocalFile,
+                   nsIFile,
+                   nsIHashable)
 #else
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsLocalFile,
-                              nsILocalFile,
-                              nsIFile,
-                              nsIHashable)
+NS_IMPL_ISUPPORTS3(nsLocalFile,
+                   nsILocalFile,
+                   nsIFile,
+                   nsIHashable)
 #endif
 
 nsresult
 nsLocalFile::nsLocalFileConstructor(nsISupports *outer, 
                                     const nsIID &aIID,
                                     void **aInstancePtr)
 {
     NS_ENSURE_ARG_POINTER(aInstancePtr);
--- a/xpcom/io/nsLocalFileUnix.h
+++ b/xpcom/io/nsLocalFileUnix.h
@@ -86,17 +86,17 @@ class nsLocalFile MOZ_FINAL :
 {
 public:
     NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
     
     nsLocalFile();
 
     static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIFILE
     NS_DECL_NSILOCALFILE
 #ifdef MOZ_WIDGET_COCOA
     NS_DECL_NSILOCALFILEMAC
 #endif
     NS_DECL_NSIHASHABLE
 
 public:
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -974,21 +974,21 @@ nsLocalFile::nsLocalFileConstructor(nsIS
     return NS_OK;
 }
 
 
 //-----------------------------------------------------------------------------
 // nsLocalFile::nsISupports
 //-----------------------------------------------------------------------------
 
-NS_IMPL_THREADSAFE_ISUPPORTS4(nsLocalFile,
-                              nsILocalFile,
-                              nsIFile,
-                              nsILocalFileWin,
-                              nsIHashable)
+NS_IMPL_ISUPPORTS4(nsLocalFile,
+                   nsILocalFile,
+                   nsIFile,
+                   nsILocalFileWin,
+                   nsIHashable)
 
 
 //-----------------------------------------------------------------------------
 // nsLocalFile <private>
 //-----------------------------------------------------------------------------
 
 nsLocalFile::nsLocalFile(const nsLocalFile& other)
   : mDirty(true)
--- a/xpcom/io/nsLocalFileWin.h
+++ b/xpcom/io/nsLocalFileWin.h
@@ -29,17 +29,17 @@ class nsLocalFile MOZ_FINAL : public nsI
 public:
     NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
     
     nsLocalFile();
 
     static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
     // nsISupports interface
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     
     // nsIFile interface
     NS_DECL_NSIFILE
     
     // nsILocalFile interface
     NS_DECL_NSILOCALFILE
 
     // nsILocalFileWin interface
--- a/xpcom/io/nsMultiplexInputStream.cpp
+++ b/xpcom/io/nsMultiplexInputStream.cpp
@@ -28,17 +28,17 @@ using mozilla::DeprecatedAbs;
 
 class nsMultiplexInputStream MOZ_FINAL : public nsIMultiplexInputStream,
                                          public nsISeekableStream,
                                          public nsIIPCSerializableInputStream
 {
 public:
     nsMultiplexInputStream();
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSIMULTIPLEXINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
     NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
 
 private:
     ~nsMultiplexInputStream() {}
 
@@ -55,18 +55,18 @@ private:
                                uint32_t aCount, uint32_t *aWriteCount);
     
     nsTArray<nsCOMPtr<nsIInputStream> > mStreams;
     uint32_t mCurrentStream;
     bool mStartedReadingCurrent;
     nsresult mStatus;
 };
 
-NS_IMPL_THREADSAFE_ADDREF(nsMultiplexInputStream)
-NS_IMPL_THREADSAFE_RELEASE(nsMultiplexInputStream)
+NS_IMPL_ADDREF(nsMultiplexInputStream)
+NS_IMPL_RELEASE(nsMultiplexInputStream)
 
 NS_IMPL_CLASSINFO(nsMultiplexInputStream, NULL, nsIClassInfo::THREADSAFE,
                   NS_MULTIPLEXINPUTSTREAM_CID)
 
 NS_IMPL_QUERY_INTERFACE4_CI(nsMultiplexInputStream,
                             nsIMultiplexInputStream,
                             nsIInputStream,
                             nsISeekableStream,
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -123,17 +123,17 @@ public:
     // be notified, to wake up a blocked reader if any.
     bool     OnInputReadable(uint32_t bytesWritten, nsPipeEvents &);
     bool     OnInputException(nsresult, nsPipeEvents &);
 
 private:
     nsPipe                        *mPipe;
 
     // separate refcnt so that we know when to close the consumer
-    nsrefcnt                       mReaderRefCnt;
+    mozilla::ThreadSafeAutoRefCnt  mReaderRefCnt;
     int64_t                        mLogicalOffset;
     bool                           mBlocking;
 
     // these variables can only be accessed while inside the pipe's monitor
     bool                           mBlocked;
     uint32_t                       mAvailable;
     nsCOMPtr<nsIInputStreamCallback> mCallback;
     uint32_t                       mCallbackFlags;
@@ -177,17 +177,17 @@ public:
     // be notified, to wake up a blocked writer if any.
     bool     OnOutputWritable(nsPipeEvents &);
     bool     OnOutputException(nsresult, nsPipeEvents &);
 
 private:
     nsPipe                         *mPipe;
 
     // separate refcnt so that we know when to close the producer
-    nsrefcnt                        mWriterRefCnt;
+    mozilla::ThreadSafeAutoRefCnt   mWriterRefCnt;
     int64_t                         mLogicalOffset;
     bool                            mBlocking;
 
     // these variables can only be accessed while inside the pipe's monitor
     bool                            mBlocked;
     bool                            mWritable;
     nsCOMPtr<nsIOutputStreamCallback> mCallback;
     uint32_t                        mCallbackFlags;
@@ -196,17 +196,17 @@ private:
 //-----------------------------------------------------------------------------
 
 class nsPipe MOZ_FINAL : public nsIPipe
 {
 public:
     friend class nsPipeInputStream;
     friend class nsPipeOutputStream;
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIPIPE
 
     // nsPipe methods:
     nsPipe();
 
 private:
     ~nsPipe();
 
@@ -306,17 +306,17 @@ nsPipe::nsPipe()
     , mInited(false)
 {
 }
 
 nsPipe::~nsPipe()
 {
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsPipe, nsIPipe)
+NS_IMPL_ISUPPORTS1(nsPipe, nsIPipe)
 
 NS_IMETHODIMP
 nsPipe::Init(bool nonBlockingIn,
              bool nonBlockingOut,
              uint32_t segmentSize,
              uint32_t segmentCount,
              nsIMemory *segmentAlloc)
 {
@@ -675,24 +675,24 @@ nsPipeInputStream::OnInputException(nsre
         result = true;
 
     return result;
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeInputStream::AddRef(void)
 {
-    NS_AtomicIncrementRefcnt(mReaderRefCnt);
+    ++mReaderRefCnt;
     return mPipe->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeInputStream::Release(void)
 {
-    if (NS_AtomicDecrementRefcnt(mReaderRefCnt) == 0)
+    if (--mReaderRefCnt == 0)
         Close();
     return mPipe->Release();
 }
 
 NS_IMETHODIMP
 nsPipeInputStream::CloseWithStatus(nsresult reason)
 {
     LOG(("III CloseWithStatus [this=%x reason=%x]\n", this, reason));
@@ -1030,24 +1030,24 @@ nsPipeOutputStream::OnOutputException(ns
 
     return result;
 }
 
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeOutputStream::AddRef()
 {
-    NS_AtomicIncrementRefcnt(mWriterRefCnt);
+    ++mWriterRefCnt;
     return mPipe->AddRef();
 }
 
 NS_IMETHODIMP_(nsrefcnt)
 nsPipeOutputStream::Release()
 {
-    if (NS_AtomicDecrementRefcnt(mWriterRefCnt) == 0)
+    if (--mWriterRefCnt == 0)
         Close();
     return mPipe->Release();
 }
 
 NS_IMETHODIMP
 nsPipeOutputStream::CloseWithStatus(nsresult reason)
 {
     LOG(("OOO CloseWithStatus [this=%x reason=%x]\n", this, reason));
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -54,19 +54,19 @@ nsStorageStream::nsStorageStream()
     LOG(("Creating nsStorageStream [%p].\n", this));
 }
 
 nsStorageStream::~nsStorageStream()
 {
     delete mSegmentedBuffer;
 }
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsStorageStream,
-                              nsIStorageStream,
-                              nsIOutputStream)
+NS_IMPL_ISUPPORTS2(nsStorageStream,
+                   nsIStorageStream,
+                   nsIOutputStream)
 
 NS_IMETHODIMP
 nsStorageStream::Init(uint32_t segmentSize, uint32_t maxSize,
                       nsIMemory *segmentAllocator)
 {
     mSegmentedBuffer = new nsSegmentedBuffer();
     if (!mSegmentedBuffer)
         return NS_ERROR_OUT_OF_MEMORY;
@@ -315,17 +315,17 @@ public:
         : mStorageStream(aStorageStream), mReadCursor(0),
           mSegmentEnd(0), mSegmentNum(0),
           mSegmentSize(aSegmentSize), mLogicalCursor(0),
           mStatus(NS_OK)
 	{
         NS_ADDREF(mStorageStream);
 	}
 
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
 
 private:
     ~nsStorageInputStream()
     {
         NS_IF_RELEASE(mStorageStream);
     }
@@ -343,19 +343,19 @@ private:
     uint32_t         mSegmentSize;   // All segments, except the last, are of this size
     uint32_t         mLogicalCursor; // Logical offset into stream
     nsresult         mStatus;
 
     uint32_t SegNum(uint32_t aPosition)    {return aPosition >> mStorageStream->mSegmentSizeLog2;}
     uint32_t SegOffset(uint32_t aPosition) {return aPosition & (mSegmentSize - 1);}
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsStorageInputStream,
-                              nsIInputStream,
-                              nsISeekableStream)
+NS_IMPL_ISUPPORTS2(nsStorageInputStream,
+                   nsIInputStream,
+                   nsISeekableStream)
 
 NS_IMETHODIMP
 nsStorageStream::NewInputStream(int32_t aStartingOffset, nsIInputStream* *aInputStream)
 {
     NS_ENSURE_TRUE(mSegmentedBuffer, NS_ERROR_NOT_INITIALIZED);
 
     nsStorageInputStream *inputStream = new nsStorageInputStream(this, mSegmentSize);
     if (!inputStream)
--- a/xpcom/io/nsStorageStream.h
+++ b/xpcom/io/nsStorageStream.h
@@ -32,17 +32,17 @@
 class nsSegmentedBuffer;
 
 class nsStorageStream MOZ_FINAL : public nsIStorageStream,
                                   public nsIOutputStream
 {
 public:
     nsStorageStream();
     
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSISTORAGESTREAM
     NS_DECL_NSIOUTPUTSTREAM
 
     friend class nsStorageInputStream;
 
 private:
     ~nsStorageStream();
 
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -17,17 +17,17 @@
 using namespace mozilla;
 
 //-----------------------------------------------------------------------------
 
 class nsInputStreamReadyEvent MOZ_FINAL : public nsIRunnable
                                         , public nsIInputStreamCallback
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     nsInputStreamReadyEvent(nsIInputStreamCallback *callback,
                             nsIEventTarget *target)
         : mCallback(callback)
         , mTarget(target)
     {
     }
 
@@ -86,26 +86,26 @@ public:
     }
 
 private:
     nsCOMPtr<nsIAsyncInputStream>    mStream;
     nsCOMPtr<nsIInputStreamCallback> mCallback;
     nsCOMPtr<nsIEventTarget>         mTarget;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsInputStreamReadyEvent, nsIRunnable,
-                              nsIInputStreamCallback)
+NS_IMPL_ISUPPORTS2(nsInputStreamReadyEvent, nsIRunnable,
+                   nsIInputStreamCallback)
 
 //-----------------------------------------------------------------------------
 
 class nsOutputStreamReadyEvent MOZ_FINAL : public nsIRunnable
                                          , public nsIOutputStreamCallback
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     nsOutputStreamReadyEvent(nsIOutputStreamCallback *callback,
                              nsIEventTarget *target)
         : mCallback(callback)
         , mTarget(target)
     {
     }
 
@@ -164,18 +164,18 @@ public:
     }
 
 private:
     nsCOMPtr<nsIAsyncOutputStream>    mStream;
     nsCOMPtr<nsIOutputStreamCallback> mCallback;
     nsCOMPtr<nsIEventTarget>          mTarget;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsOutputStreamReadyEvent, nsIRunnable,
-                              nsIOutputStreamCallback)
+NS_IMPL_ISUPPORTS2(nsOutputStreamReadyEvent, nsIRunnable,
+                   nsIOutputStreamCallback)
 
 //-----------------------------------------------------------------------------
 
 already_AddRefed<nsIInputStreamCallback>
 NS_NewInputStreamReadyEvent(nsIInputStreamCallback *callback,
                             nsIEventTarget *target)
 {
     NS_ASSERTION(callback, "null callback");
@@ -200,17 +200,17 @@ NS_NewOutputStreamReadyEvent(nsIOutputSt
 // NS_AsyncCopy implementation
 
 // abstract stream copier...
 class nsAStreamCopier : public nsIInputStreamCallback
                       , public nsIOutputStreamCallback
                       , public nsIRunnable
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     nsAStreamCopier()
         : mLock("nsAStreamCopier.mLock")
         , mCallback(nullptr)
         , mProgressCallback(nullptr)
         , mClosure(nullptr)
         , mChunkSize(0)
         , mEventInProcess(false)
@@ -454,20 +454,20 @@ protected:
     bool                           mEventInProcess;
     bool                           mEventIsPending;
     bool                           mCloseSource;
     bool                           mCloseSink;
     bool                           mCanceled;
     nsresult                       mCancelStatus;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS3(nsAStreamCopier,
-                              nsIInputStreamCallback,
-                              nsIOutputStreamCallback,
-                              nsIRunnable)
+NS_IMPL_ISUPPORTS3(nsAStreamCopier,
+                   nsIInputStreamCallback,
+                   nsIOutputStreamCallback,
+                   nsIRunnable)
 
 class nsStreamCopierIB MOZ_FINAL : public nsAStreamCopier
 {
 public:
     nsStreamCopierIB() : nsAStreamCopier() {}
     virtual ~nsStreamCopierIB() {}
 
     struct ReadSegmentsState {
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -30,17 +30,17 @@ using namespace mozilla::ipc;
 //-----------------------------------------------------------------------------
 
 class nsStringInputStream MOZ_FINAL : public nsIStringInputStream
                                     , public nsISeekableStream
                                     , public nsISupportsCString
                                     , public nsIIPCSerializableInputStream
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
     NS_DECL_NSISTRINGINPUTSTREAM
     NS_DECL_NSISEEKABLESTREAM
     NS_DECL_NSISUPPORTSPRIMITIVE
     NS_DECL_NSISUPPORTSCSTRING
     NS_DECL_NSIIPCSERIALIZABLEINPUTSTREAM
 
     nsStringInputStream()
@@ -73,18 +73,18 @@ private:
     }
 
     nsDependentCSubstring mData;
     uint32_t mOffset;
 };
 
 // This class needs to support threadsafe refcounting since people often
 // allocate a string stream, and then read it from a background thread.
-NS_IMPL_THREADSAFE_ADDREF(nsStringInputStream)
-NS_IMPL_THREADSAFE_RELEASE(nsStringInputStream)
+NS_IMPL_ADDREF(nsStringInputStream)
+NS_IMPL_RELEASE(nsStringInputStream)
 
 NS_IMPL_CLASSINFO(nsStringInputStream, NULL, nsIClassInfo::THREADSAFE,
                   NS_STRINGINPUTSTREAM_CID)
 NS_IMPL_QUERY_INTERFACE5_CI(nsStringInputStream,
                             nsIStringInputStream,
                             nsIInputStream,
                             nsISupportsCString,
                             nsISeekableStream,
--- a/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h
+++ b/xpcom/reflect/xptinfo/public/XPTInterfaceInfoManager.h
@@ -21,17 +21,17 @@ class xptiInterfaceEntry;
 class xptiInterfaceInfo;
 class xptiTypelibGuts;
 
 namespace mozilla {
 
 class XPTInterfaceInfoManager MOZ_FINAL
     : public nsIInterfaceInfoManager
 {
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINTERFACEINFOMANAGER
 
 public:
     // GetSingleton() is infallible
     static XPTInterfaceInfoManager* GetSingleton();
     static void FreeInterfaceInfoManager();
 
     void GetScriptableInterfaces(nsCOMArray<nsIInterfaceInfo>& aInterfaces);
--- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
@@ -590,26 +590,26 @@ xptiInterfaceInfo::~xptiInterfaceInfo()
     LOG_INFO_DESTROY(this);
     NS_IF_RELEASE(mParent); 
     NS_ASSERTION(!mEntry, "bad state in dtor");
 }
 
 nsrefcnt
 xptiInterfaceInfo::AddRef(void)
 {
-    nsrefcnt cnt = NS_AtomicIncrementRefcnt(mRefCnt);
+    nsrefcnt cnt = ++mRefCnt;
     NS_LOG_ADDREF(this, cnt, "xptiInterfaceInfo", sizeof(*this));
     return cnt;
 }
 
 nsrefcnt
 xptiInterfaceInfo::Release(void)
 {
     xptiInterfaceEntry* entry = mEntry;
-    nsrefcnt cnt = NS_AtomicDecrementRefcnt(mRefCnt);
+    nsrefcnt cnt = --mRefCnt;
     NS_LOG_RELEASE(this, cnt, "xptiInterfaceInfo");
     if(!cnt)
     {
         mozilla::ReentrantMonitorAutoEnter monitor(XPTInterfaceInfoManager::
                                           GetSingleton()->mWorkingSet.
                                           mTableReentrantMonitor);
         LOG_INFO_MONITOR_ENTRY;
 
--- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfoManager.cpp
@@ -14,18 +14,18 @@
 #include "nsISupportsArray.h"
 #include "nsArrayEnumerator.h"
 #include "nsDirectoryService.h"
 #include "mozilla/FileUtils.h"
 #include "nsIMemoryReporter.h"
 
 using namespace mozilla;
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(XPTInterfaceInfoManager, 
-                              nsIInterfaceInfoManager)
+NS_IMPL_ISUPPORTS1(XPTInterfaceInfoManager, 
+                   nsIInterfaceInfoManager)
 
 static XPTInterfaceInfoManager* gInterfaceInfoManager = nullptr;
 #ifdef DEBUG
 static int gCallCount = 0;
 #endif
 
 
 NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(XPTMallocSizeOf)
--- a/xpcom/reflect/xptinfo/src/xptiprivate.h
+++ b/xpcom/reflect/xptinfo/src/xptiprivate.h
@@ -286,17 +286,17 @@ private:
     xptiInterfaceInfo*      mInfo;        // May come and go.
     xptiInfoFlags           mFlags;
     char                    mName[1];     // Always last. Sized to fit.
 };
 
 class xptiInterfaceInfo MOZ_FINAL : public nsIInterfaceInfo
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     // Use delegation to implement (most!) of nsIInterfaceInfo.
     NS_IMETHOD GetName(char * *aName) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetName(aName); }
     NS_IMETHOD GetInterfaceIID(nsIID * *aIID) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->GetIID(aIID); }
     NS_IMETHOD IsScriptable(bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsScriptable(_retval); }
     NS_IMETHOD IsBuiltinClass(bool *_retval) { return !mEntry ? NS_ERROR_UNEXPECTED : mEntry->IsBuiltinClass(_retval); }
     // Except this one.
     NS_IMETHOD GetParent(nsIInterfaceInfo * *aParent) 
--- a/xpcom/tests/TestPipes.cpp
+++ b/xpcom/tests/TestPipes.cpp
@@ -101,17 +101,17 @@ WriteAll(nsIOutputStream *os, const char
         bufLen -= n;
         *lenWritten += n;
     }
     return NS_OK;
 }
 
 class nsReceiver : public nsIRunnable {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_IMETHOD Run() {
         nsresult rv;
         char buf[101];
         uint32_t count;
         PRIntervalTime start = PR_IntervalNow();
         while (true) {
             rv = mIn->Read(buf, 100, &count);
@@ -141,17 +141,17 @@ public:
 
     uint32_t GetBytesRead() { return mCount; }
 
 protected:
     nsCOMPtr<nsIInputStream> mIn;
     uint32_t            mCount;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsReceiver, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsReceiver, nsIRunnable)
 
 nsresult
 TestPipe(nsIInputStream* in, nsIOutputStream* out)
 {
     nsCOMPtr<nsReceiver> receiver = new nsReceiver(in);
     if (!receiver)
         return NS_ERROR_OUT_OF_MEMORY;
 
@@ -192,17 +192,17 @@ TestPipe(nsIInputStream* in, nsIOutputSt
 
     return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsShortReader : public nsIRunnable {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_IMETHOD Run() {
         nsresult rv;
         char buf[101];
         uint32_t count;
         uint32_t total = 0;
         while (true) {
             //if (gTrace)
@@ -256,17 +256,17 @@ public:
     }
 
 protected:
     nsCOMPtr<nsIInputStream> mIn;
     uint32_t                 mReceived;
     Monitor*                 mMon;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsShortReader, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsShortReader, nsIRunnable)
 
 nsresult
 TestShortWrites(nsIInputStream* in, nsIOutputStream* out)
 {
     nsCOMPtr<nsShortReader> receiver = new nsShortReader(in);
     if (!receiver)
         return NS_ERROR_OUT_OF_MEMORY;
 
@@ -311,17 +311,17 @@ TestShortWrites(nsIInputStream* in, nsIO
     return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 class nsPump : public nsIRunnable
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_IMETHOD Run() {
         nsresult rv;
         uint32_t count;
         while (true) {
             rv = mOut->WriteFrom(mIn, ~0U, &count);
             if (NS_FAILED(rv)) {
                 printf("Write failed\n");
@@ -347,18 +347,17 @@ public:
     }
 
 protected:
     nsCOMPtr<nsIInputStream>      mIn;
     nsCOMPtr<nsIOutputStream>     mOut;
     uint32_t                            mCount;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsPump,
-                              nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsPump, nsIRunnable)
 
 nsresult
 TestChainedPipes()
 {
     nsresult rv;
     printf("TestChainedPipes\n");
 
     nsCOMPtr<nsIInputStream> in1;
--- a/xpcom/tests/TestRacingServiceManager.cpp
+++ b/xpcom/tests/TestRacingServiceManager.cpp
@@ -82,67 +82,67 @@ public:
 
 private:
   ReentrantMonitor** mReentrantMonitorPtr;
 };
 
 class Factory MOZ_FINAL : public nsIFactory
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   Factory() : mFirstComponentCreated(false) { }
 
   NS_IMETHOD CreateInstance(nsISupports* aDelegate,
                             const nsIID& aIID,
                             void** aResult);
 
   NS_IMETHOD LockFactory(bool aLock) {
     return NS_OK;
   }
 
   bool mFirstComponentCreated;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(Factory, nsIFactory)
+NS_IMPL_ISUPPORTS1(Factory, nsIFactory)
 
 class Component1 MOZ_FINAL : public nsISupports
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   Component1() {
     // This is the real test - make sure that only one instance is ever created.
     int32_t count = PR_AtomicIncrement(&gComponent1Count);
     TEST_ASSERTION(count == 1, "Too many components created!");
   }
 };
 
-NS_IMPL_THREADSAFE_ADDREF(Component1)
-NS_IMPL_THREADSAFE_RELEASE(Component1)
+NS_IMPL_ADDREF(Component1)
+NS_IMPL_RELEASE(Component1)
 
 NS_INTERFACE_MAP_BEGIN(Component1)
   NS_INTERFACE_MAP_ENTRY(Component1)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 class Component2 MOZ_FINAL : public nsISupports
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   Component2() {
     // This is the real test - make sure that only one instance is ever created.
     int32_t count = PR_AtomicIncrement(&gComponent2Count);
     TEST_ASSERTION(count == 1, "Too many components created!");
   }
 };
 
-NS_IMPL_THREADSAFE_ADDREF(Component2)
-NS_IMPL_THREADSAFE_RELEASE(Component2)
+NS_IMPL_ADDREF(Component2)
+NS_IMPL_RELEASE(Component2)
 
 NS_INTERFACE_MAP_BEGIN(Component2)
   NS_INTERFACE_MAP_ENTRY(Component2)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 Factory::CreateInstance(nsISupports* aDelegate,
--- a/xpcom/tests/TestThreadPool.cpp
+++ b/xpcom/tests/TestThreadPool.cpp
@@ -11,33 +11,33 @@
 #include "nsIThreadPool.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsIRunnable.h"
 
 class Task : public nsIRunnable
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   Task(int i) : mIndex(i) {}
 
   NS_IMETHOD Run()
   {
     printf("###(%d) running from thread: %p\n", mIndex, (void *) PR_GetCurrentThread());
     int r = (int) ((float) rand() * 200 / RAND_MAX);
     PR_Sleep(PR_MillisecondsToInterval(r));
     printf("###(%d) exiting from thread: %p\n", mIndex, (void *) PR_GetCurrentThread());
     return NS_OK;
   }
 
 private:
   int mIndex;
 };
-NS_IMPL_THREADSAFE_ISUPPORTS1(Task, nsIRunnable)
+NS_IMPL_ISUPPORTS1(Task, nsIRunnable)
 
 static nsresult
 RunTests()
 {
   nsCOMPtr<nsIThreadPool> pool = do_CreateInstance(NS_THREADPOOL_CONTRACTID);
   NS_ENSURE_STATE(pool);
 
   for (int i = 0; i < 100; ++i) {
--- a/xpcom/tests/TestThreadPoolListener.cpp
+++ b/xpcom/tests/TestThreadPoolListener.cpp
@@ -43,21 +43,21 @@ static bool gAllThreadsShutDown = false;
       NS_DebugBreak(NS_DEBUG_ABORT, _msg, #_test, __FILE__, __LINE__); \
     } \
   PR_END_MACRO
 #endif
 
 class Listener MOZ_FINAL : public nsIThreadPoolListener
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITHREADPOOLLISTENER
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(Listener, nsIThreadPoolListener)
+NS_IMPL_ISUPPORTS1(Listener, nsIThreadPoolListener)
 
 NS_IMETHODIMP
 Listener::OnThreadCreated()
 {
   nsCOMPtr<nsIThread> current(do_GetCurrentThread());
   TEST_ASSERTION(current, "Couldn't get current thread!");
 
   ReentrantMonitorAutoEnter mon(*gReentrantMonitor);
--- a/xpcom/tests/TestThreads.cpp
+++ b/xpcom/tests/TestThreads.cpp
@@ -8,17 +8,17 @@
 #include <stdlib.h>
 #include "nspr.h"
 #include "nsCOMPtr.h"
 #include "nsIServiceManager.h"
 #include "nsXPCOM.h"
 
 class nsRunner : public nsIRunnable {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_IMETHOD Run() {
         nsCOMPtr<nsIThread> thread;
         nsresult rv = NS_GetCurrentThread(getter_AddRefs(thread));
         if (NS_FAILED(rv)) {
             printf("failed to get current thread\n");
             return rv;
         }
@@ -33,17 +33,17 @@ public:
 
     nsRunner(int num) : mNum(num) {
     }
 
 protected:
     int mNum;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsRunner, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsRunner, nsIRunnable)
 
 nsresult
 TestThreads()
 {
     nsresult rv;
 
     nsCOMPtr<nsIRunnable> event = new nsRunner(0);
     if (!event)
@@ -70,17 +70,17 @@ TestThreads()
 
     PR_Sleep(PR_MillisecondsToInterval(100));       // hopefully the runner will quit here
 
     return NS_OK;
 }
 
 class nsStressRunner : public nsIRunnable {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
 
     NS_IMETHOD Run() {
         NS_ASSERTION(!mWasRun, "run twice!");
         mWasRun = true;
         PR_Sleep(1);
         if (!PR_AtomicDecrement(&gNum)) {
             printf("   last thread was %d\n", mNum);
         }
@@ -101,17 +101,17 @@ private:
 protected:
     static int32_t gNum;
     int32_t mNum;
     bool mWasRun;
 };
 
 int32_t nsStressRunner::gNum = 0;
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsStressRunner, nsIRunnable)
+NS_IMPL_ISUPPORTS1(nsStressRunner, nsIRunnable)
 
 static int Stress(int loops, int threads)
 {
 
     for (int i = 0; i < loops; i++) {
         printf("Loop %d of %d\n", i+1, loops);
 
         int k;
--- a/xpcom/tests/TestTimers.cpp
+++ b/xpcom/tests/TestTimers.cpp
@@ -67,17 +67,17 @@ public:
 
 private:
   ReentrantMonitor* mReentrantMonitor;
 };
 
 class TimerCallback MOZ_FINAL : public nsITimerCallback
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
 
   TimerCallback(nsIThread** aThreadPtr, ReentrantMonitor* aReentrantMonitor)
   : mThreadPtr(aThreadPtr), mReentrantMonitor(aReentrantMonitor) { }
 
   NS_IMETHOD Notify(nsITimer* aTimer) {
     nsCOMPtr<nsIThread> current(do_GetCurrentThread());
 
     ReentrantMonitorAutoEnter mon(*mReentrantMonitor);
@@ -89,17 +89,17 @@ public:
 
     return NS_OK;
   }
 private:
   nsIThread** mThreadPtr;
   ReentrantMonitor* mReentrantMonitor;
 };
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(TimerCallback, nsITimerCallback)
+NS_IMPL_ISUPPORTS1(TimerCallback, nsITimerCallback)
 
 nsresult
 TestTargetedTimers()
 {
   AutoCreateAndDestroyReentrantMonitor newMon;
   NS_ENSURE_TRUE(newMon, NS_ERROR_OUT_OF_MEMORY);
 
   AutoTestThread testThread;
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -329,22 +329,22 @@ LazyIdleThread::ShutdownThread()
 
 void
 LazyIdleThread::SelfDestruct()
 {
   MOZ_ASSERT(mRefCnt == 1, "Bad refcount!");
   delete this;
 }
 
-NS_IMPL_THREADSAFE_ADDREF(LazyIdleThread)
+NS_IMPL_ADDREF(LazyIdleThread)
 
 NS_IMETHODIMP_(nsrefcnt)
 LazyIdleThread::Release()
 {
-  nsrefcnt count = NS_AtomicDecrementRefcnt(mRefCnt);
+  nsrefcnt count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "LazyIdleThread");
 
   if (!count) {
     // Stabilize refcount.
     mRefCnt = 1;
 
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct);
@@ -358,21 +358,21 @@ LazyIdleThread::Release()
       // thread.
       SelfDestruct();
     }
   }
 
   return count;
 }
 
-NS_IMPL_THREADSAFE_QUERY_INTERFACE5(LazyIdleThread, nsIThread,
-                                                    nsIEventTarget,
-                                                    nsITimerCallback,
-                                                    nsIThreadObserver,
-                                                    nsIObserver)
+NS_IMPL_QUERY_INTERFACE5(LazyIdleThread, nsIThread,
+                         nsIEventTarget,
+                         nsITimerCallback,
+                         nsIThreadObserver,
+                         nsIObserver)
 
 NS_IMETHODIMP
 LazyIdleThread::Dispatch(nsIRunnable* aEvent,
                          uint32_t aFlags)
 {
   ASSERT_OWNING_THREAD();
 
   // LazyIdleThread can't always support synchronous dispatch currently.
--- a/xpcom/threads/LazyIdleThread.h
+++ b/xpcom/threads/LazyIdleThread.h
@@ -33,17 +33,17 @@ namespace mozilla {
  * XPCOM shutdown using the Observer Service.
  */
 class LazyIdleThread MOZ_FINAL : public nsIThread,
                                  public nsITimerCallback,
                                  public nsIThreadObserver,
                                  public nsIObserver
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREAD
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSITHREADOBSERVER
   NS_DECL_NSIOBSERVER
 
   enum ShutdownMethod {
     AutomaticShutdown = 0,
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -12,17 +12,17 @@
 #include "nsIObserverService.h"
 #include "nsIServiceManager.h"
 #include "mozilla/Services.h"
 
 #include <math.h>
 
 using namespace mozilla;
 
-NS_IMPL_THREADSAFE_ISUPPORTS2(TimerThread, nsIRunnable, nsIObserver)
+NS_IMPL_ISUPPORTS2(TimerThread, nsIRunnable, nsIObserver)
 
 TimerThread::TimerThread() :
   mInitInProgress(0),
   mInitialized(false),
   mMonitor("TimerThread.mMonitor"),
   mShutdown(false),
   mWaiting(false),
   mSleeping(false)
--- a/xpcom/threads/TimerThread.h
+++ b/xpcom/threads/TimerThread.h
@@ -25,17 +25,17 @@ class TimerThread MOZ_FINAL : public nsI
 public:
   typedef mozilla::Monitor Monitor;
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
 
   TimerThread();
   NS_HIDDEN_(nsresult) InitLocks();
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIRUNNABLE
   NS_DECL_NSIOBSERVER
   
   NS_HIDDEN_(nsresult) Init();
   NS_HIDDEN_(nsresult) Shutdown();
 
   nsresult AddTimer(nsTimerImpl *aTimer);
   nsresult TimerDelayChanged(nsTimerImpl *aTimer);
--- a/xpcom/threads/nsEnvironment.cpp
+++ b/xpcom/threads/nsEnvironment.cpp
@@ -9,17 +9,17 @@
 #include "nsBaseHashtable.h"
 #include "nsHashKeys.h"
 #include "nsPromiseFlatString.h"
 #include "nsDependentString.h"
 #include "nsNativeCharsetUtils.h"
 
 using namespace mozilla;
 
-NS_IMPL_THREADSAFE_ISUPPORTS1(nsEnvironment, nsIEnvironment)
+NS_IMPL_ISUPPORTS1(nsEnvironment, nsIEnvironment)
 
 nsresult
 nsEnvironment::Create(nsISupports *aOuter, REFNSIID aIID,
                       void **aResult)
 {
     nsresult rv;
     *aResult = nullptr;
 
--- a/xpcom/threads/nsEnvironment.h
+++ b/xpcom/threads/nsEnvironment.h
@@ -13,17 +13,17 @@
 #define NS_ENVIRONMENT_CID \
   { 0X3D68F92UL, 0X9513, 0X4E25, \
   { 0X9B, 0XE9, 0X7C, 0XB2, 0X39, 0X87, 0X41, 0X72 } }
 #define NS_ENVIRONMENT_CONTRACTID "@mozilla.org/process/environment;1"
 
 class nsEnvironment MOZ_FINAL : public nsIEnvironment
 {
 public:
-    NS_DECL_ISUPPORTS
+    NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIENVIRONMENT
 
     static nsresult Create(nsISupports *aOuter, REFNSIID aIID,
                            void **aResult);
 
 private:
     nsEnvironment() : mLock("nsEnvironment.mLock") { }
     ~nsEnvironment();
--- a/xpcom/threads/nsProcess.h
+++ b/xpcom/threads/nsProcess.h
@@ -31,17 +31,17 @@
 {0x7b4eeb20, 0xd781, 0x11d4, \
    {0x8A, 0x83, 0x00, 0x10, 0xa4, 0xe0, 0xc9, 0xca}}
 
 class nsProcess MOZ_FINAL : public nsIProcess,
                             public nsIObserver
 {
 public:
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPROCESS
   NS_DECL_NSIOBSERVER
 
   nsProcess();
 
 private:
   ~nsProcess();
   static void Monitor(void *arg);
--- a/xpcom/threads/nsProcessCommon.cpp
+++ b/xpcom/threads/nsProcessCommon.cpp
@@ -54,18 +54,18 @@ cpu_type_t pref_cpu_types[2] = {
                                  CPU_TYPE_POWERPC,
 #endif
                                  CPU_TYPE_ANY };
 #endif
 
 //-------------------------------------------------------------------//
 // nsIProcess implementation
 //-------------------------------------------------------------------//
-NS_IMPL_THREADSAFE_ISUPPORTS2(nsProcess, nsIProcess,
-                                         nsIObserver)
+NS_IMPL_ISUPPORTS2(nsProcess, nsIProcess,
+                   nsIObserver)
 
 //Constructor
 nsProcess::nsProcess()
     : mThread(nullptr)
     , mLock("nsProcess.mLock")
     , mShutdown(false)
     , mBlocking(false)
     , mPid(-1)
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -125,18 +125,18 @@ nsThreadClassInfo::GetFlags(uint32_t *re
 NS_IMETHODIMP
 nsThreadClassInfo::GetClassIDNoAlloc(nsCID *result)
 {
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 //-----------------------------------------------------------------------------
 
-NS_IMPL_THREADSAFE_ADDREF(nsThread)
-NS_IMPL_THREADSAFE_RELEASE(nsThread)
+NS_IMPL_ADDREF(nsThread)
+NS_IMPL_RELEASE(nsThread)
 NS_INTERFACE_MAP_BEGIN(nsThread)
   NS_INTERFACE_MAP_ENTRY(nsIThread)
   NS_INTERFACE_MAP_ENTRY(nsIThreadInternal)
   NS_INTERFACE_MAP_ENTRY(nsIEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIThread)
   if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
     static nsThreadClassInfo sThreadClassInfo;
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -16,17 +16,17 @@
 #include "nsTObserverArray.h"
 #include "mozilla/Attributes.h"
 
 // A native thread
 class nsThread MOZ_FINAL : public nsIThreadInternal,
                            public nsISupportsPriority
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREAD
   NS_DECL_NSITHREADINTERNAL
   NS_DECL_NSISUPPORTSPRIORITY
 
   enum MainThreadFlag {
     MAIN_THREAD,
     NOT_MAIN_THREAD
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -32,18 +32,18 @@ GetThreadPoolLog()
 //  o  Use nsThreadPool::Run as the main routine for each thread.
 //  o  Each thread waits on the event queue's monitor, checking for
 //     pending events and rescheduling itself as an idle thread.
 
 #define DEFAULT_THREAD_LIMIT 4
 #define DEFAULT_IDLE_THREAD_LIMIT 1
 #define DEFAULT_IDLE_THREAD_TIMEOUT PR_SecondsToInterval(60)
 
-NS_IMPL_THREADSAFE_ADDREF(nsThreadPool)
-NS_IMPL_THREADSAFE_RELEASE(nsThreadPool)
+NS_IMPL_ADDREF(nsThreadPool)
+NS_IMPL_RELEASE(nsThreadPool)
 NS_IMPL_CLASSINFO(nsThreadPool, NULL, nsIClassInfo::THREADSAFE,
                   NS_THREADPOOL_CID)
 NS_IMPL_QUERY_INTERFACE3_CI(nsThreadPool, nsIThreadPool, nsIEventTarget,
                             nsIRunnable)
 NS_IMPL_CI_INTERFACE_GETTER2(nsThreadPool, nsIThreadPool, nsIEventTarget)
 
 nsThreadPool::nsThreadPool()
   : mThreadLimit(DEFAULT_THREAD_LIMIT)
--- a/xpcom/threads/nsThreadPool.h
+++ b/xpcom/threads/nsThreadPool.h
@@ -15,17 +15,17 @@
 #include "nsCOMPtr.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
 
 class nsThreadPool MOZ_FINAL : public nsIThreadPool,
                                public nsIRunnable
 {
 public:
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIEVENTTARGET
   NS_DECL_NSITHREADPOOL
   NS_DECL_NSIRUNNABLE
 
   nsThreadPool();
 
 private:
   ~nsThreadPool();
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -183,25 +183,25 @@ void TimerEventAllocator::Free(void* aPt
   FreeEntry* entry = reinterpret_cast<FreeEntry*>(aPtr);
 
   entry->mNext = mFirstFree;
   mFirstFree = entry;
 }
 
 } // anonymous namespace
 
-NS_IMPL_THREADSAFE_QUERY_INTERFACE1(nsTimerImpl, nsITimer)
-NS_IMPL_THREADSAFE_ADDREF(nsTimerImpl)
+NS_IMPL_QUERY_INTERFACE1(nsTimerImpl, nsITimer)
+NS_IMPL_ADDREF(nsTimerImpl)
 
 NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Release(void)
 {
   nsrefcnt count;
 
   MOZ_ASSERT(int32_t(mRefCnt) > 0, "dup release");
-  count = NS_AtomicDecrementRefcnt(mRefCnt);
+  count = --mRefCnt;
   NS_LOG_RELEASE(this, count, "nsTimerImpl");
   if (count == 0) {
     mRefCnt = 1; /* stabilize */
 
     /* enable this to find non-threadsafe destructors: */
     /* NS_ASSERT_OWNINGTHREAD(nsTimerImpl); */
     delete this;
     return 0;
--- a/xpcom/threads/nsTimerImpl.h
+++ b/xpcom/threads/nsTimerImpl.h
@@ -52,17 +52,17 @@ public:
 
   friend class TimerThread;
   friend struct TimerAdditionComparator;
 
   void Fire();
   nsresult PostTimerEvent();
   void SetDelayInternal(uint32_t aDelay);
 
-  NS_DECL_ISUPPORTS
+  NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITIMER
 
   int32_t GetGeneration() { return mGeneration; }
 
 private:
   ~nsTimerImpl();
   nsresult InitCommon(uint32_t aType, uint32_t aDelay);