lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 13, Juris Kalnins wrote:
> * Once UpVal is closed, can value of it's 'next' member change? I mean
>   the GCObject *next, not the u.l.next

Yes the next pointer can change.  Closing an UpVal just moves it off the Lua 
Stack and into the Closure.  The GC still has to mark those values, so they 
are still in the l_G->rootgc linked list.

> * If closed UpVal is not linked into l_G->rootgc list and is ignored by GC,
>   can it's 'next' or 'marked' change?

All collectable values (tables,strings,closures,userdata,coroutines) must be 
in the l_G->rootgc linked list.

> * If Udata is not linked into mainthread->next list and is ignored by GC,
>   can it's 'next' or 'marked' change?

Without changes to the GC no collectable value can be ignored by the GC.

> "Ignored by GC" means a change in GC that doesn't trace into such object
> and does not alter it in any way.

The GC is a Mark & Sweep collector it has to trace/step through and mark all 
collectable values still accessible from the Lua stack.  After marking all 
values that are still accessible(live) it sweeps through the l_G->rootgc 
linked list and deletes any dead values.

Some more notes about how Lua's GC works can be found here:
http://lua-users.org/wiki/EmergencyGarbageCollector

-- 
Robert G. Jakabosky