public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: Justin Seyster <jrseys@gmail.com>
Cc: Joern Rennecke <joernr@arc.com>,
	  Richard Guenther <richard.guenther@gmail.com>,
	 Taras Glek <tglek@mozilla.com>,
	  "Joseph S. Myers" <joseph@codesourcery.com>,
	 GCC Mailing List <gcc@gcc.gnu.org>,
	Diego Novillo <dnovillo@google.com>,
	  Le-Chun Wu <lcwu@google.com>,
	 Grigori Fursin <grigori.fursin@inria.fr>
Subject: Re: Plugins & GGC ie GTY
Date: Tue, 05 May 2009 06:09:00 -0000	[thread overview]
Message-ID: <49FFD872.3010500@starynkevitch.net> (raw)
In-Reply-To: <395877250905041953m70a6838et5eda1a027e05533f@mail.gmail.com>

Justin Seyster wrote:
>
>   
>> We just have to add some small code [2] into the ggc_mark_roots routine of
>> gcc/ggc-common.c to add the scanning using this gt_ggc_r_gt_FOO_h. This is
>> not a big deal. We should simply add a routine
>> ggc_register_plugin_root_tab(const struct ggc_root_tab*) that adds its
>> argument to some (static variable in gcc/ggc-common.c which is a) linked
>> list or vector, and have ggc_mark_root scan that list or vector by adding a
>> few lines there. We require plugin initializers to call
>> ggc_register_plugin_root_tab appropriatly, exactly like they do already call
>> register_callback etc...
>>     
>
> This is in fact exactly the solution I was using in the old plugin
> branch (though I never submitted the code once it became clear that
> the newer plug-in system was going to take over).  I can send out the
> patch if anyone is interested; it's as simple as it sounds.
>
> With that extra bit of garbage collector support in place, I hacked up
> a simple header file that provides macros to manually generate
> ggc_add_plugin_root struct entries just like the ones gengtype would
> generate (for a small set of types).  So a plug-in author can declare
> a vector of tree nodes like so:
>
> static GC_ROOT_TREE_VEC (my_tree_vector);
>
> Another macro (to be called from plugin_init()) lets the author
> register that root with the garbage collector.
>
> register_root (my_tree_vector);
>
> This isn't an end-all solution, but it actually provides all the
> support that I need for my plug-ins, and it is perhaps a useful
> stepping stone.
>
> The main reason I'm bringing this up is because I've got a handful of
> plug-ins I'd like to make public.  Without any support from the
> garbage collector, I'll have to do some rewriting to get around the
> issue.  If other plug-in authors thinks this is a useful idea (would
> it be sufficient to port MELT, for instance?), I'd be willing to
> prepare some patches to add it in.
>
>   


I think the major issue is not to code the patch. It is to have it 
accepted in the trunk. My perception is that many people dislike GGC and 
reject the whole idea of garbage collection inside GCC [1] For example, 
http://gcc.gnu.org/ml/gcc-patches/2009-01/msg00431.html was a small 
[rejected] patch which would have provide the equivalent functionality.

I definitely dream of making MELT a plugin. What I need for this is

a. The ability to add a few (perhaps only 2 or 4) static or global GGC 
roots inside a plugin. One of these roots has a very special scanning 
routine.

b. The ability to add a few GTY-ed types. This would require essentially 
a patch to gengtype to have it run in a plugin mode where it take one 
single foo.c source files with GTY as input and output one single 
gt-foo.h file with the scanning/marking routine.

c. The ability to have a custom scanning/marking routine. This I could 
perhaps do with a #define gt_ggc_mx_FOOTYPE(Root) my_marking_rootine(Root)

The main reason of all this is that MELT does have its own GC backed up 
by GGC, and that MELT handle all its local pointers appropriately (in 
generated C code, this is quite easy: just hack the C generator). So in 
the infrequent case (only full MELT garbage collection, since the minor 
MELT GC is handled by MELT using a copying strategy) when GGC is called, 
a special routine has to mark all the local pointers. Remember that MELT 
is a Lisp dialect translated to C: you don't handle explicitly any GC 
local roots in MELT code, they appear only in the generated C code.

Also, GGC is perhaps more associated -in the mind of most people here- 
with precompiled headers than with memory management. MELT is not 
compatible with precompiled headers (in the sense that they could not be 
generated by MELT stuff; however, one could imagine loading some 
precompiled headers before using some MELT pass). My belief is that 
precompiled headers and plugins [2] are not really compatible (I am 
thinking of generating a *.gch file using plugins, I am not thinking of 
reading a *.gch file using a plugin; that should be already ok), and 
both are rarely used (so will probably be even less often used 
together). The insight is that there is no way to guarantee that a 
plugin would restore its entire state (at time of *.gch writing) when 
reading again the *.gch

Regards

Note [1]: my opposite view is that garbage collection is a 
whole-program-wide feature which is required in any sufficiently complex 
compiler (so I believe it is here to stay) but that GGC is not the 
garbage collector I'm dreaming (mostly because it does not handle local 
roots), burt barely enough for me. I am aware that my position is in the 
minority.

Note [2]: See the 
http://gcc.gnu.org/ml/gcc-patches/2009-04/msg02233.html thread

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***

  reply	other threads:[~2009-05-05  6:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-01 22:49 Joern Rennecke
2009-04-01 23:40 ` Steven Bosscher
2009-04-02  5:34 ` Basile STARYNKEVITCH
2009-05-05  2:53   ` Justin Seyster
2009-05-05  6:09     ` Basile STARYNKEVITCH [this message]
     [not found] <49D25E40.6080507@mozilla.com>
     [not found] ` <84fc9c000904010146j53e49ed9i6c271751d41dfd42@mail.gmail.com>
     [not found]   ` <Pine.LNX.4.64.0904011257550.14922@digraph.polyomino.org.uk>
     [not found]     ` <49D398C9.1010809@mozilla.com>
2009-04-01 17:22       ` Basile STARYNKEVITCH
2009-04-01 18:26         ` Richard Guenther
2009-04-01 18:37           ` Basile STARYNKEVITCH
2009-04-01 20:48             ` Basile STARYNKEVITCH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49FFD872.3010500@starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=dnovillo@google.com \
    --cc=gcc@gcc.gnu.org \
    --cc=grigori.fursin@inria.fr \
    --cc=joernr@arc.com \
    --cc=joseph@codesourcery.com \
    --cc=jrseys@gmail.com \
    --cc=lcwu@google.com \
    --cc=richard.guenther@gmail.com \
    --cc=tglek@mozilla.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).