Last Comment Bug 695171 - Make our operator new throw bad_alloc
: Make our operator new throw bad_alloc
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: General (show other bugs)
: unspecified
: x86 Mac OS X
: -- normal (vote)
: mozilla10
Assigned To: Jeff Muizelaar [:jrmuizel]
:
:
Mentors:
Depends on:
Blocks:
  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:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
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 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. http://llvm.org/bugs/show_bug.cgi?id=10895

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 :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 Jeff Muizelaar [:jrmuizel] 2011-10-17 14:42:03 PDT
I don't see how they are more lies than before.
Comment 3 :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/Nightly2.app/Contents/MacOS/XUL
24739840	2547712	0	24514560	51802112	3167000	obj-ff-opt/dist/Nightly.app/Contents/MacOS/XUL
Comment 4 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 Marco Bonardo [::mak] 2011-10-21 08:34:12 PDT
https://hg.mozilla.org/mozilla-central/rev/2606bc44cb7c

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