Re: How expensive are exceptions?
on Thu Jun 14 2007, Walter Bright <walter-AT-digitalmars-nospamm.com> wrote:
at least on Windows, having EH enabled does add some cost to
successful paths. The reason is because EH on x86 Windows is
implemented using Microsoft's "Structured Exception Handling" scheme
which requires:
1) a special stack frame
2) incrementing/decrementing a special 'scope index' variable when going
in and out of try blocks
It does not have to be implemented that way on Windows. That's just
how Microsoft did it on 32-bit windows, and several vendors naturally
followed suit. I don't believe Cygwin GCC integrates with SEH (though
it might - their mechanism is just about as slow as SEH), and
Metrowerks on windows had an option to select "zero-overhead" or
"SEH-compatible" exception handling.
I think this cost was reduced for SEH on x64,
At least according to the Visual C++ devs, they implemented a
range-table based approach for x64.
at the cost of much slower execution of catch blocks.
Slower unwinding, actually. The catch block itself is just regular
C++ code.
While the modern trend is to accept slow exception paths, such does
preclude using the hardware to implement write barriers in gc
implementations.
Care to say more? I don't follow that.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
The Astoria Seminar ==> http://www.astoriaseminar.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]