__attribute__((cleanup(function)) versus try/finally

Jason Merrill jason@redhat.com
Thu May 8 21:18:00 GMT 2003


On 08 May 2003 12:47:09 -0700, Mark Mitchell <mark@codesourcery.com> wrote:

> I agree that all of this is parenthetical; the key question is whether C
> needs to have EH constructs or not, not which particular constructs they
> are.

I think it does.  If we want to be able to interleave pthread cleanups from
C and C++ exception handling, then the C code needs to interface with the
EH runtime somehow; the obvious way to accomplish this is to use EH for
cleanups in threaded C code.

For a target that uses sjlj exceptions, this can have exactly the same
overhead as the old mechanism.

For a target that uses unwind tables, the normal case should be slightly
faster than in the old mechanism, since we don't need to call the pthread
library to register the cleanup.  Code size should be similar.  The main
overhead is the unwind tables, which just take up disk space unless they're
needed.  And there's more and more precedent for always emitting unwind
tables (ia64, x86-64).

I don't see any compelling reason to consider inventing a new mechanism.

Jason



More information about the Gcc mailing list