This is the mail archive of the gcc-patches@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: [patch] Move loop structures to gc memory


Zdenek Dvorak <rakdver@kam.mff.cuni.cz> writes:

> > > On May 14, 2007, at 11:12 AM, Ian Lance Taylor wrote:
> > Using ggc_free with GC just puts us on the road back to the problems
> > which led us to introduce GC in the first place: we didn't track our
> > memory allocations properly, so we got confused and got weird crashes.
> > We introduced GC so that it didn't matter whether we tracked our
> > memory allocations properly or not.  There was no other reason for GC.
> > When we use ggc_free, we lose the whole point of having GC.  It just
> > does not make sense.
> 
> well, sort of.  There are some structures that are hard to keep track of
> (trees and rtl, and maybe a few others), and I think it is OK to have gc
> for them.  I guess most of the other thinks that are currently kept in
> GC should not be, but it would be a bit hard to keep track of all GC
> roots if we moved them out.  Using ggc_free of course is not a nice
> solution, but not using it for structures for that we are sure that they
> are no longer reachable is wasteful.

I think that correctly keeping track of the various GC roots is
precisely as hard as correctly using ggc_free.  Both are cases where
we need to correctly determine whether we have a live pointer into GC
memory.  And indeed we've had a series of bugs over the years in which
static variables were not correctly annotated as being GC roots, just
as we've had several bugs in which ggc_free was used incorrectly.

Setting a pointer to NULL is always safe.

Ian


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