Bug 763000 - Remove MOZ_Assert. r=Ms2ger, r=terrence, r=ted
authorJeff Walden <jwalden@mit.edu>
Thu, 07 Jun 2012 14:41:11 -0700
changeset 99672 01844720b147314475896425f6c5ae9e6f363053
parent 99671 a112cf3d055d8930f8bdb7f40b8537cc26bab787
child 99673 229623f7ea72ed9e611933ef7c6982d0b44add28
push id1729
push userlsblakk@mozilla.com
push dateMon, 16 Jul 2012 20:02:43 +0000
treeherdermozilla-aurora@f4e75e148951 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMs2ger, terrence, ted
bugs763000
milestone16.0a1
Bug 763000 - Remove MOZ_Assert. r=Ms2ger, r=terrence, r=ted
js/public/Utility.h
js/src/gc/Memory.cpp
js/src/jsapi.cpp
js/src/jsapi.h
js/src/jsgc.cpp
js/src/jsinfer.cpp
js/src/jsinfer.h
js/src/jsutil.cpp
js/src/jsutil.h
js/src/vm/Stack.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
mfbt/Assertions.cpp
mfbt/Assertions.h
mfbt/sources.mk
mozglue/linker/Makefile.in
webapprt/mac/Makefile.in
webapprt/win/Makefile.in
xpcom/base/nsCycleCollector.cpp
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -4,16 +4,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/. */
 
 #ifndef js_utility_h__
 #define js_utility_h__
 
 #include "mozilla/Assertions.h"
+#include "mozilla/Attributes.h"
 
 #include <stdlib.h>
 #include <string.h>
 
 #ifdef JS_OOM_DO_BACKTRACES
 #include <stdio.h>
 #include <execinfo.h>
 #endif
@@ -61,16 +62,19 @@ JS_BEGIN_EXTERN_C
 # endif
 #else
 # define JS_THREADSAFE_ASSERT(expr) ((void) 0)
 #endif
 
 #define JS_STATIC_ASSERT(cond)           MOZ_STATIC_ASSERT(cond, "JS_STATIC_ASSERT")
 #define JS_STATIC_ASSERT_IF(cond, expr)  MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF")
 
+extern MOZ_NORETURN JS_PUBLIC_API(void)
+JS_Assert(const char *s, const char *file, int ln);
+
 /*
  * Abort the process in a non-graceful manner. This will cause a core file,
  * call to the debugger or other moral equivalent as well as causing the
  * entire process to stop.
  */
 extern JS_PUBLIC_API(void) JS_Abort(void);
 
 /*
--- a/js/src/gc/Memory.cpp
+++ b/js/src/gc/Memory.cpp
@@ -1,15 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * vim: set ts=8 sw=4 et tw=78:
  *
  * 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/Assertions.h"
+
 #include "jstypes.h"
 
 #include "js/Utility.h"
 #include "gc/Memory.h"
 
 namespace js {
 namespace gc {
 
@@ -19,17 +21,18 @@ namespace gc {
 
 static size_t AllocationGranularity = 0;
 
 void
 InitMemorySubsystem()
 {
     SYSTEM_INFO sysinfo;
     GetSystemInfo(&sysinfo);
-    JS_OPT_ASSERT(sysinfo.dwPageSize == PageSize);
+    if (sysinfo.dwPageSize != PageSize)
+        MOZ_CRASH();
     AllocationGranularity = sysinfo.dwAllocationGranularity;
 }
 
 void *
 MapAlignedPages(size_t size, size_t alignment)
 {
     JS_ASSERT(size >= alignment);
     JS_ASSERT(size % alignment == 0);
@@ -294,17 +297,18 @@ GetPageFaultCount()
 #include <sys/mman.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <unistd.h>
 
 void
 InitMemorySubsystem()
 {
-    JS_OPT_ASSERT(size_t(sysconf(_SC_PAGESIZE)) == PageSize);
+    if (size_t(sysconf(_SC_PAGESIZE)) != PageSize)
+        MOZ_CRASH();
 }
 
 void *
 MapAlignedPages(size_t size, size_t alignment)
 {
     JS_ASSERT(size >= alignment);
     JS_ASSERT(size % alignment == 0);
     JS_ASSERT(size % PageSize == 0);
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -6620,17 +6620,17 @@ JS_SetRuntimeThread(JSRuntime *rt)
 #endif
 }
 
 extern JS_NEVER_INLINE JS_PUBLIC_API(void)
 JS_AbortIfWrongThread(JSRuntime *rt)
 {
 #ifdef JS_THREADSAFE
     if (!rt->onOwnerThread())
-        MOZ_Assert("rt->onOwnerThread()", __FILE__, __LINE__);
+        MOZ_CRASH();
 #endif
 }
 
 #ifdef JS_GC_ZEAL
 JS_PUBLIC_API(void)
 JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency)
 {
     const char *env = getenv("JS_GC_ZEAL");
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -36,18 +36,16 @@
 
 /* JS::Value can store a full int32_t. */
 #define JSVAL_INT_BITS          32
 #define JSVAL_INT_MIN           ((int32_t)0x80000000)
 #define JSVAL_INT_MAX           ((int32_t)0x7fffffff)
 
 /************************************************************************/
 
-#define JS_Assert MOZ_Assert
-
 #ifdef __cplusplus
 namespace JS {
 
 /*
  * Protecting non-jsval, non-JSObject *, non-JSString * values from collection
  *
  * Most of the time, the garbage collector's conservative stack scanner works
  * behind the scenes, finding all live values and protecting them from being
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -4509,17 +4509,18 @@ AssertMarkedOrAllocated(const EdgeValue 
 {
     if (!edge.thing || IsMarkedOrAllocated(static_cast<Cell *>(edge.thing)))
         return;
 
     char msgbuf[1024];
     const char *label = edge.label ? edge.label : "<unknown>";
 
     JS_snprintf(msgbuf, sizeof(msgbuf), "[barrier verifier] Unmarked edge: %s", label);
-    MOZ_Assert(msgbuf, __FILE__, __LINE__);
+    MOZ_ReportAssertionFailure(msgbuf, __FILE__, __LINE__);
+    MOZ_CRASH();
 }
 
 static void
 EndVerifyBarriers(JSRuntime *rt)
 {
     AutoLockGC lock(rt);
     AutoHeapSession session(rt);
 
--- a/js/src/jsinfer.cpp
+++ b/js/src/jsinfer.cpp
@@ -317,20 +317,18 @@ types::TypeFailure(JSContext *cx, const 
     JS_vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
     va_end(ap);
 
     JS_snprintf(msgbuf, sizeof(msgbuf), "[infer failure] %s", errbuf);
 
     /* Dump type state, even if INFERFLAGS is unset. */
     cx->compartment->types.print(cx, true);
 
-    /* Always active, even in release builds */
-    MOZ_Assert(msgbuf, __FILE__, __LINE__);
-
-    *((volatile int *)NULL) = 0;  /* Should never be reached */
+    MOZ_ReportAssertionFailure(msgbuf, __FILE__, __LINE__);
+    MOZ_CRASH();
 }
 
 /////////////////////////////////////////////////////////////////////
 // TypeSet
 /////////////////////////////////////////////////////////////////////
 
 TypeSet *
 TypeSet::make(JSContext *cx, const char *name)
--- a/js/src/jsinfer.h
+++ b/js/src/jsinfer.h
@@ -4,16 +4,18 @@
  * 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/. */
 
 /* Definitions related to javascript type inference. */
 
 #ifndef jsinfer_h___
 #define jsinfer_h___
 
+#include "mozilla/Attributes.h"
+
 #include "jsalloc.h"
 #include "jsfriendapi.h"
 #include "jsprvtd.h"
 
 #include "ds/LifoAlloc.h"
 #include "gc/Barrier.h"
 #include "gc/Heap.h"
 #include "js/HashTable.h"
