Bug 695171. Make our operator new throw std::bad_alloc. r=cjones
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 18 Oct 2011 14:19:23 -0400
changeset 79065 2606bc44cb7cceeafe055da65136e1f9a4d49052
parent 79064 344e0e0cabe451fd8d99f0b5729d8cd3b7121fa9
child 79066 81fdcdc7368d618d238fd9f107ada176a050e0ba
push id247
push usertim.taubert@gmx.de
push dateSat, 22 Oct 2011 19:08:15 +0000
treeherderfx-team@72bb20c484a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs695171, 10895
milestone10.0a1
Bug 695171. Make our operator new throw std::bad_alloc. r=cjones If new doesn't throw bad_alloc the compiler emits a null check after to avoid calling the constructor. http://llvm.org/bugs/show_bug.cgi?id=10895 Adding throw(std::bad_alloc) shaves 57KB of .text off a gcc mac build and 61KB off a clang build.
memory/mozalloc/mozalloc.h
--- a/memory/mozalloc/mozalloc.h
+++ b/memory/mozalloc/mozalloc.h
@@ -209,25 +209,23 @@ MOZALLOC_EXPORT void* moz_valloc(size_t 
 
 #if defined(ANDROID) || defined(_MSC_VER)
 /*
  * Android doesn't fully support exceptions, so its <new> header
  * has operators that don't specify throw() at all. Also include MSVC
  * to suppress build warning spam (bug 578546).
  */
 #define MOZALLOC_THROW_IF_HAS_EXCEPTIONS /**/
+#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS
 #else
 #define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw()
+#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS throw(std::bad_alloc)
 #endif
 
-#ifdef MOZ_CPP_EXCEPTIONS
-#define MOZALLOC_THROW_BAD_ALLOC throw(std::bad_alloc)
-#else
-#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_IF_HAS_EXCEPTIONS
-#endif
+#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS
 
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE
 void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC
 {
     return moz_xmalloc(size);
 }
 
 MOZALLOC_EXPORT_NEW MOZALLOC_INLINE