This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cost of having try-catch statements?


Martin Egholm Nielsen wrote:
> Hi there,
> 
> I was wondering: Is there any significant cost in having "unused" 
> try-catches in my code?
> That is, I have a method that 99.99% of the times invoked never throws a 
> given exception. However, in case it does, I need to log it...

You have not mentioned the platform you have in mind.

On almost all of the major platforms, GCC uses DWARF-2
unwind information based exception handling ("range tables")
which involves almost no performance overhead in the
"normal" case.

GCC builds for Windows from MinGW (www.mingw.org) however
use SJLJ (setjmp-longjmp) based exception handling which
does involve an overhead even in the "normal" case. This
is needed at the moment to correctly unwind over a Windows
events callback stack. I am not sure, but probably Cygwin
builds are also built like this.

You can find an excellent overview of these approaches
in this paper:

http://www.usenix.org/events/osdi2000/wiess2000/full_papers/dinechin/dinechin_html/

Ranjit.

-- 
Ranjit Mathew          Email: rmathew AT gmail DOT com

Bangalore, INDIA.      Web: http://ranjitmathew.tripod.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]