no need to keep threads in a different GC list, now that there is the

'twups' list
This commit is contained in:
Roberto Ierusalimschy 2014-02-18 10:46:26 -03:00
parent d764cc5522
commit 3f78de256e
5 changed files with 17 additions and 33 deletions

6
lgc.c
View File

@ -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 */

13
lgc.h
View File

@ -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) \

View File

@ -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);

View File

@ -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;

View File

@ -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]);