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: ggc_del_root


Mark Mitchell <mark@codesourcery.com> writes:

> I see that ggc_del_root is gone as part of the gengtype conversion.
> 
> I don't see, now, how to introduce GC roots for a limited period of
> time.  You can, of course, keep some global list of things and mark
> that for gengtype.  But the last thing we want to do is create more
> global variables.
> 
> Concretely, what I want to do is:
> 
>   x = new_something ();
>   ggc_add_root (x);
>   /* Long-running computation involving x. */
>   gcc_del_root (x);
> 
> Do you have any objection if I restore this entry point?

Annoyingly, I only yesterday found out that I hadn't committed this
documentation change to ggc.h before doing the merge:

! /* Manipulate global roots that are needed between calls to gc.
!    THIS ROUTINE IS OBSOLETE, do not use it for new code.  */
  extern void ggc_add_root              PARAMS ((void *base, int nelt,
                                                 int size, void (*)(void *)));

I don't mind ggc_del_root, but I do mind new ggc_add_root invocations.
Also, all the routines that you might pass to ggc_add_root in the
fourth parameter are either obsolete (in the case of ggc_mark_rtx), or
considered private to the gengtype machinery (in the case of
gt_ggc_m_*).

> If you do object, what do you suggest I do instead?

If we can't live without ggc_add_root functionality, the way it needs
to work is this:

void do_with_something (void)
{
   GTY((local ("do_with_something_x_type"))) rtx x;
   x = new_rtx ();
   ggc_add_gty_root (&x, do_with_something_x_type);
   ...
   ggc_del_gty_root (&x);
}

because gengtype needs to know about what types are used for GC (so it
can generate the appropriate marker routines) and the routine needs to
know what magic cookie is passed to ggc_add_root to describe the type.

I considered implementing this, but it turned out to be easier to
simply have all roots be static.

What I'd really like to do is just have:

void do_with_something (void)
{
   static GTY(()) rtx x;
   x = new_rtx ();
   ...
}

but there's no portable way to get the address of 'x' into a
globally-visible variable (there are lots of ways to do it if you
assume GCC as the compiler, but we can't).

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


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