A generational GC question

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

A generational GC question

Dibyendu Majumdar
Hi,

I have ported the generational GC to Ravi, but Ravi's up-value model
is based on the reference counting approach in Lua 5.3. My question is
this:

What should the age of an upvalue be set to in an upvalue barrier?

I see that the code in Lua looked like this before the up-value
implementation was changed:

void luaC_upvalbarrier_ (lua_State *L, GCObject *o) {
  global_State *g = G(L);
  if (keepinvariant(g) && !isold(o)) {
    markobject(g, o);
    setage(o, G_OLD0);
  }
}

I am trying to figure out if OLD0 is still the correct age to set to.

Regards
Dibyendu
Reply | Threaded
Open this post in threaded view
|

Re: A generational GC question

Roberto Ierusalimschy
> I have ported the generational GC to Ravi, but Ravi's up-value model
> is based on the reference counting approach in Lua 5.3. My question is
> this:
>
> What should the age of an upvalue be set to in an upvalue barrier?

I don't follow you here. If upvalues are reference counted, they should
not have ages.

-- Roberto
Reply | Threaded
Open this post in threaded view
|

Re: A generational GC question

Dibyendu Majumdar
On Tue, 22 Dec 2020 at 19:44, Roberto Ierusalimschy
<[hidden email]> wrote:

>
> > I have ported the generational GC to Ravi, but Ravi's up-value model
> > is based on the reference counting approach in Lua 5.3. My question is
> > this:
> >
> > What should the age of an upvalue be set to in an upvalue barrier?
>
> I don't follow you here. If upvalues are reference counted, they should
> not have ages.
>

I meant the value pointed to by the up-value . This is the 5.3 code;

/*
** barrier for assignments to closed upvalues. Because upvalues are
** shared among closures, it is impossible to know the color of all
** closures pointing to it. So, we assume that the object being assigned
** must be marked.
*/
void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) {
  global_State *g = G(L);
  GCObject *o = gcvalue(uv->v);
  lua_assert(!upisopen(uv));  /* ensured by macro luaC_upvalbarrier */
  if (keepinvariant(g))
    markobject(g, o);
}

My question is what age to set 'o' to.
In the early GC code I quoted, this was set to G_OLD0.

Regards
Reply | Threaded
Open this post in threaded view
|

Re: A generational GC question

Roberto Ierusalimschy
> I meant the value pointed to by the up-value . This is the 5.3 code;
>
> /*
> ** barrier for assignments to closed upvalues. Because upvalues are
> ** shared among closures, it is impossible to know the color of all
> ** closures pointing to it. So, we assume that the object being assigned
> ** must be marked.
> */
> void luaC_upvalbarrier_ (lua_State *L, UpVal *uv) {
>   global_State *g = G(L);
>   GCObject *o = gcvalue(uv->v);
>   lua_assert(!upisopen(uv));  /* ensured by macro luaC_upvalbarrier */
>   if (keepinvariant(g))
>     markobject(g, o);
> }
>
> My question is what age to set 'o' to.
> In the early GC code I quoted, this was set to G_OLD0.

So, G_OLD0. Or there was something wrong with that early code?  The
comment explains this choice.

-- Roberto
Reply | Threaded
Open this post in threaded view
|

Re: A generational GC question

Dibyendu Majumdar
On Wed, 23 Dec 2020 at 14:04, Roberto Ierusalimschy
<[hidden email]> wrote:

> So, G_OLD0. Or there was something wrong with that early code?  The
> comment explains this choice.
>

Yes. I have a couple of breaks in tests that I am investigating - may
be unrelated.
Thanks for the info.