views:

36

answers:

1

I mean in the current implementation of clang or the gcc version.

C++ and Java guys always tell me that exceptions do not cost any performance unless they are thrown. Is the same true for Objective-C?

+1  A: 

According to some 2007 release notes for the Objective-C runtime in Mac OS X v10.5, they have re-written the 64bit implementation of Objective-C exceptions to provide "zero-cost" try blocks and interoperability with C++.

Apparently, these "zero-cost" try blocks incur no time penalty when entering a try, unlike it's 32-bit counterpart which must call setjmp() and other functions. Apparently throwing them is "much more expensive".

This is the only bit of information I can find in Apple's release notes so I would have to assume that this still applies in todays runtimes, and as such, 32bit exceptions = expensive, 64-bit exceptions = "zero-cost"

Daniel Frear