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: New GCC plugin: gcc-python-plugin


On Tue, 2011-06-21 at 22:31 +0200, Basile Starynkevitch wrote:
> On Tue, 21 Jun 2011 15:34:51 -0400
> David Malcolm <dmalcolm@redhat.com> wrote:
> > When I mentioned the garbage collector, I was merely trying to convey
> > the early, buggy nature of my code.  This is a bug that I need to fix,
> > but not a fundamental design flaw (I hope!)
> 
> 
> I would be very interested in understanding in details how you mix
> Python reference counting garbage collector with Gcc GGC!

I'm looking forward to figuring that out as well! :)

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).

(Or it could just explicitly keep track of all live Python wrapper
objects, and walk them when PLUGIN_GGC_MARKING occurs, marking the
wrapped GCC objects; not sure).

I'm probably forgetting something important here though (e.g. what
happens when Python's GC runs?  Though so far I'm only wrapping GCC with
Python, not the other way around, so I _think_ this isn't an issue)

Hope this sounds sane
Dave



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