This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Cost of having try-catch statements?
- From: Ranjit Mathew <rmathew at gmail dot com>
- To: Martin Egholm Nielsen <martin at egholm-nielsen dot dk>
- Cc: GCJ <java at gcc dot gnu dot org>
- Date: Wed, 11 Aug 2004 10:14:37 +0530
- Subject: Re: Cost of having try-catch statements?
- References: <cfan45$ghk$1@sea.gmane.org>
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/