Re: C++ exception implementation (tangent)
--Z0mFw3+mXTC5ycVe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Friday, 4 February 2005 at 14:08:46 +0100, Joerg Sonnenberger wrote:
> On Thu, Feb 03, 2005 at 09:32:29PM -0500, David Cuthbert wrote:
>> Greg 'groggy' Lehey wrote:
>>> You'll notice that [C++ exceptions are] implemented with
>>> setjmp()/longjmp().
>>
>> Is this the current state of g++?
I knew somebody was going to pick up on this, and I should have
researched more carefully. You're probably right (I still haven't
checked; been pretty busy lately): my information is about 10 years
old.
> The current GCC C++ frontend supports multiple mechanisms for
> exception handling, setjmp/longjmp is one of them.
OK, this seems plausible.
>> I thought -- perhaps incorrectly -- that EDG-based compilers used lookup
>> tables based on the PC. This imposes no performance hit in the cases
>> where the exception isn't invoked -- it's popular for this reason. I
>> thought that g++ was heading in this direction, but I haven't been
>> following the changes terribly closely.
>
> I'm pretty sure this is exactly the case. IIRC there's still a minor
> performance penalty for exception setup, but it's very small compared
> to the older approach.
I'd be interested in details there. My understanding is that setjmp
saves processor registers in a jmpbuf, and that longjmp restores
them. Neither sounds exactly high-overhead, certainly less than a
chain of function returns.
Greg
--
Finger grog@lemis.com for PGP public key.
See complete headers for address and phone numbers.
--Z0mFw3+mXTC5ycVe
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (FreeBSD)
iD8DBQFCEoHiIubykFB6QiMRAj6LAJ49Qhwag06cn6OkNdfTzJUUGjzDswCfYG5e
gEWpK2z7jL8zIEMZRbY1ZgM=
=FZzE
-----END PGP SIGNATURE-----
--Z0mFw3+mXTC5ycVe--
討論串 (同標題文章)
完整討論串 (本文為第 3 之 4 篇):