@@ -1257,17 +1259,17 @@ inline const char * InferSpewColor(TypeC
 inline const char * InferSpewColor(TypeSet *types) { return NULL; }
 inline void InferSpew(SpewChannel which, const char *fmt, ...) {}
 inline const char * TypeString(Type type) { return NULL; }
 inline const char * TypeObjectString(TypeObject *type) { return NULL; }
 
 #endif
 
 /* Print a warning, dump state and abort the program. */
-void TypeFailure(JSContext *cx, const char *fmt, ...);
+MOZ_NORETURN void TypeFailure(JSContext *cx, const char *fmt, ...);
 
 } /* namespace types */
 } /* namespace js */
 
 namespace JS {
     template<> class AnchorPermitted<js::types::TypeObject *> { };
 }
 
--- a/js/src/jsutil.cpp
+++ b/js/src/jsutil.cpp
@@ -1,80 +1,52 @@
 /* -*- Mode: C++; tab-width: 4; 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/. */
 
 /* Various JS utility functions. */
 
+#include "mozilla/Assertions.h"
 #include "mozilla/Attributes.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "jstypes.h"
 #include "jsutil.h"
 
 #ifdef WIN32
 #    include "jswin.h"
 #else
 #    include <signal.h>
 #endif
 
 #include "js/TemplateLib.h"
+#include "js/Utility.h"
 
 using namespace js;
 
 #ifdef DEBUG
 /* For JS_OOM_POSSIBLY_FAIL in jsutil.h. */
 JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations = UINT32_MAX;
 JS_PUBLIC_DATA(uint32_t) OOM_counter = 0;
 #endif
 
 /*
  * Checks the assumption that JS_FUNC_TO_DATA_PTR and JS_DATA_TO_FUNC_PTR
  * macros uses to implement casts between function and data pointers.
  */
 JS_STATIC_ASSERT(sizeof(void *) == sizeof(void (*)()));
 
-static JS_NEVER_INLINE void
-CrashInJS()
-{
-    /*
-     * We write 123 here so that the machine code for this function is
-     * unique. Otherwise the linker, trying to be smart, might use the
-     * same code for CrashInJS and for some other function. That
-     * messes up the signature in minidumps.
-     */
-
-#if defined(WIN32)
-    /*
-     * We used to call DebugBreak() on Windows, but amazingly, it causes
-     * the MSVS 2010 debugger not to be able to recover a call stack.
-     */
-    *((volatile int *) NULL) = 123;
-    exit(3);
-#elif defined(__APPLE__)
-    /*
-     * On Mac OS X, Breakpad ignores signals. Only real Mach exceptions are
-     * trapped.
-     */
-    *((volatile int *) NULL) = 123;  /* To continue from here in GDB: "return" then "continue". */
-    raise(SIGABRT);  /* In case above statement gets nixed by the optimizer. */
-#else
-    raise(SIGABRT);  /* To continue from here in GDB: "signal 0". */
-#endif
-}
-
 JS_PUBLIC_API(void)
 JS_Assert(const char *s, const char *file, int ln)
 {
-    fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
-    fflush(stderr);
-    CrashInJS();
+    MOZ_ReportAssertionFailure(s, file, ln);
+    MOZ_CRASH();
 }
 
 #ifdef JS_BASIC_STATS
 
 #include <math.h>
 #include <string.h>
 
 /*
--- a/js/src/jsutil.h
+++ b/js/src/jsutil.h
@@ -372,24 +372,18 @@ inline __attribute__ ((unused)) void MUS
 #endif
 
 /* Crash diagnostics */
 #ifdef DEBUG
 # define JS_CRASH_DIAGNOSTICS 1
 #endif
 #ifdef JS_CRASH_DIAGNOSTICS
 # define JS_POISON(p, val, size) memset((p), (val), (size))
-# define JS_OPT_ASSERT(expr)                                                  \
-    ((expr) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__))
-# define JS_OPT_ASSERT_IF(cond, expr)                                         \
-    ((!(cond) || (expr)) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__))
 #else
 # define JS_POISON(p, val, size) ((void) 0)
