lua-users home
lua-l archive

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


CHU Run-min wrote:
> [... Quote from Lua sources deleted ...]
> 
> The call stack will be traversed in gc mark phase, so the BASE[-1]
> will be treated specially. Though it is a number value, the gc known
> its internals. So the function object will be marked.
> May I got the right understanding?

Yes, your understanding is correct. But of course the code base of
LuaJIT 2.x has diverged quite a bit ... here are the relevant
snippets from the code:

  /* Stack marking. */
  TValue *o;
  for (o = th->stack+1; o < th->top; o++)
    gc_marktv(g, o);

  /* Frame marking and finding the max. top of all frames. */
  TValue *frame, *top = th->top-1;
  for (frame = th->base-1; frame > th->stack; frame = frame_prev(frame)) {
    GCfunc *fn = frame_func(frame);
    TValue *ftop = frame;
    if (isluafunc(fn)) ftop += funcproto(fn)->framesize;
    if (ftop > top) top = ftop;
    gc_markobj(g, frame_gc(frame));
  }
  if (top > th->maxstack) top = th->maxstack;

--Mike