aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-28 13:42:57 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-12-28 13:42:57 -0200
commitcf7eff45f3abf2386d5392c0b431498bbb274ac7 (patch)
tree0eaafe3456bd03b241e447f1375296341fb648e8 /lgc.c
parent8691612f01ae4b32d861464032521d969766c1c5 (diff)
downloadlua-cf7eff45f3abf2386d5392c0b431498bbb274ac7.tar.gz
lua-cf7eff45f3abf2386d5392c0b431498bbb274ac7.tar.bz2
lua-cf7eff45f3abf2386d5392c0b431498bbb274ac7.zip
keep control of stack top in Lua functions concentrated in 'luaV_execute'
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/lgc.c b/lgc.c
index 37bcdb8d..d02dc031 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.242 2017/12/08 17:28:25 roberto Exp roberto $ 2** $Id: lgc.c,v 2.243 2017/12/20 14:58:05 roberto Exp roberto $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -571,21 +571,16 @@ static int traverseLclosure (global_State *g, LClosure *cl) {
571 571
572/* 572/*
573** Traverse a thread, marking the elements in the stack up to its top 573** Traverse a thread, marking the elements in the stack up to its top
574** and cleaning the rest of the stack in the last traversal. 574** and cleaning the rest of the stack in the final traversal.
575** That ensures that the entire stack have valid (non-dead) objects. 575** That ensures that the entire stack have valid (non-dead) objects.
576** In an emergency collection running Lua code, 'L->top' may not be
577** update. In that case, traverse at least up to 'ci->top'.
578*/ 576*/
579static int traversethread (global_State *g, lua_State *th) { 577static int traversethread (global_State *g, lua_State *th) {
580 StkId o = th->stack; 578 StkId o = th->stack;
581 StkId top = th->top;
582 if (o == NULL) 579 if (o == NULL)
583 return 1; /* stack not completely built yet */ 580 return 1; /* stack not completely built yet */
584 lua_assert(g->gcstate == GCSatomic || 581 lua_assert(g->gcstate == GCSatomic ||
585 th->openupval == NULL || isintwups(th)); 582 th->openupval == NULL || isintwups(th));
586 if (g->gcemergency && isLuacode(th->ci) && top < th->ci->top) 583 for (; o < th->top; o++) /* mark live elements in the stack */
587 top = th->ci->top;
588 for (; o < top; o++) /* mark live elements in the stack */
589 markvalue(g, s2v(o)); 584 markvalue(g, s2v(o));
590 if (g->gcstate == GCSatomic) { /* final traversal? */ 585 if (g->gcstate == GCSatomic) { /* final traversal? */
591 StkId lim = th->stack + th->stacksize; /* real end of stack */ 586 StkId lim = th->stack + th->stacksize; /* real end of stack */