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.

--HG--
extra : rebase_source : 098c1f5df472bcc572b812fe5d4f12c8eadf14d2
This commit is contained in:
Jeff Muizelaar 2011-10-18 14:19:23 -04:00
parent c96a172091
commit 29cbea0da7

View File

@ -214,15 +214,13 @@ MOZALLOC_EXPORT void* moz_valloc(size_t size)
* 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