aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-11 16:00:27 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-11 16:00:27 -0300
commit0c8a7e071b00a1ea9822101f3b9fe4392d05c3c6 (patch)
tree84020c63180b516c048fb56350f5097924a2aa5c
parenta3d36fe283c09d4e56474da98f22d13162cc9fec (diff)
downloadlua-0c8a7e071b00a1ea9822101f3b9fe4392d05c3c6.tar.gz
lua-0c8a7e071b00a1ea9822101f3b9fe4392d05c3c6.tar.bz2
lua-0c8a7e071b00a1ea9822101f3b9fe4392d05c3c6.zip
'mainthread' lives in 'allgc' list, like everybody else
-rw-r--r--lgc.c16
-rw-r--r--lstate.c7
2 files changed, 10 insertions, 13 deletions
diff --git a/lgc.c b/lgc.c
index f4223588..c0af55f4 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.219 2017/04/10 13:33:04 roberto Exp roberto $ 2** $Id: lgc.c,v 2.220 2017/04/11 18:41:09 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*/
@@ -1200,8 +1200,6 @@ static void entergen (lua_State *L, global_State *g) {
1200 1200
1201 sweep2old(L, &g->tobefnz); 1201 sweep2old(L, &g->tobefnz);
1202 1202
1203 setage(g->mainthread, G_OLD);
1204
1205 finishgencycle(L, g); 1203 finishgencycle(L, g);
1206 g->gckind = KGC_GEN; 1204 g->gckind = KGC_GEN;
1207} 1205}
@@ -1213,7 +1211,6 @@ static void entergen (lua_State *L, global_State *g) {
1213** and go to pause state. 1211** and go to pause state.
1214*/ 1212*/
1215static void enterinc (global_State *g) { 1213static void enterinc (global_State *g) {
1216 makewhite(g, g->mainthread);
1217 whitelist(g, g->allgc); 1214 whitelist(g, g->allgc);
1218 g->reallyold = g->old = g->survival = NULL; 1215 g->reallyold = g->old = g->survival = NULL;
1219 whitelist(g, g->finobj); 1216 whitelist(g, g->finobj);
@@ -1305,8 +1302,8 @@ static void entersweep (lua_State *L) {
1305} 1302}
1306 1303
1307 1304
1308static void deletealllist (lua_State *L, GCObject *p) { 1305static void deletealllist (lua_State *L, GCObject *p, GCObject *limit) {
1309 while (p) { 1306 while (p != limit) {
1310 GCObject *next = p->next; 1307 GCObject *next = p->next;
1311 freeobj(L, p); 1308 freeobj(L, p);
1312 p = next; 1309 p = next;
@@ -1320,9 +1317,9 @@ void luaC_freeallobjects (lua_State *L) {
1320 separatetobefnz(g, 1); /* separate all objects with finalizers */ 1317 separatetobefnz(g, 1); /* separate all objects with finalizers */
1321 lua_assert(g->finobj == NULL); 1318 lua_assert(g->finobj == NULL);
1322 callallpendingfinalizers(L); 1319 callallpendingfinalizers(L);
1323 deletealllist(L, g->finobj); 1320 deletealllist(L, g->allgc, g->mainthread);
1324 deletealllist(L, g->allgc); 1321 deletealllist(L, g->finobj, NULL);
1325 deletealllist(L, g->fixedgc); /* collect fixed objects */ 1322 deletealllist(L, g->fixedgc, NULL); /* collect fixed objects */
1326 lua_assert(g->strt.nuse == 0); 1323 lua_assert(g->strt.nuse == 0);
1327} 1324}
1328 1325
@@ -1427,7 +1424,6 @@ static lu_mem singlestep (lua_State *L) {
1427 return sweepstep(L, g, GCSswpend, NULL); 1424 return sweepstep(L, g, GCSswpend, NULL);
1428 } 1425 }
1429 case GCSswpend: { /* finish sweeps */ 1426 case GCSswpend: { /* finish sweeps */
1430 makewhite(g, g->mainthread); /* sweep main thread */
1431 checkSizes(L, g); 1427 checkSizes(L, g);
1432 g->gcstate = GCScallfin; 1428 g->gcstate = GCScallfin;
1433 return 0; 1429 return 0;
diff --git a/lstate.c b/lstate.c
index d2f38588..0b731c87 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.c,v 2.134 2017/02/23 21:07:34 roberto Exp roberto $ 2** $Id: lstate.c,v 2.135 2017/04/05 16:50:51 roberto Exp $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -300,11 +300,12 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
300 if (l == NULL) return NULL; 300 if (l == NULL) return NULL;
301 L = &l->l.l; 301 L = &l->l.l;
302 g = &l->g; 302 g = &l->g;
303 L->next = NULL;
304 L->tt = LUA_TTHREAD; 303 L->tt = LUA_TTHREAD;
305 g->currentwhite = bitmask(WHITE0BIT); 304 g->currentwhite = bitmask(WHITE0BIT);
306 L->marked = luaC_white(g); 305 L->marked = luaC_white(g);
307 preinit_thread(L, g); 306 preinit_thread(L, g);
307 g->allgc = obj2gco(L); /* by now, only object is the main thread */
308 L->next = NULL;
308 g->frealloc = f; 309 g->frealloc = f;
309 g->ud = ud; 310 g->ud = ud;
310 g->mainthread = L; 311 g->mainthread = L;
@@ -318,7 +319,7 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
318 g->version = NULL; 319 g->version = NULL;
319 g->gcstate = GCSpause; 320 g->gcstate = GCSpause;
320 g->gckind = KGC_NORMAL; 321 g->gckind = KGC_NORMAL;
321 g->allgc = g->finobj = g->tobefnz = g->fixedgc = NULL; 322 g->finobj = g->tobefnz = g->fixedgc = NULL;
322 g->survival = g->old = g->reallyold = NULL; 323 g->survival = g->old = g->reallyold = NULL;
323 g->finobjsur = g->finobjold = g->finobjrold = NULL; 324 g->finobjsur = g->finobjold = g->finobjrold = NULL;
324 g->sweepgc = NULL; 325 g->sweepgc = NULL;