Last Comment Bug 695171 - Make our operator new throw bad_alloc
: Make our operator new throw bad_alloc
Product: Core
Classification: Components
Component: General (show other bugs)
: unspecified
: x86 Mac OS X
-- normal (vote)
: mozilla10
Assigned To: Jeff Muizelaar [:jrmuizel]
Depends on:
  Show dependency treegraph
Reported: 2011-10-17 14:28 PDT by Jeff Muizelaar [:jrmuizel]
Modified: 2011-10-21 08:34 PDT (History)
3 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

add throw(std::bad_alloc) (1.07 KB, patch)
2011-10-17 14:28 PDT, Jeff Muizelaar [:jrmuizel]
cjones.bugs: review+
Details | Diff | Splinter Review

Description User image Jeff Muizelaar [:jrmuizel] 2011-10-17 14:28:23 PDT
Created attachment 567579 [details] [diff] [review]
add throw(std::bad_alloc)

If new doesn't throw bad_alloc the compiler emits a null check after to avoid calling the constructor.

Adding throw(std::bad_alloc) shaves 57KB of .text off a gcc mac build. I expect it would take more off the clang build.
Comment 1 User image :Ehsan Akhgari 2011-10-17 14:37:35 PDT
I'd rename the macros since the names after this patch would just be lies.
Comment 2 User image Jeff Muizelaar [:jrmuizel] 2011-10-17 14:42:03 PDT
I don't see how they are more lies than before.
Comment 3 User image :Ehsan Akhgari 2011-10-18 07:21:10 PDT
As promised to Jeff, I measured how much of a size change this caused with Mac.  The answer is 0.

__TEXT	__DATA	__OBJC	others	dec	hex
24739840	2547712	0	24514560	51802112	3167000	obj-ff-opt/dist/
24739840	2547712	0	24514560	51802112	3167000	obj-ff-opt/dist/
Comment 4 User image Jeff Muizelaar [:jrmuizel] 2011-10-18 08:28:52 PDT
Fortunately, my results don't match Ehsan's.

/tmp$ size XUL-pre 
__TEXT	__DATA	__OBJC	others	dec	hex
24637440	2539520	0	24469504	51646464	3141000
/tmp$ size XUL-post 
__TEXT	__DATA	__OBJC	others	dec	hex
24576000	2539520	0	24469504	51585024	3132000

Which gives a savings of 61KB
Comment 5 User image Marco Bonardo [::mak] 2011-10-21 08:34:12 PDT

Note You need to log in before you can comment on or make changes to this bug.