From 3f78de256e5759669460c6fa14455303762f2f53 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 18 Feb 2014 10:46:26 -0300 Subject: [PATCH] no need to keep threads in a different GC list, now that there is the 'twups' list --- lgc.c | 6 +----- lgc.h | 13 ++++++------- lstate.c | 8 ++++---- lstate.h | 3 +-- ltests.c | 20 +++++--------------- 5 files changed, 17 insertions(+), 33 deletions(-) diff --git a/lgc.c b/lgc.c index 9471b894..c210b67e 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.175 2014/02/15 13:12:01 roberto Exp roberto $ +** $Id: lgc.c,v 2.176 2014/02/18 13:39:37 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -954,7 +954,6 @@ void luaC_freeallobjects (lua_State *L) { g->gckind = KGC_NORMAL; sweepwholelist(L, &g->finobj); sweepwholelist(L, &g->allgc); - sweepwholelist(L, &g->mainthread->next); sweepwholelist(L, &g->fixedgc); /* collect fixed objects */ lua_assert(g->strt.nuse == 0); } @@ -1046,9 +1045,6 @@ static lu_mem singlestep (lua_State *L) { return work + sw * GCSWEEPCOST; } case GCSswpallgc: { /* sweep "regular" objects */ - return sweepstep(L, g, GCSswpthreads, &g->mainthread->next); - } - case GCSswpthreads: { /* sweep threads */ return sweepstep(L, g, GCSswpfinobj, &g->finobj); } case GCSswpfinobj: { /* sweep objects with finalizers */ diff --git a/lgc.h b/lgc.h index 0e24d2c3..958ca26b 100644 --- a/lgc.h +++ b/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.79 2014/02/13 14:46:38 roberto Exp roberto $ +** $Id: lgc.h,v 2.80 2014/02/14 16:43:14 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -39,12 +39,11 @@ #define GCSpropagate 0 #define GCSatomic 1 #define GCSswpallgc 2 -#define GCSswpthreads 3 -#define GCSswpfinobj 4 -#define GCSswptobefnz 5 -#define GCSswpend 6 -#define GCScallfin 7 -#define GCSpause 8 +#define GCSswpfinobj 3 +#define GCSswptobefnz 4 +#define GCSswpend 5 +#define GCScallfin 6 +#define GCSpause 7 #define issweepphase(g) \ diff --git a/lstate.c b/lstate.c index bc235941..123dd198 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.119 2014/02/13 14:46:38 roberto Exp roberto $ +** $Id: lstate.c,v 2.120 2014/02/18 13:39:37 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -260,9 +260,9 @@ LUA_API lua_State *lua_newthread (lua_State *L) { L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l; L1->marked = luaC_white(g); L1->tt = LUA_TTHREAD; - /* link it on list of threads */ - L1->next = g->mainthread->next; - g->mainthread->next = obj2gco(L1); + /* link it on list 'allgc' */ + L1->next = g->allgc; + g->allgc = obj2gco(L1); setthvalue(L, L->top, L1); api_incr_top(L); preinit_thread(L1, g); diff --git a/lstate.h b/lstate.h index 9df36f32..a876f35f 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.100 2014/02/13 14:46:38 roberto Exp roberto $ +** $Id: lstate.h,v 2.101 2014/02/18 13:39:37 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -21,7 +21,6 @@ ** belong to one (and only one) of these lists, using field 'next' of ** the 'CommonHeader' for the link: ** -** mainthread->next: all threads; ** allgc: all objects not marked for finalization; ** finobj: all objects marked for finalization; ** tobefnz: all objects ready to be finalized; diff --git a/ltests.c b/ltests.c index 5abe598c..931fc1c8 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.164 2014/02/13 12:11:34 roberto Exp roberto $ +** $Id: ltests.c,v 2.165 2014/02/15 13:12:01 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -426,14 +426,6 @@ int lua_checkmemory (lua_State *L) { checkobject(g, o, maybedead); lua_assert(!tofinalize(o)); } - /* check thread list */ - checkgray(g, obj2gco(g->mainthread)); - maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpthreads); - for (o = obj2gco(g->mainthread); o != NULL; o = gch(o)->next) { - checkobject(g, o, maybedead); - lua_assert(!tofinalize(o)); - lua_assert(gch(o)->tt == LUA_TTHREAD); - } /* check 'finobj' list */ checkgray(g, g->finobj); for (o = g->finobj; o != NULL; o = gch(o)->next) { @@ -615,12 +607,10 @@ static int gc_color (lua_State *L) { static int gc_state (lua_State *L) { - static const char *statenames[] = {"propagate", "atomic", - "sweepallgc", "sweepthreads", "sweepfinobj", - "sweeptobefnz", "sweepend", "pause", ""}; - static const int states[] = {GCSpropagate, GCSatomic, - GCSswpallgc, GCSswpthreads, GCSswpfinobj, - GCSswptobefnz, GCSswpend, GCSpause, -1}; + static const char *statenames[] = {"propagate", "atomic", "sweepallgc", + "sweepfinobj", "sweeptobefnz", "sweepend", "pause", ""}; + static const int states[] = {GCSpropagate, GCSatomic, GCSswpallgc, + GCSswpfinobj, GCSswptobefnz, GCSswpend, GCSpause, -1}; int option = states[luaL_checkoption(L, 1, "", statenames)]; if (option == -1) { lua_pushstring(L, statenames[G(L)->gcstate]);