lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 992b6d2712c50ba2a20f161aaaddc7225734c5f1
parent 588dfa4ce5f7fa699495a2ee590a57a8305be420
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 11 Jun 2018 11:19:23 -0300

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

Diffstat:
Mlgc.h | 7++++---
Mltests.c | 25++++---------------------
2 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/lgc.h b/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 ** See Copyright Notice in lua.h */ @@ -69,13 +69,14 @@ /* ** 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 WHITE1BIT 4 /* object is white (type 1) */ #define BLACKBIT 5 /* object is black */ #define FINALIZEDBIT 6 /* object has been marked for finalization */ -#define TESTGRAYBIT 7 /* used by tests (luaL_checkmemory) */ + #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) diff --git a/ltests.c b/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 ** 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 */ while (o) { lua_assert(isgray(o) || getage(o) == G_TOUCHED2); - lua_assert(!testbit(o->marked, TESTGRAYBIT)); - l_setbit(o->marked, TESTGRAYBIT); switch (o->tt) { case LUA_TTABLE: o = gco2t(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 -** 'checkmemory' can check that all gray objects are in a gray list +** Check objects in gray lists. */ -static void markgrays (global_State *g) { +static void checkgrays (global_State *g) { if (!keepinvariant(g)) return; checkgraylist(g, g->gray); 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, GCObject *newl, GCObject *survival, GCObject *old, GCObject *reallyold) { GCObject *o; @@ -499,7 +485,7 @@ int lua_checkmemory (lua_State *L) { } lua_assert(!isdead(g, gcvalue(&g->l_registry))); lua_assert(g->sweepgc == NULL || issweepphase(g)); - markgrays(g); + checkgrays(g); /* check 'fixedgc' list */ for (o = g->fixedgc; o != NULL; o = o->next) { @@ -507,16 +493,13 @@ int lua_checkmemory (lua_State *L) { } /* check 'allgc' list */ - checkgray(g, g->allgc); maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); checklist(g, maybedead, 0, g->allgc, g->survival, g->old, g->reallyold); /* check 'finobj' list */ - checkgray(g, g->finobj); checklist(g, 0, 1, g->finobj, g->finobjsur, g->finobjold, g->finobjrold); /* check 'tobefnz' list */ - checkgray(g, g->tobefnz); for (o = g->tobefnz; o != NULL; o = o->next) { checkobject(g, o, 0, G_NEW); lua_assert(tofinalize(o));