-# define JS_OPT_ASSERT(expr) ((void) 0)
-# define JS_OPT_ASSERT_IF(cond, expr) ((void) 0)
 #endif
 
 /* Basic stats */
 #ifdef DEBUG
 # define JS_BASIC_STATS 1
 #endif
 #ifdef JS_BASIC_STATS
 # include <stdio.h>
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -1203,19 +1203,19 @@ StackIter::startOnSegment(StackSegment *
     settleOnNewSegment();
 }
 
 static void JS_NEVER_INLINE
 CrashIfInvalidSlot(StackFrame *fp, Value *vp)
 {
     Value *slots = (Value *)(fp + 1);
     if (vp < slots || vp >= slots + fp->script()->nslots) {
-        JS_ASSERT(false && "About to dereference invalid slot");
-        *(int *)0xbad = 0;  // show up nicely in crash-stats
-        MOZ_Assert("About to dereference invalid slot", __FILE__, __LINE__);
+        MOZ_ASSERT(false, "About to dereference invalid slot");
+        *(volatile int *)0xbad = 0;  // show up nicely in crash-stats
+        MOZ_CRASH();
     }
 }
 
 /*
  * Given that the iterator's current value of fp_ and calls_ (initialized on
  * construction or after operator++ popped the previous scripted/native call),
  * "settle" the iterator on a new StackIter::State value. The goal is to
  * present the client a simple linear sequence of native/scripted calls while
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -130,17 +130,17 @@ nsXPConnect::~nsXPConnect()
 // static
 nsXPConnect*
 nsXPConnect::GetXPConnect()
 {
     // Do a release-mode assert that we're not doing anything significant in
     // XPConnect off the main thread. If you're an extension developer hitting
     // this, you need to change your code. See bug 716167.
     if (!NS_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread()))
-        MOZ_Assert("NS_IsMainThread()", __FILE__, __LINE__);
+        MOZ_CRASH();
 
     if (!gSelf) {
         if (gOnceAliveNowDead)
             return nsnull;
         gSelf = new nsXPConnect();
         if (!gSelf)
             return nsnull;
 
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -3662,17 +3662,17 @@ class XPCPerThreadData
 public:
     // Get the instance of this object for the current thread
     static inline XPCPerThreadData* GetData(JSContext *cx)
     {
         // Do a release-mode assert that we're not doing anything significant in
         // XPConnect off the main thread. If you're an extension developer hitting
         // this, you need to change your code. See bug 716167.
         if (!NS_LIKELY(NS_IsMainThread() || NS_IsCycleCollectorThread()))
-            MOZ_Assert("NS_IsMainThread()", __FILE__, __LINE__);
+            MOZ_CRASH();
 
         if (cx) {
             if (js::GetOwnerThread(cx) == sMainJSThread)
                 return sMainThreadData;
         } else if (sMainThreadData && sMainThreadData->mThread == PR_GetCurrentThread()) {
             return sMainThreadData;
         }
 
deleted file mode 100644
--- a/mfbt/Assertions.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-/* -*- 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 "mozilla/Assertions.h"
-
-/* Implementations of runtime and static assertion macros for C and C++. */
-
-extern "C" {
-
-MOZ_EXPORT_API(void)
-MOZ_Assert(const char* s, const char* file, int ln)
-{
-  MOZ_OutputAssertMessage(s, file, ln);
-  MOZ_CRASH();
-}
-
-}
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -100,59 +100,66 @@
 #endif
 
 #define MOZ_STATIC_ASSERT_IF(cond, expr, reason)  MOZ_STATIC_ASSERT(!(cond) || (expr), reason)
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#if defined(WIN32)
-   /*
-    * We used to call DebugBreak() on Windows, but amazingly, it causes
-    * the MSVS 2010 debugger not to be able to recover a call stack.
-    */
-#  define MOZ_CRASH() \
-     do { \
-       *((volatile int*) NULL) = 123; \
-       exit(3); \
-     } while (0)
-#elif defined(ANDROID)
-   /*
-    * On Android, raise(SIGABRT) is handled asynchronously. Seg fault now
-    * so we crash immediately and capture the current call stack. We need
-    * to specifically use the global namespace in the C++ case.
-    */
+/*
+ * MOZ_CRASH crashes the program, plain and simple, in a Breakpad-compatible
+ * way, in both debug and release builds.
+ *
+ * MOZ_CRASH is a good solution for "handling" failure cases when you're
+ * unwilling or unable to handle them more cleanly -- for OOM, for likely memory
+ * corruption, and so on.  It's also a good solution if you need safe behavior
+ * in release builds as well as debug builds.  But if the failure is one that
+ * should be debugged and fixed, MOZ_ASSERT is generally preferable.
+ */
+#ifdef WIN32
+#  ifdef __cplusplus
+#    define MOZ_CRASH() \
+       do { \
+         *((volatile int*) NULL) = 123; \
+         ::exit(3); \
+       } while (0)
+#  else
+#    define MOZ_CRASH() \
+       do { \
+         *((volatile int*) NULL) = 123; \
+         exit(3); \
+       } while (0)
+#  endif
+#else
 #  ifdef __cplusplus
 #    define MOZ_CRASH() \
        do { \
          *((volatile int*) NULL) = 123; \
          ::abort(); \
        } while (0)
 #  else
 #    define MOZ_CRASH() \
        do { \
          *((volatile int*) NULL) = 123; \
          abort(); \
        } while (0)
 #  endif
