C++ Garbage Collecter
Jeffrey A Law
law@cygnus.com
Thu Aug 26 01:00:00 GMT 1999
In message < m2btbw30qj.fsf@magnus.bothner.com >you write:
> I don't think these statements are very relevant. Yes, the compiler
> sometimes does such re-writing, but that is not a problem for a
conservative
> collectors as long as there is still a pointer somewhere that points to
> the actual base of the object. And either you have a newly allocated
> object that will be passed to someone, or it was an existing object
> that was passed from somewhere (as an argument). In either case, you
> would have a pointer to the base object somewhere.
But this is precisely the problem. You allocate a hunk of memory and initially
assign it to some variable. Let's call it "a".
You then do a lot of indexing off "a" in a loop. The compiler may create a
pointer outside of "a" and kill the pseudo which originally contained "a".
If you do garbage collection you lose.
ie, the compiler effectively does something like this:
a = malloc (100)
a -= 10
for ( ... )
a[10 + i] = whatever
even though you wrote
a = malloc (100)
for ( ...)
a[i] = whatever
jeff
More information about the Gcc
mailing list