This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bad dead code detection ?


On 05-Jul-2003, David Jobet <david.jobet@free.fr> wrote:
> Le Samedi 5 Juillet 2003 00:26, Fergus Henderson a ?crit :
> > On 25-Jun-2003, David Jobet <david.jobet@free.fr> wrote:
> > > I try to write an exception handling library, and I'm forced to play with
> > > gcc inline assembly.
> >
> > I don't see why.  For an example of an exception handling
> > library which does not use any inline assembly, see
> > <http://www.cs.mu.oz.au/~fjh/CXCPT/>.
> 
> Writing an exception handling library with stjmp/longjmp is quite easy. But it
> does not support all the semantic I'd like to bring in : destruction of live 
> local variables.

If you want to be able to traverse the live local variables on the C
stack, you can do it by keeping a "shadow stack"; see my paper "Accurate
garbage collection in an uncooperative environment" [1].  That paper
discusses GC, not exception handling, but the shadow stack approach
described could just as easily be used to unwind the stack for exception
handling.  However, such an approach will have substantial overhead,
so it's probably not what you're looking for.

> What I want to do is to offer the same kind of semantic c++ offers. 
> Using setjmp/longjmp is too much of an overhead. 

I suggest that you compile to C++ rather than compiling to C.
Then you can just use C++'s exception handling features.


References
----------
[1] Fergus Henderson, 
    "Accurate garbage collection in an uncooperative environment".
    Proceedings of the 2002 International Symposium on Memory Management,
    Berlin, Germany, June 2002, pages 150-156.
<http://www.cs.mu.oz.au/research/mercury/information/papers.html#high_level_gc>

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]