-#else
-#  define MOZ_CRASH() \
-     do { \
-       *((volatile int*) NULL) = 123; \
-       raise(SIGABRT);  /* In case above statement gets nixed by the optimizer. */ \
-     } while (0)
 #endif
 
-
-extern MFBT_API(void)
-MOZ_Assert(const char* s, const char* file, int ln);
-
+/*
+ * Prints |s| as an assertion failure (using file and ln as the location of the
+ * assertion) to the standard debug-output channel.
+ *
+ * Usually you should use MOZ_ASSERT instead of this method.  This method is
+ * primarily for internal use in this header, and only secondarily for use in
+ * implementing release-build assertions.
+ */
 static MOZ_ALWAYS_INLINE void
-MOZ_OutputAssertMessage(const char* s, const char *file, int ln)
+MOZ_ReportAssertionFailure(const char* s, const char* file, int ln)
 {
 #ifdef ANDROID
   __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert",
                       "Assertion failure: %s, at %s:%d\n", s, file, ln);
 #else
   fprintf(stderr, "Assertion failure: %s, at %s:%d\n", s, file, ln);
   fflush(stderr);
 #endif
@@ -194,25 +201,25 @@ MOZ_OutputAssertMessage(const char* s, c
  * MOZ_ASSERT has no effect in non-debug builds.  It is designed to catch bugs
  * *only* during debugging, not "in the field".
  */
 #ifdef DEBUG
    /* First the single-argument form. */
 #  define MOZ_ASSERT_HELPER1(expr) \
      do { \
        if (!(expr)) { \
-         MOZ_OutputAssertMessage(#expr, __FILE__, __LINE__); \
+         MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \
          MOZ_CRASH(); \
        } \
      } while (0)
    /* Now the two-argument form. */
 #  define MOZ_ASSERT_HELPER2(expr, explain) \
      do { \
        if (!(expr)) { \
-         MOZ_OutputAssertMessage(#expr " (" explain ")", __FILE__, __LINE__); \
+         MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \
          MOZ_CRASH(); \
        } \
      } while (0)
    /* And now, helper macrology up the wazoo. */
    /*
     * Count the number of arguments passed to MOZ_ASSERT, very carefully
     * tiptoeing around an MSVC bug where it improperly expands __VA_ARGS__ as a
     * single token in argument lists.  See these URLs for details:
@@ -253,29 +260,48 @@ MOZ_OutputAssertMessage(const char* s, c
      do { \
        if (cond) \
          MOZ_ASSERT(expr); \
      } while (0)
 #else
 #  define MOZ_ASSERT_IF(cond, expr)  do { } while (0)
 #endif
 
-/* MOZ_NOT_REACHED_MARKER() expands (in compilers which support it) to an
- * expression which states that it is undefined behavior for the compiler to
- * reach this point. Most code should probably use the higher level
- * MOZ_NOT_REACHED (which expands to this when appropriate).
+/*
+ * MOZ_NOT_REACHED_MARKER() expands to an expression which states that it is
+ * undefined behavior for execution to reach this point.  No guarantees are made
+ * about what will happen if this is reached at runtime.  Most code should
+ * probably use the higher level MOZ_NOT_REACHED, which uses this when
+ * appropriate.
  */
 #if defined(__clang__)
 #  define MOZ_NOT_REACHED_MARKER() __builtin_unreachable()
 #elif defined(__GNUC__)
+   /*
+    * __builtin_unreachable() was implemented in gcc 4.5.  If we don't have
+    * that, call a noreturn function; abort() will do nicely.  Qualify the call
+    * in C++ in case there's another abort() visible in local scope.
+    */
 #  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
 #    define MOZ_NOT_REACHED_MARKER() __builtin_unreachable()
+#  else
+#    ifdef __cplusplus
+#      define MOZ_NOT_REACHED_MARKER() ::abort()
+#    else
+#      define MOZ_NOT_REACHED_MARKER() abort()
+#    endif
 #  endif
 #elif defined(_MSC_VER)
 #  define MOZ_NOT_REACHED_MARKER() __assume(0)
+#else
+#  ifdef __cplusplus
+#    define MOZ_NOT_REACHED_MARKER() ::abort()
+#  else
+#    define MOZ_NOT_REACHED_MARKER() abort()
+#  endif
 #endif
 
 /*
  * MOZ_NOT_REACHED(reason) indicates that the given point can't be reached
  * during execution: simply reaching that point in execution is a bug.  It takes
  * as an argument an error message indicating the reason why that point should
  * not have been reachable.
  *
@@ -285,49 +311,24 @@ MOZ_OutputAssertMessage(const char* s, c
  *     if (node.isTrue())
  *       handleTrueLiteral();
  *     else if (node.isFalse())
  *       handleFalseLiteral();
  *     else
  *       MOZ_NOT_REACHED("boolean literal that's not true or false?");
  *   }
  */
-#if defined(MOZ_NOT_REACHED_MARKER)
-#  if defined(DEBUG)
-#    define MOZ_NOT_REACHED(reason)  do { \
-                                       MOZ_Assert(reason, __FILE__, __LINE__); \
-                                       MOZ_NOT_REACHED_MARKER();        \
-                                     } while (0)
-#  else
-#    define MOZ_NOT_REACHED(reason)  MOZ_NOT_REACHED_MARKER()
-#  endif
+#if defined(DEBUG)
+#  define MOZ_NOT_REACHED(reason) \
+     do { \
+       MOZ_ASSERT(false, reason); \
+       MOZ_NOT_REACHED_MARKER(); \
+     } while (0)
 #else
-#  if defined(__GNUC__)
-     /*
-      * On older versions of gcc we need to call a noreturn function to mark the
-      * code as unreachable. Since what we want is an unreachable version of
-      * MOZ_Assert, we use an asm label
-      * (http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Asm-Labels.html) to create
-      * a new declaration to the same symbol. MOZ_ASSERT_NR should only be
-      * used via this macro, as it is a very specific hack to older versions of
-      * gcc.
-      */
-#    define MOZ_GETASMPREFIX2(X) #X
-#    define MOZ_GETASMPREFIX(X) MOZ_GETASMPREFIX2(X)
-#    define MOZ_ASMPREFIX MOZ_GETASMPREFIX(__USER_LABEL_PREFIX__)
-     extern MOZ_NORETURN MFBT_API(void)
-     MOZ_ASSERT_NR(const char* s, const char* file, int ln) \
-       asm (MOZ_ASMPREFIX "MOZ_Assert");
-
-#    define MOZ_NOT_REACHED(reason)    MOZ_ASSERT_NR(reason, __FILE__, __LINE__)
-#  elif defined(DEBUG)
-#    define MOZ_NOT_REACHED(reason)    MOZ_Assert(reason, __FILE__, __LINE__)
-#  else
-#    define MOZ_NOT_REACHED(reason)    ((void)0)
-#  endif
+#  define MOZ_NOT_REACHED(reason)  MOZ_NOT_REACHED_MARKER()
 #endif
 
 /*
  * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided
  * expression, in debug builds and in release builds both.  Then, in debug
  * builds only, the value of the expression is asserted either true or false
  * using MOZ_ASSERT.
  */
--- a/mfbt/sources.mk
+++ b/mfbt/sources.mk
@@ -3,17 +3,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 ifndef MFBT_ROOT
 $(error Before including this file, you must define MFBT_ROOT to point to \
 the MFBT source directory)
 endif
 
 CPPSRCS += \
-  Assertions.cpp \
   HashFunctions.cpp \
   $(NULL)
 
 # Imported double-conversion sources.
 VPATH += $(MFBT_ROOT)/double-conversion \
   $(NULL)
 
 CPPSRCS += \
--- a/mozglue/linker/Makefile.in
+++ b/mozglue/linker/Makefile.in
@@ -18,21 +18,18 @@ CPPSRCS = \
   Zip.cpp \
   $(NULL)
 
 ifndef MOZ_OLD_LINKER
 HOST_PROGRAM = szip
 
 HOST_CPPSRCS = \
   szip.cpp \
-  Assertions.cpp \
   $(NULL)
 
-VPATH += $(topsrcdir)/mfbt
-
 HOST_LIBS = -lz
 
 CPPSRCS += \
   ElfLoader.cpp \
   CustomElf.cpp \
   Mappable.cpp \
   SeekableZStream.cpp \
   $(NULL)
--- a/webapprt/mac/Makefile.in
+++ b/webapprt/mac/Makefile.in
@@ -17,21 +17,16 @@ PROGRAM = webapprt-stub$(BIN_SUFFIX)
 
 CMMSRCS = webapprt.mm
 
 # Don't create a dependency on mozglue, which is impossible (difficult?)
 # to dynamically link into our executable, as we copy it to arbitrary locations.
 MOZ_GLUE_LDFLAGS =
 MOZ_GLUE_PROGRAM_LDFLAGS =
 
-# mozglue uses mfbt's Assertions.cpp, which provides MOZ_ASSERT, which lots
-# of code in libxpcom uses, so we have to do the same.
-VPATH += $(topsrcdir)/mfbt
-CPPSRCS = Assertions.cpp
-
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
 LOCAL_INCLUDES += -I$(DEPTH)/build
 
 DEFINES += -DXPCOM_GLUE
 STL_FLAGS=
 
--- a/webapprt/win/Makefile.in
+++ b/webapprt/win/Makefile.in
@@ -15,21 +15,16 @@ PROGRAM   = webapprt-stub$(BIN_SUFFIX)
 CPPSRCS   = webapprt.cpp
 
 # Statically link against the CRT
 USE_STATIC_LIBS = 1
 # Don't create a dependency on mozglue, which is impossible (difficult?)
 # to dynamically link into our executable, as we copy it to arbitrary locations.
 MOZ_GLUE_LDFLAGS =
 
-# mozglue uses mfbt's Assertions.cpp, which provides MOZ_ASSERT, which lots
-# of code in libxpcom uses, so we have to do the same.
-VPATH += $(topsrcdir)/mfbt
-CPPSRCS += Assertions.cpp
-
 LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/base
 LOCAL_INCLUDES += -I$(topsrcdir)/xpcom/build
 LOCAL_INCLUDES += -I$(DEPTH)/build
 
 DEFINES += -DXPCOM_GLUE
 STL_FLAGS=
 
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -163,17 +163,17 @@ PRThread* gCycleCollectorThread = nsnull
 
 // If true, always log cycle collector graphs.
 const bool gAlwaysLogCCGraphs = false;
 
 MOZ_NEVER_INLINE void
 CC_AbortIfNull(void *ptr)
 {
     if (!ptr)
-        MOZ_Assert("ptr was null", __FILE__, __LINE__);
+        MOZ_CRASH();
 }
 
 // Various parameters of this collector can be tuned using environment
 // variables.
 
 struct nsCycleCollectorParams
 {
     bool mDoNothing;