From cf7eff45f3abf2386d5392c0b431498bbb274ac7 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 28 Dec 2017 13:42:57 -0200 Subject: keep control of stack top in Lua functions concentrated in 'luaV_execute' --- lgc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'lgc.c') diff --git a/lgc.c b/lgc.c index 37bcdb8d..d02dc031 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.242 2017/12/08 17:28:25 roberto Exp roberto $ +** $Id: lgc.c,v 2.243 2017/12/20 14:58:05 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -571,21 +571,16 @@ static int traverseLclosure (global_State *g, LClosure *cl) { /* ** Traverse a thread, marking the elements in the stack up to its top -** and cleaning the rest of the stack in the last traversal. +** and cleaning the rest of the stack in the final traversal. ** That ensures that the entire stack have valid (non-dead) objects. -** In an emergency collection running Lua code, 'L->top' may not be -** update. In that case, traverse at least up to 'ci->top'. */ static int traversethread (global_State *g, lua_State *th) { StkId o = th->stack; - StkId top = th->top; if (o == NULL) return 1; /* stack not completely built yet */ lua_assert(g->gcstate == GCSatomic || th->openupval == NULL || isintwups(th)); - if (g->gcemergency && isLuacode(th->ci) && top < th->ci->top) - top = th->ci->top; - for (; o < top; o++) /* mark live elements in the stack */ + for (; o < th->top; o++) /* mark live elements in the stack */ markvalue(g, s2v(o)); if (g->gcstate == GCSatomic) { /* final traversal? */ StkId lim = th->stack + th->stacksize; /* real end of stack */ -- cgit v1.2.3-55-g6feb