Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-02-12 18:58:38


Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> writes:

> On 2/12/06, David Abrahams <dave_at_[hidden]> wrote:
>
> [snip]
>
>> > and AFAIK it's impossible to implement zero-overhead stack unwinding
>> > (you're the exception expert, so please correct me if I'm wrong).
>>
>> If by "zero-overhead stack unwinding" you mean exception handling that
>> has no speed cost unless an exception is thrown, then consider
>> yourself corrected.
>
> This means that it is impossible to implement stack unwind with no
> speed cost when an exception is not thrown?

What do you mean "implement stack unwind?" If an exception is not
thrown, there is no unwinding, so naturally unwinding has no cost when
no exception is thrown.

> I'm definitely not an expert, not even a newbie in this field
> probably, but I thought it was possble.
> Or did I misunderstood your statement?

I think you misunderstood.

It is possible to implement EH so that there is no cost at runtime
until an exception is thrown. When compared with code that implements
the same error handling functionality by means other than exceptions,
the code using exceptions can even run faster when no error is
detected. In practice we've observed code using EH running about
1000x slower when an error /is/ detected, but that's expected to be a
very rare occurrence. A good EH implementation optimizes for the
no-error case.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk