aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-11 11:09:55 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-09-11 11:09:55 -0300
commitdd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8 (patch)
treed475246f43edc6de6e1ebf491b274e9d9a5c1c24 /ltests.c
parent7061fe1d56f40e9d22a226423079da808fb41f66 (diff)
downloadlua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.tar.gz
lua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.tar.bz2
lua-dd373a8f665e5e22ad3ad75401aa9fe3bbb2afc8.zip
threads are kept in a separated GC list, linked after the main thread
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ltests.c b/ltests.c
index 1db957cc..0f6a23dd 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.156 2013/09/11 12:26:14 roberto Exp roberto $ 2** $Id: ltests.c,v 2.157 2013/09/11 12:47:48 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -423,7 +423,6 @@ int lua_checkmemory (lua_State *L) {
423 global_State *g = G(L); 423 global_State *g = G(L);
424 GCObject *o; 424 GCObject *o;
425 int maybedead; 425 int maybedead;
426 int isthread;
427 if (keepinvariant(g)) { 426 if (keepinvariant(g)) {
428 lua_assert(!iswhite(obj2gco(g->mainthread))); 427 lua_assert(!iswhite(obj2gco(g->mainthread)));
429 lua_assert(!iswhite(gcvalue(&g->l_registry))); 428 lua_assert(!iswhite(gcvalue(&g->l_registry)));
@@ -443,14 +442,20 @@ int lua_checkmemory (lua_State *L) {
443 /* check 'allgc' list */ 442 /* check 'allgc' list */
444 checkgray(g, g->allgc); 443 checkgray(g, g->allgc);
445 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepall); 444 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepall);
446 isthread = 0; /* not traversing threads (yet) */
447 for (o = g->allgc; o != NULL; o = gch(o)->next) { 445 for (o = g->allgc; o != NULL; o = gch(o)->next) {
448 if (gch(o)->tt == LUA_TTHREAD) isthread = 1; /* now travesing threads... */
449 else lua_assert(!isthread); /* ... and only threads */
450 checkobject(g, o, maybedead); 446 checkobject(g, o, maybedead);
451 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); 447 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK));
452 lua_assert(testbit(o->gch.marked, NOLOCALBIT)); 448 lua_assert(testbit(o->gch.marked, NOLOCALBIT));
453 } 449 }
450 /* check thread list */
451 checkgray(g, obj2gco(g->mainthread));
452 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepthreads);
453 for (o = obj2gco(g->mainthread); o != NULL; o = gch(o)->next) {
454 checkobject(g, o, maybedead);
455 lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK));
456 lua_assert(testbit(o->gch.marked, NOLOCALBIT));
457 lua_assert(gch(o)->tt == LUA_TTHREAD);
458 }
454 /* check 'localfin' list */ 459 /* check 'localfin' list */
455 checkgray(g, g->localfin); 460 checkgray(g, g->localfin);
456 for (o = g->localfin; o != NULL; o = gch(o)->next) { 461 for (o = g->localfin; o != NULL; o = gch(o)->next) {
@@ -650,8 +655,8 @@ static int gc_local (lua_State *L) {
650 655
651static int gc_state (lua_State *L) { 656static int gc_state (lua_State *L) {
652 static const char *statenames[] = {"propagate", "atomic", 657 static const char *statenames[] = {"propagate", "atomic",
653 "sweeplocal", "sweeplocfin", "sweepfin", "sweepall", "sweeptobefnz", 658 "sweeplocal", "sweeplocfin", "sweepfin", "sweepall",
654 "sweepmainth", "pause", ""}; 659 "sweeptobefnz", "sweepthreads", "sweepend", "pause", ""};
655 int option = luaL_checkoption(L, 1, "", statenames); 660 int option = luaL_checkoption(L, 1, "", statenames);
656 if (option == GCSpause + 1) { 661 if (option == GCSpause + 1) {
657 lua_pushstring(L, statenames[G(L)->gcstate]); 662 lua_pushstring(L, statenames[G(L)->gcstate]);