This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Move loop structures to gc memory
Michael Matz <matz@suse.de> writes:
> > > First, I don't really understand to what bug Ian refers to, so, I
> > > couldn't fix it, even if I wanted to. Second, I'd predict at this
> > > point, that even if the bug were fixed, it would not be as fast as
> > > ggc_free. If it isn't faster, I don't see what relevance it has to
> > > the two quoted above. And lastly, I don't think this issue was
> > > contained in either of those two messages, just for the record.
> >
> > The bug, if it is indeed a bug, is that the set of GC roots is static.
> > If you want to have a dynamically allocated pointer into GC memory,
> > you must put that pointer into GC memory itself.
> >
> > Fixing that, and using it for the loop structures, would not be slower
> > than using ggc_free.
>
> But it also wouldn't be different the slightest. You just move the
> problem of when to call ggc_free to when to remove that pointer from the
> set of additional roots. Unless of course you don't want to remove them
> once allocated. But that would be wasteful again, just like every memory
> leak.
No, for example, we could enhance the GTY markings to say "this field
in cfun points to a linked list of structs, linked by this field. For
each instance of the struct, these fields in the struct point into GC
memory." Then a list of, e.g., loop structs would automatically
become GC roots with no additional work required. That is simple and
safe.
Ian