lua-users home
lua-l archive

Why set useless stack slice(above L->top) to nil during gc atomic phase ?

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


Lua 5.2.4
In lgc.c propagatemark -> traversestack, line 502-506,
clear the slice in the range of [th->top + 1, th->stack + th->stacksize),
What if don't clear not-marked stack slice ?
 495 static lu_mem traversestack (global_State *g, lua_State *th) {
 496 int n = 0;
 497 StkId o = th->stack;
 498 if (o == NULL)
 499 return 1; /* stack not completely built yet */
 500 for (; o < th->top; o++) /* mark live elements in the stack */
 501 markvalue(g, o);
 502 if (g->gcstate == GCSatomic) { /* final traversal? */
 503 StkId lim = th->stack + th->stacksize; /* real end of stack */
 504 for (; o < lim; o++) /* clear not-marked stack slice */
 505 setnilvalue(o);
 506 }
 507 else { /* count call infos to compute size */
 508 CallInfo *ci;
 509 for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
 510 n++;
 511 }
 512 return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
 513 sizeof(CallInfo) * n;
 514 }
Thanks.

AltStyle によって変換されたページ (->オリジナル) /