From dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 11 Sep 2013 11:09:55 -0300 Subject: threads are kept in a separated GC list, linked after the main thread --- ltests.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 1db957cc..0f6a23dd 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.156 2013/09/11 12:26:14 roberto Exp roberto $ +** $Id: ltests.c,v 2.157 2013/09/11 12:47:48 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -423,7 +423,6 @@ int lua_checkmemory (lua_State *L) { global_State *g = G(L); GCObject *o; int maybedead; - int isthread; if (keepinvariant(g)) { lua_assert(!iswhite(obj2gco(g->mainthread))); lua_assert(!iswhite(gcvalue(&g->l_registry))); @@ -443,14 +442,20 @@ int lua_checkmemory (lua_State *L) { /* check 'allgc' list */ checkgray(g, g->allgc); maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepall); - isthread = 0; /* not traversing threads (yet) */ for (o = g->allgc; o != NULL; o = gch(o)->next) { - if (gch(o)->tt == LUA_TTHREAD) isthread = 1; /* now travesing threads... */ - else lua_assert(!isthread); /* ... and only threads */ checkobject(g, o, maybedead); lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); lua_assert(testbit(o->gch.marked, NOLOCALBIT)); } + /* check thread list */ + checkgray(g, obj2gco(g->mainthread)); + maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepthreads); + for (o = obj2gco(g->mainthread); o != NULL; o = gch(o)->next) { + checkobject(g, o, maybedead); + lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); + lua_assert(testbit(o->gch.marked, NOLOCALBIT)); + lua_assert(gch(o)->tt == LUA_TTHREAD); + } /* check 'localfin' list */ checkgray(g, g->localfin); for (o = g->localfin; o != NULL; o = gch(o)->next) { @@ -650,8 +655,8 @@ static int gc_local (lua_State *L) { static int gc_state (lua_State *L) { static const char *statenames[] = {"propagate", "atomic", - "sweeplocal", "sweeplocfin", "sweepfin", "sweepall", "sweeptobefnz", - "sweepmainth", "pause", ""}; + "sweeplocal", "sweeplocfin", "sweepfin", "sweepall", + "sweeptobefnz", "sweepthreads", "sweepend", "pause", ""}; int option = luaL_checkoption(L, 1, "", statenames); if (option == GCSpause + 1) { lua_pushstring(L, statenames[G(L)->gcstate]); -- cgit v1.2.3-55-g6feb