diff options
| -rw-r--r-- | ltests.c | 19 |
1 files changed, 12 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.c,v 2.127 2012/05/08 13:53:33 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.128 2012/05/30 16:40:29 roberto Exp $ |
| 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 | */ |
| @@ -198,7 +198,7 @@ static void printobj (global_State *g, GCObject *o) { | |||
| 198 | if (p == NULL) i = 0; /* zero means 'not found' */ | 198 | if (p == NULL) i = 0; /* zero means 'not found' */ |
| 199 | else i = -i; /* negative means 'found in findobj list */ | 199 | else i = -i; /* negative means 'found in findobj list */ |
| 200 | } | 200 | } |
| 201 | printf("%d:%s(%p)-%c(%02X)", i, ttypename(gch(o)->tt), (void *)o, | 201 | printf("||%d:%s(%p)-%c(%02X)||", i, ttypename(gch(o)->tt), (void *)o, |
| 202 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); | 202 | isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| @@ -325,9 +325,9 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | 327 | ||
| 328 | static void checkobject (global_State *g, GCObject *o) { | 328 | static void checkobject (global_State *g, GCObject *o, int maybedead) { |
| 329 | if (isdead(g, o)) | 329 | if (isdead(g, o)) |
| 330 | lua_assert(issweepphase(g)); | 330 | lua_assert(maybedead); |
| 331 | else { | 331 | else { |
| 332 | if (g->gcstate == GCSpause && !isgenerational(g)) | 332 | if (g->gcstate == GCSpause && !isgenerational(g)) |
| 333 | lua_assert(iswhite(o)); | 333 | lua_assert(iswhite(o)); |
| @@ -427,6 +427,7 @@ int lua_checkmemory (lua_State *L) { | |||
| 427 | global_State *g = G(L); | 427 | global_State *g = G(L); |
| 428 | GCObject *o; | 428 | GCObject *o; |
| 429 | UpVal *uv; | 429 | UpVal *uv; |
| 430 | int maybedead; | ||
| 430 | if (keepinvariant(g)) { | 431 | if (keepinvariant(g)) { |
| 431 | lua_assert(!iswhite(obj2gco(g->mainthread))); | 432 | lua_assert(!iswhite(obj2gco(g->mainthread))); |
| 432 | lua_assert(!iswhite(gcvalue(&g->l_registry))); | 433 | lua_assert(!iswhite(gcvalue(&g->l_registry))); |
| @@ -437,17 +438,21 @@ int lua_checkmemory (lua_State *L) { | |||
| 437 | /* check 'allgc' list */ | 438 | /* check 'allgc' list */ |
| 438 | markgrays(g); | 439 | markgrays(g); |
| 439 | checkold(g, g->allgc); | 440 | checkold(g, g->allgc); |
| 441 | lua_assert(g->sweepgc == NULL || issweepphase(g)); | ||
| 442 | maybedead = 0; | ||
| 440 | for (o = g->allgc; o != NULL; o = gch(o)->next) { | 443 | for (o = g->allgc; o != NULL; o = gch(o)->next) { |
| 441 | checkobject(g, o); | 444 | if (g->sweepgc && o == *g->sweepgc) |
| 445 | maybedead = 1; /* part of the list not yet sweeped */ | ||
| 446 | checkobject(g, o, maybedead); | ||
| 442 | lua_assert(!testbit(o->gch.marked, SEPARATED)); | 447 | lua_assert(!testbit(o->gch.marked, SEPARATED)); |
| 443 | } | 448 | } |
| 444 | /* check 'finobj' list */ | 449 | /* check 'finobj' list */ |
| 445 | checkold(g, g->finobj); | 450 | checkold(g, g->finobj); |
| 446 | for (o = g->finobj; o != NULL; o = gch(o)->next) { | 451 | for (o = g->finobj; o != NULL; o = gch(o)->next) { |
| 447 | lua_assert(!isdead(g, o) && testbit(o->gch.marked, SEPARATED)); | 452 | lua_assert(testbit(o->gch.marked, SEPARATED)); |
| 448 | lua_assert(gch(o)->tt == LUA_TUSERDATA || | 453 | lua_assert(gch(o)->tt == LUA_TUSERDATA || |
| 449 | gch(o)->tt == LUA_TTABLE); | 454 | gch(o)->tt == LUA_TTABLE); |
| 450 | checkobject(g, o); | 455 | checkobject(g, o, 0); |
| 451 | } | 456 | } |
| 452 | /* check 'tobefnz' list */ | 457 | /* check 'tobefnz' list */ |
| 453 | checkold(g, g->tobefnz); | 458 | checkold(g, g->tobefnz); |
