[PATCH]: An almost working copying collector for gcc

Geoff Keating geoffk@geoffk.org
Fri Dec 13 13:21:00 GMT 2002


> Date: Fri, 13 Dec 2002 13:42:44 -0500 (EST)
> From: Daniel Berlin <dberlin@dberlin.org>

> On Fri, 13 Dec 2002, Geoff Keating wrote:
> 
> > >
> > > We have locals we expect to be the same between collections.
> > > Which means i'm gonna have to do stack scanning for pointers.
> > > Whee!
> >
> > That won't work unless you have type information, otherwise you won't
> > be able to distinguish between a pointer that has value 0x12340 and
> > some counter or something that just happens to have the same value.
> Technically, yes, but the chances of this happening are incredibly
> slim.
> 1. Garbage collection only occurs from a small number of routines, and
> thus, if those routines don't have counters or things that might have
> such a value, it doesn't matter.
> 2. We verify that the old pointer is in the old fromspace.
> 3. We verify that it's been forwarded.

Yes, but when this "slim chance" does happen, the compiler will crash
or miscompile a file, because you'll have corrupted some value
on the stack.  It's not like the Boehm collector, where if a value is
misidentified as a pointer, some memory is leaked but everything works
properly otherwise.

It may work well enough for you to get some timing results to
determine if you want to progress with a real implementation, but it
wouldn't be acceptable in a real implementation, and it's enough of a
fundamental design point that it may even invalidate your timing
results.

> Unless you've got a platform that starts mmappings < 0x1000000, this
> is a non-issue.

I don't see why.  If you're trying to make an argument that "the only
objects that will be on the stack are pointer-size integers with small
values and pointers", this is plainly false.

I wouldn't want to speculate on how platforms allocate memory without
making a survey of the 10 or 20 most popular platforms.  Do you know
what addresses {x86-linux, Cygwin, linux/mips, linux/ppc, Darwin,
linux on ps2, Solaris, AIX, VMS, linux on S/300} can return with mmap?

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



More information about the Gcc-patches mailing list