Re: New GCC plugin: gcc-python-plugin

2012-01-14 Thread David Malcolm
On Wed, 2011-06-22 at 08:19 +0200, Jakub Jelinek wrote:
> Hi!
> 
> On Tue, Jun 21, 2011 at 07:52:27PM -0400, David Malcolm wrote:
> > I'm not yet familiar with the details of the gcc GC, but it appears that
> > GTY() annotations are preprocessed to generate traversal code used by a
> > mark-and-sweep algorithm.
> > 
> > Python's own GC allows for classes to opt-in as reference-owners;
> > instances of such classes get tracked within linked lists (one per
> > generation of Python's GC).  This is intended for use for tracking
> > PyObject* references, but I may be able to piggy-back off of this - if I
> > add the relevant flag to my wrapper classes then they get tracked in
> > these linked lists.  I can then register a callback to
> > PLUGIN_GGC_MARKING that uses this to locate the subset of all PyObject*
> > objects that wrap GCC objects.  This could then mark all of the wrapped
> > GCC objects referenced from Python.  That way all of the Python wrapper
> > objects can be found as roots within a GCC GC, and thus not have their
> > wrapped GCC objects deleted "from under them" (traversing any refs they
> > in turn keep alive, of course).
> 
> You could just:
> #include "ggc.h"
> 
> static void my_walker (void *arg ATTRIBUTE_UNUSED)
> {
>   /* Ignore argument, as it is dummy */
>   /* Walk all the still live python objects here and if they reference
>  GCC GC objects, call
>   ggc_test_and_set_mark (ptr);
>  on each of them.  */
> }
> 
> static struct ggc_root_tab myroot = { "", 1, 1, my_walker, NULL };
> 
> ...
> init_plugin (...)
> {
> ...
>   ggc_register_root_tab (&myroot);
> ...
> }
> 
> No need for gengtype for this, unless you want to use GTY(()) markup
> inside of your plugin.

[replying to 6-month old thread about integrating the Python plugin with
GCC's garbage collector]

Thanks.  FWIW, I implemented something like this in 
http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=58d65a1b353220efbcf8d908b0946ef5d1c4fafd

which iterates over all live wrapper objects calling
gt_ggc_mx_NAME_OF_TYPE() on each wrapped object, which I hope is the
correct approach [it seems to work: the selftest puts the machinery into
verbose mode, and then verifies this log:
http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=blob;f=tests/plugin/gc/_gc_selftest/stdout.txt;hb=HEAD
 ]

Hope this is helpful
Dave



gcc-4.7-20120114 is now available

2012-01-14 Thread gccadmin
Snapshot gcc-4.7-20120114 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/4.7-20120114/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 4.7 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/trunk revision 183186

You'll find:

 gcc-4.7-20120114.tar.bz2 Complete GCC

  MD5=8603e5005a5553f9286767f3be8b23ad
  SHA1=8e7e5f17c9fd31b8f67ab7ca95a270d2bd3e0d00

Diffs from 4.7-20120107 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-4.7
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.