diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-04 12:34:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-09-04 12:34:24 -0300 |
commit | 0ad15fc10041f59b5466fe902637b1a2fb64565d (patch) | |
tree | 89da5de9bfc3af18402ead7fa94fd6f784bc6e8e | |
parent | aeff4f79fa10caef29617652aa49b77055f4045e (diff) | |
download | lua-0ad15fc10041f59b5466fe902637b1a2fb64565d.tar.gz lua-0ad15fc10041f59b5466fe902637b1a2fb64565d.tar.bz2 lua-0ad15fc10041f59b5466fe902637b1a2fb64565d.zip |
better (and correct!) control of 'maybedead'
-rw-r--r-- | ltests.c | 39 |
1 files changed, 19 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.152 2013/08/30 19:14:26 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.153 2013/09/03 15:37:10 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 | */ |
@@ -335,7 +335,7 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
335 | 335 | ||
336 | static void checkobject (global_State *g, GCObject *o, int maybedead) { | 336 | static void checkobject (global_State *g, GCObject *o, int maybedead) { |
337 | if (isdead(g, o)) | 337 | if (isdead(g, o)) |
338 | lua_assert(maybedead && issweepphase(g)); | 338 | lua_assert(maybedead); |
339 | else { | 339 | else { |
340 | lua_assert(g->gcstate != GCSpause || iswhite(o)); | 340 | lua_assert(g->gcstate != GCSpause || iswhite(o)); |
341 | lua_assert(!islocal(o) || !testbit(gch(o)->marked, LOCALMARK)); | 341 | lua_assert(!islocal(o) || !testbit(gch(o)->marked, LOCALMARK)); |
@@ -431,20 +431,32 @@ int lua_checkmemory (lua_State *L) { | |||
431 | lua_assert(!isdead(g, gcvalue(&g->l_registry))); | 431 | lua_assert(!isdead(g, gcvalue(&g->l_registry))); |
432 | checkstack(g, g->mainthread); | 432 | checkstack(g, g->mainthread); |
433 | resetbit(g->mainthread->marked, TESTGRAYBIT); | 433 | resetbit(g->mainthread->marked, TESTGRAYBIT); |
434 | /* check 'allgc' list */ | 434 | lua_assert(g->sweepgc == NULL || issweepphase(g)); |
435 | markgrays(g); | 435 | markgrays(g); |
436 | /* check 'localgc' list */ | ||
437 | checkgray(g, g->localgc); | ||
438 | maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweeplocal); | ||
439 | for (o = g->localgc; o != NULL; o = gch(o)->next) { | ||
440 | checkobject(g, o, maybedead); | ||
441 | lua_assert(!tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); | ||
442 | } | ||
443 | /* check 'allgc' list */ | ||
436 | checkgray(g, g->allgc); | 444 | checkgray(g, g->allgc); |
437 | lua_assert(g->sweepgc == NULL || issweepphase(g)); | 445 | maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSsweepall); |
438 | maybedead = 0; | ||
439 | isthread = 0; /* not traversing threads (yet) */ | 446 | isthread = 0; /* not traversing threads (yet) */ |
440 | for (o = g->allgc; o != NULL; o = gch(o)->next) { | 447 | for (o = g->allgc; o != NULL; o = gch(o)->next) { |
441 | if (g->sweepgc && o == *g->sweepgc) | ||
442 | maybedead = 1; /* part of the list not yet swept */ | ||
443 | if (gch(o)->tt == LUA_TTHREAD) isthread = 1; /* now travesing threads... */ | 448 | if (gch(o)->tt == LUA_TTHREAD) isthread = 1; /* now travesing threads... */ |
444 | else lua_assert(!isthread); /* ... and only threads */ | 449 | else lua_assert(!isthread); /* ... and only threads */ |
445 | checkobject(g, o, maybedead); | 450 | checkobject(g, o, maybedead); |
446 | lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); | 451 | lua_assert(!tofinalize(o) && testbit(o->gch.marked, LOCALMARK)); |
447 | } | 452 | } |
453 | /* check 'localfin' list */ | ||
454 | checkgray(g, g->localfin); | ||
455 | for (o = g->localfin; o != NULL; o = gch(o)->next) { | ||
456 | checkobject(g, o, 0); | ||
457 | lua_assert(tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); | ||
458 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); | ||
459 | } | ||
448 | /* check 'finobj' list */ | 460 | /* check 'finobj' list */ |
449 | checkgray(g, g->finobj); | 461 | checkgray(g, g->finobj); |
450 | for (o = g->finobj; o != NULL; o = gch(o)->next) { | 462 | for (o = g->finobj; o != NULL; o = gch(o)->next) { |
@@ -460,19 +472,6 @@ int lua_checkmemory (lua_State *L) { | |||
460 | lua_assert(!isdead(g, o) && tofinalize(o)); | 472 | lua_assert(!isdead(g, o) && tofinalize(o)); |
461 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); | 473 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); |
462 | } | 474 | } |
463 | /* check 'localgc' list */ | ||
464 | checkgray(g, g->localgc); | ||
465 | for (o = g->localgc; o != NULL; o = gch(o)->next) { | ||
466 | checkobject(g, o, 1); | ||
467 | lua_assert(!tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); | ||
468 | } | ||
469 | /* check 'localfin' list */ | ||
470 | checkgray(g, g->localfin); | ||
471 | for (o = g->localfin; o != NULL; o = gch(o)->next) { | ||
472 | checkobject(g, o, 0); | ||
473 | lua_assert(tofinalize(o) && !testbit(o->gch.marked, LOCALMARK)); | ||
474 | lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); | ||
475 | } | ||
476 | return 0; | 475 | return 0; |
477 | } | 476 | } |
478 | 477 | ||