Browse Source

no more 'TESTGRAYBIT' (to free this bit for real uses)

pull/19/head
Roberto Ierusalimschy 7 years ago
parent
commit
992b6d2712
  1. 7
      lgc.h
  2. 25
      ltests.c

7
lgc.h

@ -1,5 +1,5 @@
/* /*
** $Id: lgc.h,v 2.102 2018/02/19 13:55:34 roberto Exp roberto $ ** $Id: lgc.h,v 2.102 2018/02/19 20:06:56 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -69,13 +69,14 @@
/* /*
** Layout for bit use in 'marked' field. First three bits are ** Layout for bit use in 'marked' field. First three bits are
** used for object "age" in generational mode. ** used for object "age" in generational mode. Last bit is free
** to be used by respective objects.
*/ */
#define WHITE0BIT 3 /* object is white (type 0) */ #define WHITE0BIT 3 /* object is white (type 0) */
#define WHITE1BIT 4 /* object is white (type 1) */ #define WHITE1BIT 4 /* object is white (type 1) */
#define BLACKBIT 5 /* object is black */ #define BLACKBIT 5 /* object is black */
#define FINALIZEDBIT 6 /* object has been marked for finalization */ #define FINALIZEDBIT 6 /* object has been marked for finalization */
#define TESTGRAYBIT 7 /* used by tests (luaL_checkmemory) */
#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)

25
ltests.c

@ -1,5 +1,5 @@
/* /*
** $Id: ltests.c,v 2.242 2018/02/23 13:13:31 roberto Exp roberto $ ** $Id: ltests.c,v 2.243 2018/03/09 19:24:45 roberto Exp roberto $
** Internal Module for Debugging of the Lua Implementation ** Internal Module for Debugging of the Lua Implementation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -428,8 +428,6 @@ static void checkgraylist (global_State *g, GCObject *o) {
((void)g); /* better to keep it available if we need to print an object */ ((void)g); /* better to keep it available if we need to print an object */
while (o) { while (o) {
lua_assert(isgray(o) || getage(o) == G_TOUCHED2); lua_assert(isgray(o) || getage(o) == G_TOUCHED2);
lua_assert(!testbit(o->marked, TESTGRAYBIT));
l_setbit(o->marked, TESTGRAYBIT);
switch (o->tt) { switch (o->tt) {
case LUA_TTABLE: o = gco2t(o)->gclist; break; case LUA_TTABLE: o = gco2t(o)->gclist; break;
case LUA_TLCL: o = gco2lcl(o)->gclist; break; case LUA_TLCL: o = gco2lcl(o)->gclist; break;
@ -443,10 +441,9 @@ static void checkgraylist (global_State *g, GCObject *o) {
/* /*
** mark all objects in gray lists with the TESTGRAYBIT, so that ** Check objects in gray lists.
** 'checkmemory' can check that all gray objects are in a gray list
*/ */
static void markgrays (global_State *g) { static void checkgrays (global_State *g) {
if (!keepinvariant(g)) return; if (!keepinvariant(g)) return;
checkgraylist(g, g->gray); checkgraylist(g, g->gray);
checkgraylist(g, g->grayagain); checkgraylist(g, g->grayagain);
@ -456,17 +453,6 @@ static void markgrays (global_State *g) {
} }
static void checkgray (global_State *g, GCObject *o) {
for (; o != NULL; o = o->next) {
if ((isgray(o) && o->tt != LUA_TUPVAL) || getage(o) == G_TOUCHED2) {
lua_assert(!keepinvariant(g) || testbit(o->marked, TESTGRAYBIT));
resetbit(o->marked, TESTGRAYBIT);
}
lua_assert(!testbit(o->marked, TESTGRAYBIT));
}
}
static void checklist (global_State *g, int maybedead, int tof, static void checklist (global_State *g, int maybedead, int tof,
GCObject *newl, GCObject *survival, GCObject *old, GCObject *reallyold) { GCObject *newl, GCObject *survival, GCObject *old, GCObject *reallyold) {
GCObject *o; GCObject *o;
@ -499,7 +485,7 @@ int lua_checkmemory (lua_State *L) {
} }
lua_assert(!isdead(g, gcvalue(&g->l_registry))); lua_assert(!isdead(g, gcvalue(&g->l_registry)));
lua_assert(g->sweepgc == NULL || issweepphase(g)); lua_assert(g->sweepgc == NULL || issweepphase(g));
markgrays(g); checkgrays(g);
/* check 'fixedgc' list */ /* check 'fixedgc' list */
for (o = g->fixedgc; o != NULL; o = o->next) { for (o = g->fixedgc; o != NULL; o = o->next) {
@ -507,16 +493,13 @@ int lua_checkmemory (lua_State *L) {
} }
/* check 'allgc' list */ /* check 'allgc' list */
checkgray(g, g->allgc);
maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc);
checklist(g, maybedead, 0, g->allgc, g->survival, g->old, g->reallyold); checklist(g, maybedead, 0, g->allgc, g->survival, g->old, g->reallyold);
/* check 'finobj' list */ /* check 'finobj' list */
checkgray(g, g->finobj);
checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold, g->finobjrold); checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold, g->finobjrold);
/* check 'tobefnz' list */ /* check 'tobefnz' list */
checkgray(g, g->tobefnz);
for (o = g->tobefnz; o != NULL; o = o->next) { for (o = g->tobefnz; o != NULL; o = o->next) {
checkobject(g, o, 0, G_NEW); checkobject(g, o, 0, G_NEW);
lua_assert(tofinalize(o)); lua_assert(tofinalize(o));

Loading…
Cancel
Save