* Exception handling information
@ 2009-08-21 6:38 SD
2009-08-21 6:45 ` Dave Korn
0 siblings, 1 reply; 6+ messages in thread
From: SD @ 2009-08-21 6:38 UTC (permalink / raw)
To: gcc
Hello,
After searching this list it appears that with recent gcc (I am using gcc
4.1), C++ exception handling has zero overhead (unless an exception actually
happens)
Where can I find more information on how exception handling is done and if
this zero overhead property is always true.
I looked a a couple of manuals on the gcc homepage but could not find anything.
Thanks a lot!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exception handling information
2009-08-21 6:38 Exception handling information SD
@ 2009-08-21 6:45 ` Dave Korn
2009-08-21 7:48 ` Ian Lance Taylor
0 siblings, 1 reply; 6+ messages in thread
From: Dave Korn @ 2009-08-21 6:45 UTC (permalink / raw)
To: SD; +Cc: gcc
SD wrote:
> Hello,
>
> After searching this list it appears that with recent gcc (I am using gcc
> 4.1), C++ exception handling has zero overhead (unless an exception actually
> happens)
>
> Where can I find more information on how exception handling is done and if
> this zero overhead property is always true.
There are two EH mechanisms in gcc, one using a Dwarf-2 table-driven
implementation, the other based around use of setjmp-longjmp. Which one is
used depends on the --en/disable-sjlj-exceptions flag at configure time. The
DW2 version has zero overhead in terms of execution time when no exceptions
are thrown, but adds a noticeable amount of memory usage for the eh tables.
The sjlj version incurs a time penalty every time it enters an EH region, and
probably incurs more stack usage doing so, but doesn't have all the big static
data tables that DW2 has.
> I looked a a couple of manuals on the gcc homepage but could not find anything.
Don't think there's much about sjlj except in the gcc sources themselves.
There's a page about DW2 EH on the wiki:
http://gcc.gnu.org/wiki/Dwarf2EHNewbiesHowto
cheers,
DaveK
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exception handling information
2009-08-21 6:45 ` Dave Korn
@ 2009-08-21 7:48 ` Ian Lance Taylor
2009-08-25 18:43 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2009-08-21 7:48 UTC (permalink / raw)
To: Dave Korn; +Cc: SD, gcc
Dave Korn <dave.korn.cygwin@googlemail.com> writes:
> The
> DW2 version has zero overhead in terms of execution time when no exceptions
> are thrown, but adds a noticeable amount of memory usage for the eh tables.
For the extremely picky (and who among us is not extremely picky) there
is still some overhead in the dwarf2 version. We do not have good
separation between hot and cold code, which means that exception
handling code occupies pages which otherwise contain useful instructions
and in some cases even occupies useful instruction cache lines.
Ironically, -freorder-blocks-and-partition, which seems tailor-made to
fix this, is disabled when exception handling is used.
Also, when exception handling is enabled, it becomes impossible to do
certain types of instruction reordering. While this has only a mild
effect on x86 with its out-of-order execution, it has a noticeable
effect on in-order architectures, particularly those with delay slots.
Look for all the uses of can_throw in the compiler to see the effect.
This effect is more significant with -fasynchronous-unwind-tables.
Ian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exception handling information
2009-08-21 7:48 ` Ian Lance Taylor
@ 2009-08-25 18:43 ` Jason Merrill
2009-08-25 20:11 ` Jason Merrill
2009-08-25 22:25 ` Ian Lance Taylor
0 siblings, 2 replies; 6+ messages in thread
From: Jason Merrill @ 2009-08-25 18:43 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: Dave Korn, SD, gcc@gcc.gnu.org >> GCC
On 08/20/2009 11:36 PM, Ian Lance Taylor wrote:
> Ironically, -freorder-blocks-and-partition, which seems tailor-made to
> fix this, is disabled when exception handling is used.
This is no longer true:
2009-08-07 Jakub Jelinek <jakub@redhat.com>
...
* opts.c: Include except.h.
(decode_options): Allow -freorder-blocks-and-partition with
exceptions, unless SJLJ or TARGET_UNWIND_INFO.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exception handling information
2009-08-25 18:43 ` Jason Merrill
@ 2009-08-25 20:11 ` Jason Merrill
2009-08-25 22:25 ` Ian Lance Taylor
1 sibling, 0 replies; 6+ messages in thread
From: Jason Merrill @ 2009-08-25 20:11 UTC (permalink / raw)
To: gcc; +Cc: Dave Korn, SD, gcc@gcc.gnu.org >> GCC
On 08/20/2009 11:36 PM, Ian Lance Taylor wrote:
> Ironically, -freorder-blocks-and-partition, which seems tailor-made to
> fix this, is disabled when exception handling is used.
This is no longer true:
2009-08-07 Jakub Jelinek <jakub@redhat.com>
...
* opts.c: Include except.h.
(decode_options): Allow -freorder-blocks-and-partition with
exceptions, unless SJLJ or TARGET_UNWIND_INFO.
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Exception handling information
2009-08-25 18:43 ` Jason Merrill
2009-08-25 20:11 ` Jason Merrill
@ 2009-08-25 22:25 ` Ian Lance Taylor
1 sibling, 0 replies; 6+ messages in thread
From: Ian Lance Taylor @ 2009-08-25 22:25 UTC (permalink / raw)
To: Jason Merrill; +Cc: Dave Korn, SD, gcc@gcc.gnu.org >> GCC
Jason Merrill <jason@redhat.com> writes:
> On 08/20/2009 11:36 PM, Ian Lance Taylor wrote:
>> Ironically, -freorder-blocks-and-partition, which seems tailor-made to
>> fix this, is disabled when exception handling is used.
>
> This is no longer true:
>
> 2009-08-07 Jakub Jelinek <jakub@redhat.com>
> ...
> * opts.c: Include except.h.
> (decode_options): Allow -freorder-blocks-and-partition with
> exceptions, unless SJLJ or TARGET_UNWIND_INFO.
Thanks. That is very good to hear, and it means that somebody needs to
update the documentation.
Ian
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-08-25 16:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-21 6:38 Exception handling information SD
2009-08-21 6:45 ` Dave Korn
2009-08-21 7:48 ` Ian Lance Taylor
2009-08-25 18:43 ` Jason Merrill
2009-08-25 20:11 ` Jason Merrill
2009-08-25 22:25 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).