'mainthread' lives in 'allgc' list, like everybody else

This commit is contained in:
Roberto Ierusalimschy
2017-04-11 16:00:27 -03:00
parent a3d36fe283
commit 0c8a7e071b
2 changed files with 10 additions and 13 deletions

16
lgc.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 2.219 2017/04/10 13:33:04 roberto Exp roberto $ ** $Id: lgc.c,v 2.220 2017/04/11 18:41:09 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -1200,8 +1200,6 @@ static void entergen (lua_State *L, global_State *g) {
sweep2old(L, &g->tobefnz); sweep2old(L, &g->tobefnz);
setage(g->mainthread, G_OLD);
finishgencycle(L, g); finishgencycle(L, g);
g->gckind = KGC_GEN; g->gckind = KGC_GEN;
} }
@@ -1213,7 +1211,6 @@ static void entergen (lua_State *L, global_State *g) {
** and go to pause state. ** and go to pause state.
*/ */
static void enterinc (global_State *g) { static void enterinc (global_State *g) {
makewhite(g, g->mainthread);
whitelist(g, g->allgc); whitelist(g, g->allgc);
g->reallyold = g->old = g->survival = NULL; g->reallyold = g->old = g->survival = NULL;
whitelist(g, g->finobj); whitelist(g, g->finobj);
@@ -1305,8 +1302,8 @@ static void entersweep (lua_State *L) {
} }
static void deletealllist (lua_State *L, GCObject *p) { static void deletealllist (lua_State *L, GCObject *p, GCObject *limit) {
while (p) { while (p != limit) {
GCObject *next = p->next; GCObject *next = p->next;
freeobj(L, p); freeobj(L, p);
p = next; p = next;
@@ -1320,9 +1317,9 @@ void luaC_freeallobjects (lua_State *L) {
separatetobefnz(g, 1); /* separate all objects with finalizers */ separatetobefnz(g, 1); /* separate all objects with finalizers */
lua_assert(g->finobj == NULL); lua_assert(g->finobj == NULL);
callallpendingfinalizers(L); callallpendingfinalizers(L);
deletealllist(L, g->finobj); deletealllist(L, g->allgc, g->mainthread);
deletealllist(L, g->allgc); deletealllist(L, g->finobj, NULL);
deletealllist(L, g->fixedgc); /* collect fixed objects */ deletealllist(L, g->fixedgc, NULL); /* collect fixed objects */
lua_assert(g->strt.nuse == 0); lua_assert(g->strt.nuse == 0);
} }
@@ -1427,7 +1424,6 @@ static lu_mem singlestep (lua_State *L) {
return sweepstep(L, g, GCSswpend, NULL); return sweepstep(L, g, GCSswpend, NULL);
} }
case GCSswpend: { /* finish sweeps */ case GCSswpend: { /* finish sweeps */
makewhite(g, g->mainthread); /* sweep main thread */
checkSizes(L, g); checkSizes(L, g);
g->gcstate = GCScallfin; g->gcstate = GCScallfin;
return 0; return 0;

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lstate.c,v 2.134 2017/02/23 21:07:34 roberto Exp roberto $ ** $Id: lstate.c,v 2.135 2017/04/05 16:50:51 roberto Exp $
** Global State ** Global State
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -300,11 +300,12 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
if (l == NULL) return NULL; if (l == NULL) return NULL;
L = &l->l.l; L = &l->l.l;
g = &l->g; g = &l->g;
L->next = NULL;
L->tt = LUA_TTHREAD; L->tt = LUA_TTHREAD;
g->currentwhite = bitmask(WHITE0BIT); g->currentwhite = bitmask(WHITE0BIT);
L->marked = luaC_white(g); L->marked = luaC_white(g);
preinit_thread(L, g); preinit_thread(L, g);
g->allgc = obj2gco(L); /* by now, only object is the main thread */
L->next = NULL;
g->frealloc = f; g->frealloc = f;
g->ud = ud; g->ud = ud;
g->mainthread = L; g->mainthread = L;
@@ -318,7 +319,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
g->version = NULL; g->version = NULL;
g->gcstate = GCSpause; g->gcstate = GCSpause;
g->gckind = KGC_NORMAL; g->gckind = KGC_NORMAL;
g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; g->finobj = g->tobefnz = g->fixedgc = NULL;
g->survival = g->old = g->reallyold = NULL; g->survival = g->old = g->reallyold = NULL;
g->finobjsur = g->finobjold = g->finobjrold = NULL; g->finobjsur = g->finobjold = g->finobjrold = NULL;
g->sweepgc = NULL; g->sweepgc = NULL;