Bug 839962 - Part 2: Replace some XPCOM thread NS_ASSERTIONs with MOZ_ASSERTs. r=bsmedberg
authorChris Peterson <cpeterson@mozilla.com>
Thu, 07 Feb 2013 21:54:20 -0800
changeset 127623 46b409b1fa041594600dc1a863c1fb698823f1fd
parent 127622 1b725f0b2e833916e0d21615b6f7fac334f850cc
child 127624 a4f19181ebc2f11106d95014ee3f9bb3910fffe4
push id3384
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:42:39 +0000
treeherdermozilla-aurora@d8c97bae8521 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs839962
milestone21.0a1
Bug 839962 - Part 2: Replace some XPCOM thread NS_ASSERTIONs with MOZ_ASSERTs. r=bsmedberg
xpcom/components/nsComponentManager.cpp
xpcom/components/nsNativeComponentLoader.cpp
xpcom/ds/nsAtomTable.cpp
xpcom/io/nsLocalFileWin.cpp
xpcom/threads/HangMonitor.cpp
xpcom/threads/LazyIdleThread.cpp
xpcom/threads/TimerThread.cpp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadPool.cpp
xpcom/threads/nsTimerImpl.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -404,17 +404,17 @@ nsComponentManagerImpl::RegisterModule(c
         for (entry = aModule->mCIDs; entry->cid; ++entry)
             RegisterCIDEntry(entry, m);
     }
 
     if (aModule->mContractIDs) {
         const mozilla::Module::ContractIDEntry* entry;
         for (entry = aModule->mContractIDs; entry->contractid; ++entry)
             RegisterContractID(entry);
-        NS_ASSERTION(!entry->cid, "Incorrectly terminated contract list");
+        MOZ_ASSERT(!entry->cid, "Incorrectly terminated contract list");
     }
             
     if (aModule->mCategoryEntries) {
         const mozilla::Module::CategoryEntry* entry;
         for (entry = aModule->mCategoryEntries; entry->category; ++entry)
             nsCategoryManager::GetSingleton()->
                 AddCategoryEntry(entry->category,
                                  entry->entry,
@@ -1181,33 +1181,33 @@ nsComponentManagerImpl::GetService(const
 
     if (entry->mServiceObject) {
         nsCOMPtr<nsISupports> supports = entry->mServiceObject;
         mon.Exit();
         return supports->QueryInterface(aIID, result);
     }
 
     PRThread* currentPRThread = PR_GetCurrentThread();
-    NS_ASSERTION(currentPRThread, "This should never be null!");
+    MOZ_ASSERT(currentPRThread, "This should never be null!");
 
     // Needed to optimize the event loop below.
     nsIThread* currentThread = nullptr;
 
     PRThread* pendingPRThread;
     while ((pendingPRThread = GetPendingServiceThread(aClass))) {
         if (pendingPRThread == currentPRThread) {
             NS_ERROR("Recursive GetService!");
             return NS_ERROR_NOT_AVAILABLE;
         }
 
         mon.Exit();
 
         if (!currentThread) {
             currentThread = NS_GetCurrentThread();
-            NS_ASSERTION(currentThread, "This should never be null!");
+            MOZ_ASSERT(currentThread, "This should never be null!");
         }
 
         // This will process a single event or yield the thread if no event is
         // pending.
         if (!NS_ProcessNextEvent(currentThread, false)) {
             PR_Sleep(PR_INTERVAL_NO_WAIT);
         }
 
@@ -1235,18 +1235,18 @@ nsComponentManagerImpl::GetService(const
     mon.Exit();
 
     nsresult rv = CreateInstance(aClass, nullptr, aIID, getter_AddRefs(service));
 
     mon.Enter();
 
 #ifdef DEBUG
     pendingPRThread = GetPendingServiceThread(aClass);
-    NS_ASSERTION(pendingPRThread == currentPRThread,
-                 "Pending service array has been changed!");
+    MOZ_ASSERT(pendingPRThread == currentPRThread,
+               "Pending service array has been changed!");
 #endif
     RemovePendingService(aClass);
 
     if (NS_FAILED(rv))
         return rv;
 
     NS_ASSERTION(!entry->mServiceObject, "Created two instances of a service!");
 
@@ -1369,33 +1369,33 @@ nsComponentManagerImpl::GetServiceByCont
         // QueryInterface, because it invokes user code which could try to re-enter
         // the service manager, or try to grab some other lock/monitor/condvar
         // and deadlock, e.g. bug 282743.
         mon.Exit();
         return serviceObject->QueryInterface(aIID, result);
     }
 
     PRThread* currentPRThread = PR_GetCurrentThread();
-    NS_ASSERTION(currentPRThread, "This should never be null!");
+    MOZ_ASSERT(currentPRThread, "This should never be null!");
 
     // Needed to optimize the event loop below.
     nsIThread* currentThread = nullptr;
 
     PRThread* pendingPRThread;
     while ((pendingPRThread = GetPendingServiceThread(*entry->mCIDEntry->cid))) {
         if (pendingPRThread == currentPRThread) {
             NS_ERROR("Recursive GetService!");
             return NS_ERROR_NOT_AVAILABLE;
         }
 
         mon.Exit();
 
         if (!currentThread) {
             currentThread = NS_GetCurrentThread();
-            NS_ASSERTION(currentThread, "This should never be null!");
+            MOZ_ASSERT(currentThread, "This should never be null!");
         }
 
         // This will process a single event or yield the thread if no event is
         // pending.
         if (!NS_ProcessNextEvent(currentThread, false)) {
             PR_Sleep(PR_INTERVAL_NO_WAIT);
         }
 
@@ -1424,18 +1424,18 @@ nsComponentManagerImpl::GetServiceByCont
 
     nsresult rv = CreateInstanceByContractID(aContractID, nullptr, aIID,
                                              getter_AddRefs(service));
 
     mon.Enter();
 
 #ifdef DEBUG
     pendingPRThread = GetPendingServiceThread(*entry->mCIDEntry->cid);
-    NS_ASSERTION(pendingPRThread == currentPRThread,
-                 "Pending service array has been changed!");
+    MOZ_ASSERT(pendingPRThread == currentPRThread,
+               "Pending service array has been changed!");
 #endif
     RemovePendingService(*entry->mCIDEntry->cid);
 
     if (NS_FAILED(rv))
         return rv;
 
     NS_ASSERTION(!entry->mServiceObject, "Created two instances of a service!");
 
--- a/xpcom/components/nsNativeComponentLoader.cpp
+++ b/xpcom/components/nsNativeComponentLoader.cpp
@@ -71,18 +71,17 @@ NS_IMPL_QUERY_INTERFACE1(nsNativeModuleL
 NS_IMPL_ADDREF_USING_AGGREGATOR(nsNativeModuleLoader,
                                 nsComponentManagerImpl::gComponentManager)
 NS_IMPL_RELEASE_USING_AGGREGATOR(nsNativeModuleLoader,
                                  nsComponentManagerImpl::gComponentManager)
 
 nsresult
 nsNativeModuleLoader::Init()
 {
-    NS_ASSERTION(NS_IsMainThread(), "Startup not on main thread?");
-
+    MOZ_ASSERT(NS_IsMainThread(), "Startup not on main thread?");
     LOG(PR_LOG_DEBUG, ("nsNativeModuleLoader::Init()"));
     mLibraries.Init();
     return NS_OK;
 }
 
 class LoadModuleMainThreadRunnable : public nsRunnable
 {
 public:
@@ -236,13 +235,12 @@ nsNativeModuleLoader::UnloaderFunc(nsIHa
 #endif
 
     return PL_DHASH_REMOVE;
 }
 
 void
 nsNativeModuleLoader::UnloadLibraries()
 {
-    NS_ASSERTION(NS_IsMainThread(), "Shutdown not on main thread?");
-
+    MOZ_ASSERT(NS_IsMainThread(), "Shutdown not on main thread?");
     mLibraries.Enumerate(ReleaserFunc, nullptr);
     mLibraries.Enumerate(UnloaderFunc, nullptr);
 }
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -364,41 +364,41 @@ NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom)
 PermanentAtomImpl::~PermanentAtomImpl()
 {
   // So we can tell if we were permanent while running the base class dtor.
   mRefCnt = REFCNT_PERMANENT_SENTINEL;
 }
 
 NS_IMETHODIMP_(nsrefcnt) PermanentAtomImpl::AddRef()
 {
-  NS_ASSERTION(NS_IsMainThread(), "wrong thread");
+  MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   return 2;
 }
 
 NS_IMETHODIMP_(nsrefcnt) PermanentAtomImpl::Release()
 {
-  NS_ASSERTION(NS_IsMainThread(), "wrong thread");
+  MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   return 1;
 }
 
 /* virtual */ bool
 AtomImpl::IsPermanent()
 {
   return false;
 }
 
 /* virtual */ bool
 PermanentAtomImpl::IsPermanent()
 {
   return true;
 }
 
 void* PermanentAtomImpl::operator new ( size_t size, AtomImpl* aAtom ) CPP_THROW_NEW {
-  NS_ASSERTION(!aAtom->IsPermanent(),
-               "converting atom that's already permanent");
+  MOZ_ASSERT(!aAtom->IsPermanent(),
+             "converting atom that's already permanent");
 
   // Just let the constructor overwrite the vtable pointer.
   return aAtom;
 }
 
 NS_IMETHODIMP 
 AtomImpl::ScriptableToString(nsAString& aBuf)
 {
@@ -491,29 +491,29 @@ EnsureTableExists()
   // Initialization failed.
   gAtomTable.ops = nullptr;
   return false;
 }
 
 static inline AtomTableEntry*
 GetAtomHashEntry(const char* aString, uint32_t aLength)
 {
-  NS_ASSERTION(NS_IsMainThread(), "wrong thread");
+  MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   if (!EnsureTableExists()) {
     return nullptr;
   }
   AtomTableKey key(aString, aLength);
   return static_cast<AtomTableEntry*>
                     (PL_DHashTableOperate(&gAtomTable, &key, PL_DHASH_ADD));
 }
 
 static inline AtomTableEntry*
 GetAtomHashEntry(const PRUnichar* aString, uint32_t aLength)
 {
-  NS_ASSERTION(NS_IsMainThread(), "wrong thread");
+  MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
   if (!EnsureTableExists()) {
     return nullptr;
   }
   AtomTableKey key(aString, aLength);
   return static_cast<AtomTableEntry*>
                     (PL_DHashTableOperate(&gAtomTable, &key, PL_DHASH_ADD));
 }
 
--- a/xpcom/io/nsLocalFileWin.cpp
+++ b/xpcom/io/nsLocalFileWin.cpp
@@ -109,17 +109,17 @@ public:
     AsyncLocalFileWinOperation(AsyncLocalFileWinOperation::FileOp aOperation,
                                const nsAString &aResolvedPath) : 
         mOperation(aOperation),
         mResolvedPath(aResolvedPath)
     {
     }
 
     NS_IMETHOD Run() {
-        NS_ASSERTION(!NS_IsMainThread(),
+        MOZ_ASSERT(!NS_IsMainThread(),
             "AsyncLocalFileWinOperation should not be run on the main thread!");
 
         CoInitialize(NULL);
         switch(mOperation) {
         case RevealOp: {
             Reveal();
         }
         break;
--- a/xpcom/threads/HangMonitor.cpp
+++ b/xpcom/threads/HangMonitor.cpp
@@ -224,17 +224,17 @@ void
 Startup()
 {
   // The hang detector only runs in chrome processes. If you change this,
   // you must also deal with the threadsafety of AnnotateCrashReport in
   // non-chrome processes!
   if (GeckoProcessType_Default != XRE_GetProcessType())
     return;
 
-  NS_ASSERTION(!gMonitor, "Hang monitor already initialized");
+  MOZ_ASSERT(!gMonitor, "Hang monitor already initialized");
   gMonitor = new Monitor("HangMonitor");
 
   Preferences::RegisterCallback(PrefChanged, kHangMonitorPrefName, NULL);
   PrefChanged(NULL, NULL);
 
 #ifdef REPORT_CHROME_HANGS
   Preferences::RegisterCallback(PrefChanged, kTelemetryPrefName, NULL);
   winMainThreadHandle =
@@ -256,17 +256,17 @@ Startup()
 }
 
 void
 Shutdown()
 {
   if (GeckoProcessType_Default != XRE_GetProcessType())
     return;
 
-  NS_ASSERTION(gMonitor, "Hang monitor not started");
+  MOZ_ASSERT(gMonitor, "Hang monitor not started");
 
   { // Scope the lock we're going to delete later
     MonitorAutoLock lock(*gMonitor);
     gShutdown = true;
     lock.Notify();
   }
 
   // thread creation could theoretically fail
@@ -297,18 +297,18 @@ IsUIMessageWaiting()
                                          WM_MOUSELAST, PM_NOREMOVE);
   return haveUIMessageWaiting;
 #endif
 }
 
 void
 NotifyActivity(ActivityType activityType)
 {
-  NS_ASSERTION(NS_IsMainThread(),
-    "HangMonitor::Notify called from off the main thread.");
+  MOZ_ASSERT(NS_IsMainThread(),
+             "HangMonitor::Notify called from off the main thread.");
 
   // Determine the activity type more specifically
   if (activityType == kGeneralActivity) {
     activityType = IsUIMessageWaiting() ? kActivityUIAVail : 
                                           kActivityNoUIAVail;
   }
 
   // Calculate the cumulative amount of lag time since the last UI message
@@ -345,15 +345,16 @@ NotifyActivity(ActivityType activityType
     }
     cumulativeUILagMS = 0;
   }
 }
 
 void
 Suspend()
 {
-  NS_ASSERTION(NS_IsMainThread(), "HangMonitor::Suspend called from off the main thread.");
+  MOZ_ASSERT(NS_IsMainThread(),
+             "HangMonitor::Suspend called from off the main thread.");
 
   // Because gTimestamp changes this resets the wait count.
   gTimestamp = PR_INTERVAL_NO_WAIT;
 }
 
 } } // namespace mozilla::HangMonitor
--- a/xpcom/threads/LazyIdleThread.cpp
+++ b/xpcom/threads/LazyIdleThread.cpp
@@ -15,17 +15,17 @@
 
 #ifdef DEBUG
 #define ASSERT_OWNING_THREAD()                                                 \
   PR_BEGIN_MACRO                                                               \
     nsIThread* currentThread = NS_GetCurrentThread();                          \
     if (currentThread) {                                                       \
       nsCOMPtr<nsISupports> current(do_QueryInterface(currentThread));         \
       nsCOMPtr<nsISupports> test(do_QueryInterface(mOwningThread));            \
-      NS_ASSERTION(current == test, "Wrong thread!");                          \
+      MOZ_ASSERT(current == test, "Wrong thread!");                            \
     }                                                                          \
   PR_END_MACRO
 #else
 #define ASSERT_OWNING_THREAD() /* nothing */
 #endif
 
 namespace mozilla {
 
@@ -41,17 +41,17 @@ LazyIdleThread::LazyIdleThread(uint32_t 
   mPendingEventCount(0),
   mIdleNotificationCount(0),
   mShutdownMethod(aShutdownMethod),
   mShutdown(false),
   mThreadIsShuttingDown(false),
   mIdleTimeoutEnabled(true),
   mName(aName)
 {
-  NS_ASSERTION(mOwningThread, "This should never fail!");
+  MOZ_ASSERT(mOwningThread, "Need owning thread!");
 }
 
 LazyIdleThread::~LazyIdleThread()
 {
   ASSERT_OWNING_THREAD();
 
   Shutdown();
 }
@@ -81,70 +81,70 @@ LazyIdleThread::DisableIdleTimeout()
 
   if (mIdleTimer && NS_FAILED(mIdleTimer->Cancel())) {
     NS_WARNING("Failed to cancel timer!");
   }
 
   MutexAutoLock lock(mMutex);
 
   // Pretend we have a pending event to keep the idle timer from firing.
-  NS_ASSERTION(mPendingEventCount < UINT32_MAX, "Way too many!");
+  MOZ_ASSERT(mPendingEventCount < UINT32_MAX, "Way too many!");
   mPendingEventCount++;
 }
 
 void
 LazyIdleThread::EnableIdleTimeout()
 {
   ASSERT_OWNING_THREAD();
   if (mIdleTimeoutEnabled) {
     return;
   }
   mIdleTimeoutEnabled = true;
 
   {
     MutexAutoLock lock(mMutex);
 
-    NS_ASSERTION(mPendingEventCount, "Mismatched calls to observer methods!");
+    MOZ_ASSERT(mPendingEventCount, "Mismatched calls to observer methods!");
     --mPendingEventCount;
   }
 
   if (mThread) {
     nsCOMPtr<nsIRunnable> runnable(new nsRunnable());
     if (NS_FAILED(Dispatch(runnable, NS_DISPATCH_NORMAL))) {
       NS_WARNING("Failed to dispatch!");
     }
   }
 }
 
 void
 LazyIdleThread::PreDispatch()
 {
   MutexAutoLock lock(mMutex);
 
-  NS_ASSERTION(mPendingEventCount < UINT32_MAX, "Way too many!");
+  MOZ_ASSERT(mPendingEventCount < UINT32_MAX, "Way too many!");
   mPendingEventCount++;
 }
 
 nsresult
 LazyIdleThread::EnsureThread()
 {
   ASSERT_OWNING_THREAD();
 
   if (mShutdown) {
     return NS_ERROR_UNEXPECTED;
   }
 
   if (mThread) {
     return NS_OK;
   }
 
-  NS_ASSERTION(!mPendingEventCount, "Shouldn't have events yet!");
-  NS_ASSERTION(!mIdleNotificationCount, "Shouldn't have idle events yet!");
-  NS_ASSERTION(!mIdleTimer, "Should have killed this long ago!");
-  NS_ASSERTION(!mThreadIsShuttingDown, "Should have cleared that!");
+  MOZ_ASSERT(!mPendingEventCount, "Shouldn't have events yet!");
+  MOZ_ASSERT(!mIdleNotificationCount, "Shouldn't have idle events yet!");
+  MOZ_ASSERT(!mIdleTimer, "Should have killed this long ago!");
+  MOZ_ASSERT(!mThreadIsShuttingDown, "Should have cleared that!");
 
   nsresult rv;
 
   if (mShutdownMethod == AutomaticShutdown && NS_IsMainThread()) {
     nsCOMPtr<nsIObserverService> obs =
       do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -168,49 +168,49 @@ LazyIdleThread::EnsureThread()
 void
 LazyIdleThread::InitThread()
 {
   PR_SetCurrentThreadName(mName.BeginReading());
 
   // Happens on mThread but mThread may not be set yet...
 
   nsCOMPtr<nsIThreadInternal> thread(do_QueryInterface(NS_GetCurrentThread()));
-  NS_ASSERTION(thread, "This should always succeed!");
+  MOZ_ASSERT(thread, "This should always succeed!");
 
   if (NS_FAILED(thread->SetObserver(this))) {
     NS_WARNING("Failed to set thread observer!");
   }
 }
 
 void
 LazyIdleThread::CleanupThread()
 {
   nsCOMPtr<nsIThreadInternal> thread(do_QueryInterface(NS_GetCurrentThread()));
-  NS_ASSERTION(thread, "This should always succeed!");
+  MOZ_ASSERT(thread, "This should always succeed!");
 
   if (NS_FAILED(thread->SetObserver(nullptr))) {
     NS_WARNING("Failed to set thread observer!");
   }
 
   MutexAutoLock lock(mMutex);
 
-  NS_ASSERTION(!mThreadIsShuttingDown, "Shouldn't be true ever!");
+  MOZ_ASSERT(!mThreadIsShuttingDown, "Shouldn't be true ever!");
   mThreadIsShuttingDown = true;
 }
 
 void
 LazyIdleThread::ScheduleTimer()
 {
   ASSERT_OWNING_THREAD();
 
   bool shouldSchedule;
   {
     MutexAutoLock lock(mMutex);
 
-    NS_ASSERTION(mIdleNotificationCount, "Should have at least one!");
+    MOZ_ASSERT(mIdleNotificationCount, "Should have at least one!");
     --mIdleNotificationCount;
 
     shouldSchedule = !mIdleNotificationCount && !mPendingEventCount;
   }
 
   if (NS_FAILED(mIdleTimer->Cancel())) {
     NS_WARNING("Failed to cancel timer!");
   }
@@ -249,17 +249,17 @@ LazyIdleThread::ShutdownThread()
     if (mIdleObserver) {
       mIdleObserver->Observe(static_cast<nsIThread*>(this), IDLE_THREAD_TOPIC,
                              nullptr);
     }
 
 #ifdef DEBUG
     {
       MutexAutoLock lock(mMutex);
-      NS_ASSERTION(!mThreadIsShuttingDown, "Huh?!");
+      MOZ_ASSERT(!mThreadIsShuttingDown, "Huh?!");
     }
 #endif
 
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewRunnableMethod(this, &LazyIdleThread::CleanupThread);
     NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
 
     PreDispatch();
@@ -277,19 +277,19 @@ LazyIdleThread::ShutdownThread()
     // Now unset the queue.
     mQueuedRunnables = nullptr;
 
     mThread = nullptr;
 
     {
       MutexAutoLock lock(mMutex);
 
-      NS_ASSERTION(!mPendingEventCount, "Huh?!");
-      NS_ASSERTION(!mIdleNotificationCount, "Huh?!");
-      NS_ASSERTION(mThreadIsShuttingDown, "Huh?!");
+      MOZ_ASSERT(!mPendingEventCount, "Huh?!");
+      MOZ_ASSERT(!mIdleNotificationCount, "Huh?!");
+      MOZ_ASSERT(mThreadIsShuttingDown, "Huh?!");
       mThreadIsShuttingDown = false;
     }
   }
 
   if (mIdleTimer) {
     rv = mIdleTimer->Cancel();
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -303,17 +303,17 @@ LazyIdleThread::ShutdownThread()
       NS_ERROR("Runnables dispatched to LazyIdleThread will never run!");
       return NS_OK;
     }
 
     // Re-dispatch the queued runnables.
     for (uint32_t index = 0; index < queuedRunnables.Length(); index++) {
       nsCOMPtr<nsIRunnable> runnable;
       runnable.swap(queuedRunnables[index]);
-      NS_ASSERTION(runnable, "Null runnable?!");
+      MOZ_ASSERT(runnable, "Null runnable?!");
 
       if (NS_FAILED(Dispatch(runnable, NS_DISPATCH_NORMAL))) {
         NS_ERROR("Failed to re-dispatch queued runnable!");
       }
     }
   }
 
   return NS_OK;
@@ -338,17 +338,17 @@ LazyIdleThread::Release()
     // Stabilize refcount.
     mRefCnt = 1;
 
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewNonOwningRunnableMethod(this, &LazyIdleThread::SelfDestruct);
     NS_WARN_IF_FALSE(runnable, "Couldn't make runnable!");
 
     if (NS_FAILED(NS_DispatchToCurrentThread(runnable))) {
-      NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
+      MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
       // The only way this could fail is if we're in shutdown, and in that case
       // threads should have been joined already. Deleting here isn't dangerous
       // anymore because we won't spin the event loop waiting to join the
       // thread.
       SelfDestruct();
     }
   }
 
@@ -410,17 +410,17 @@ LazyIdleThread::GetPRThread(PRThread** a
 NS_IMETHODIMP
 LazyIdleThread::Shutdown()
 {
   ASSERT_OWNING_THREAD();
 
   mShutdown = true;
 
   nsresult rv = ShutdownThread();
-  NS_ASSERTION(!mThread, "Should have destroyed this by now!");
+  MOZ_ASSERT(!mThread, "Should have destroyed this by now!");
 
   mIdleObserver = nullptr;
 
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
@@ -462,17 +462,17 @@ LazyIdleThread::Notify(nsITimer* aTimer)
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LazyIdleThread::OnDispatchedEvent(nsIThreadInternal* /*aThread */)
 {
-  NS_ASSERTION(NS_GetCurrentThread() == mOwningThread, "Wrong thread!");
+  MOZ_ASSERT(NS_GetCurrentThread() == mOwningThread, "Wrong thread!");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LazyIdleThread::OnProcessNextEvent(nsIThreadInternal* /* aThread */,
                                    bool /* aMayWait */,
                                    uint32_t /* aRecursionDepth */)
 {
@@ -482,27 +482,27 @@ LazyIdleThread::OnProcessNextEvent(nsITh
 NS_IMETHODIMP
 LazyIdleThread::AfterProcessNextEvent(nsIThreadInternal* /* aThread */,
                                       uint32_t /* aRecursionDepth */)
 {
   bool shouldNotifyIdle;
   {
     MutexAutoLock lock(mMutex);
 
-    NS_ASSERTION(mPendingEventCount, "Mismatched calls to observer methods!");
+    MOZ_ASSERT(mPendingEventCount, "Mismatched calls to observer methods!");
     --mPendingEventCount;
 
     if (mThreadIsShuttingDown) {
       // We're shutting down, no need to fire any timer.
       return NS_OK;
     }
 
     shouldNotifyIdle = !mPendingEventCount;
     if (shouldNotifyIdle) {
-      NS_ASSERTION(mIdleNotificationCount < UINT32_MAX, "Way too many!");
+      MOZ_ASSERT(mIdleNotificationCount < UINT32_MAX, "Way too many!");
       mIdleNotificationCount++;
     }
   }
 
   if (shouldNotifyIdle) {
     nsCOMPtr<nsIRunnable> runnable =
       NS_NewRunnableMethod(this, &LazyIdleThread::ScheduleTimer);
     NS_ENSURE_TRUE(runnable, NS_ERROR_FAILURE);
@@ -514,18 +514,18 @@ LazyIdleThread::AfterProcessNextEvent(ns
   return NS_OK;
 }
 
 NS_IMETHODIMP
 LazyIdleThread::Observe(nsISupports* /* aSubject */,
                         const char*  aTopic,
                         const PRUnichar* /* aData */)
 {
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  NS_ASSERTION(mShutdownMethod == AutomaticShutdown,
-               "Should not receive notifications if not AutomaticShutdown!");
-  NS_ASSERTION(!strcmp("xpcom-shutdown-threads", aTopic), "Bad topic!");
+  MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
+  MOZ_ASSERT(mShutdownMethod == AutomaticShutdown,
+             "Should not receive notifications if not AutomaticShutdown!");
+  MOZ_ASSERT(!strcmp("xpcom-shutdown-threads", aTopic), "Bad topic!");
 
   Shutdown();
   return NS_OK;
 }
 
 } // namespace mozilla
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -295,17 +295,17 @@ NS_IMETHODIMP TimerThread::Run()
               // code that created and used the timer.
               //
               // Further, note that this should never happen even with a
               // misbehaving user, because nsTimerImpl::Release checks for a
               // refcount of 1 with an armed timer (a timer whose only reference
               // is from the timer thread) and when it hits this will remove the
               // timer from the timer thread and thus destroy the last reference,
               // preventing this situation from occurring.
-              NS_ASSERTION(rc != 0, "destroyed timer off its target thread!");
+              MOZ_ASSERT(rc != 0, "destroyed timer off its target thread!");
             }
             timer = nullptr;
           }
 
           if (mShutdown)
             break;
 
           // Update now, as PostTimerEvent plus the locking may have taken a
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -481,17 +481,17 @@ nsThread::Shutdown()
   // We hold strong references to our event observers, and once the thread is
   // shut down the observers can't easily unregister themselves. Do it here
   // to avoid leaking.
   ClearObservers();
 
 #ifdef DEBUG
   {
     MutexAutoLock lock(mLock);
-    NS_ASSERTION(!mObserver, "Should have been cleared at shutdown!");
+    MOZ_ASSERT(!mObserver, "Should have been cleared at shutdown!");
   }
 #endif
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsThread::HasPendingEvents(bool *result)
@@ -621,18 +621,18 @@ nsThread::ProcessNextEvent(bool mayWait,
     *result = (event.get() != nullptr);
 
     if (event) {
       LOG(("THRD(%p) running [%p]\n", this, event.get()));
       if (MAIN_THREAD == mIsMainThread)
         HangMonitor::NotifyActivity();
       event->Run();
     } else if (mayWait) {
-      NS_ASSERTION(ShuttingDown(),
-                   "This should only happen when shutting down");
+      MOZ_ASSERT(ShuttingDown(),
+                 "This should only happen when shutting down");
       rv = NS_ERROR_UNEXPECTED;
     }
   }
 
   --mRunningEvent;
 
   NOTIFY_EVENT_OBSERVERS(AfterProcessNextEvent, (this, mRunningEvent));
 
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -87,17 +87,17 @@ nsThreadManager::Init()
 
   mInitialized = true;
   return NS_OK;
 }
 
 void
 nsThreadManager::Shutdown()
 {
-  NS_ASSERTION(NS_IsMainThread(), "shutdown not called from main thread");
+  MOZ_ASSERT(NS_IsMainThread(), "shutdown not called from main thread");
 
   // Prevent further access to the thread manager (no more new threads!)
   //
   // XXX What happens if shutdown happens before NewThread completes?
   //     Fortunately, NewThread is only called on the main thread for now.
   //
   mInitialized = false;
 
@@ -151,30 +151,30 @@ nsThreadManager::Shutdown()
 
   // Remove the TLS entry for the main thread.
   PR_SetThreadPrivate(mCurThreadIndex, nullptr);
 }
 
 void
 nsThreadManager::RegisterCurrentThread(nsThread *thread)
 {
-  NS_ASSERTION(thread->GetPRThread() == PR_GetCurrentThread(), "bad thread");
+  MOZ_ASSERT(thread->GetPRThread() == PR_GetCurrentThread(), "bad thread");
 
   MutexAutoLock lock(*mLock);
 
   mThreadsByPRThread.Put(thread->GetPRThread(), thread);  // XXX check OOM?
 
   NS_ADDREF(thread);  // for TLS entry
   PR_SetThreadPrivate(mCurThreadIndex, thread);
 }
 
 void
 nsThreadManager::UnregisterCurrentThread(nsThread *thread)
 {
-  NS_ASSERTION(thread->GetPRThread() == PR_GetCurrentThread(), "bad thread");
+  MOZ_ASSERT(thread->GetPRThread() == PR_GetCurrentThread(), "bad thread");
 
   MutexAutoLock lock(*mLock);
 
   mThreadsByPRThread.Remove(thread->GetPRThread());
 
   PR_SetThreadPrivate(mCurThreadIndex, nullptr);
   // Ref-count balanced via ReleaseObject
 }
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -111,17 +111,17 @@ nsThreadPool::PutEvent(nsIRunnable *even
 void
 nsThreadPool::ShutdownThread(nsIThread *thread)
 {
   LOG(("THRD-P(%p) shutdown async [%p]\n", this, thread));
 
   // This method is responsible for calling Shutdown on |thread|.  This must be
   // done from some other thread, so we use the main thread of the application.
 
-  NS_ASSERTION(!NS_IsMainThread(), "wrong thread");
+  MOZ_ASSERT(!NS_IsMainThread(), "wrong thread");
 
   nsRefPtr<nsIRunnable> r = NS_NewRunnableMethod(thread, &nsIThread::Shutdown);
   NS_DispatchToMainThread(r);
 }
 
 NS_IMETHODIMP
 nsThreadPool::Run()
 {
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -175,17 +175,17 @@ NS_IMETHODIMP_(nsrefcnt) nsTimerImpl::Re
   // Note that both approaches preclude a timer creator, and everyone else
   // except the TimerThread who might have a strong ref, from dropping all
   // their strong refs without implicitly canceling the timer.  Timers need
   // non-mTimers-element strong refs to stay alive.
 
   if (count == 1 && mArmed) {
     mCanceled = true;
 
-    NS_ASSERTION(gThread, "An armed timer exists after the thread timer stopped.");
+    MOZ_ASSERT(gThread, "Armed timer exists after the thread timer stopped.");
     if (NS_SUCCEEDED(gThread->RemoveTimer(this)))
       return 0;
   }
 
   return count;
 }
 
 nsTimerImpl::nsTimerImpl() :