On Fri, Mar 29, 2002 at 01:54:00AM -0500, Melvin Smith wrote:
> At 10:30 PM 3/28/2002 -0800, Steve Fink wrote:
> >When you call pmc_new, the init() routine is run before the PMC is
> >anchored to the root set. This is a problem for things like
> >aggregates, because they are likely to want to allocate a big Buffer
> >during initialization. And disabling GC entirely just feels wrong --
> >especially with pmc_new_sized, it is very believable that this is a
> >very good time to be collecting garbage.
> >
> >In short, it feels special-casey enough to me to warrant the following
> >patch, which adds a new item to the root set for just this purpose. It
> >could probably be better named. Dan, whaddaya think?
> 
> I'd prefer to use a flag to make GC pass over the particular item so
> it can be recursive, etc. Else you have to do something funky when
> creating entities that create other entities.

Good point.

> Just setting a bit upon entry, then clearing the bit after its
> linked to the root set should do the trick.
> 
> Isn't there already such a bit?

I looked for one, but couldn't find anything. The live bit is for
internal GC use only (and will get cleared at the beginning of a mark
scan, so don't bother). The constant bit would work, except you'd have
no way of detecting whether the init routine set the constant bit
itself.

Actually, there was a pair of bits that sounded perfect -- the
reference count bits. Unfortunately, they're never examined. But
they're probably the real answer.

> Another alternative is a generic stack which you would push pointers
> to pointers, so even if you triggered a GC run you'd still have the
> correct pointer.

Yes, that would be the simplest way to beef up the creating_pmc
technique to handle your objection above, but it seems pretty complex
compared to the bit technique.

> I think its more efficient to just set/clear a flag, but stashing a
> pointer to a pointer lets GC move it if it needs.

....and this is what the complexity would buy. :-)

-- 
WM ISO JOB. http://foxglove.dnsalias.org/~sfink/job.html
C, perl, networking, performance optimization, Java, XML.

Reply via email to