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]

Re: Help/suggestions for conservative gc problems


Jamie Lokier <jamie.lokier@cern.ch> writes:

> Greg Harvey wrote:
> > 
> > This is a pretty big problem, since the garbage collector uses the
> > stack to get at roots for the collection; if a collection occurs
> > during the code following the above snippet, the vector will be freed,
> > since there's no pointer to the actual scheme object. 
> 
> I don't see a problem.  If you use the stack and registers to get roots,
> then eax points to the vector and velts to the elements.  Once eax is
> clobbered, you still have velts as long as you're using it.  If velts as
> a root isn't enough for correct behaviour, that's a bug in Guile's
> garbage collector.

It isn't enough, and it's not a bug; the collector only manages a heap
of cells which are used to build every object (unlike other
conservative collectors like boehm's, which manage all memory unless
you tell them not to). The major benefit is that it makes it very easy
to create new objects (especially for foreign code) and allows the gc
to do much less work than scanning the whole heap for the existance of
every possible pointer in the stack (which becomes even worse if we
have to conservatively scan all mallocated memory to find possible
pointers); the downside is that pointers which might only be used once
have to stay alive in their scope to get a pointer to the scheme
object. This isn't just the case for vectors, but for any object in
guile (excepting immediates).

-- 
Gregh

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