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

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.

my_new() {
    PMC * p, q;
    remember(&p);
    q = another_new();
    p->otherpmc = g;
    recall();
    return p;
}


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.

I think Hong Zhang already pointed out how JVM does it, maybe we should
learn from experience? Doesn't the JVM allow creating temporary stashes,
which are then collected themselves upon leaving some set of routines?

-Melvin

Reply via email to