Bug 822431 - Use MOZ_UNLIKELY in MOZ_ASSERT. r=waldo
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 19 Apr 2013 16:20:35 -0700
changeset 129394 87ac8643d3b35329df34451272ae87f5053c0eaf
parent 129393 6953e922b5c7a7d51ba2d8a1fc6fd8e3271b7eed
child 129395 1d3fb4987df795d8fcde1fe070b3f73025cb3484
push id24572
push userphilringnalda@gmail.com
push dateSun, 21 Apr 2013 16:31:35 +0000
treeherdermozilla-central@a09acc1ed635 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs822431
milestone23.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 822431 - Use MOZ_UNLIKELY in MOZ_ASSERT. r=waldo
mfbt/Assertions.h
--- a/mfbt/Assertions.h
+++ b/mfbt/Assertions.h
@@ -5,16 +5,17 @@
 
 /* Implementations of runtime and static assertion macros for C and C++. */
 
 #ifndef mozilla_Assertions_h_
 #define mozilla_Assertions_h_
 
 #include "mozilla/Attributes.h"
 #include "mozilla/Compiler.h"
+#include "mozilla/Likely.h"
 
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef WIN32
    /*
     * TerminateProcess and GetCurrentProcess are defined in <winbase.h>, which
     * further depends on <windef.h>.  We hardcode these few definitions manually
@@ -243,25 +244,25 @@ MOZ_ReportAssertionFailure(const char* s
  *
  * 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)) { \
+       if (MOZ_UNLIKELY(!(expr))) { \
          MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \
          MOZ_CRASH(); \
        } \
      } while (0)
    /* Now the two-argument form. */
 #  define MOZ_ASSERT_HELPER2(expr, explain) \
      do { \
-       if (!(expr)) { \
+       if (MOZ_UNLIKELY(!(expr))) { \
          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