From c006f085d98923e505c7fe8909944d3c182f8301 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 May 2010 13:46:49 -0300 Subject: [PATCH] new macro 'resetoldbit' --- lgc.c | 12 ++++++------ lgc.h | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lgc.c b/lgc.c index 49d00f3c..97f8bd4c 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.91 2010/05/07 18:19:36 roberto Exp roberto $ +** $Id: lgc.c,v 2.92 2010/05/07 18:43:24 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -164,7 +164,7 @@ void luaC_checkupvalcolor (global_State *g, UpVal *uv) { lua_assert(!isblack(o)); /* open upvalues are never black */ if (isgray(o)) { if (keepinvariant(g)) { - resetbit(o->gch.marked, OLDBIT); + resetoldbit(o); gray2black(o); /* it is being visited now */ markvalue(g, uv->v); } @@ -729,7 +729,7 @@ void luaC_separateudata (lua_State *L, int all) { p = &gch(curr)->next; /* don't bother with it */ else { l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ - resetbit(gch(curr)->marked, OLDBIT); /* may be old when 'all' */ + resetoldbit(curr); /* may be old when 'all' is true */ *p = gch(curr)->next; /* remove 'curr' from 'udgc' list */ gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ *lastnext = curr; @@ -745,8 +745,8 @@ void luaC_separateudata (lua_State *L, int all) { */ void luaC_checkfinalizer (lua_State *L, Udata *u) { global_State *g = G(L); - if (testbit(u->uv.marked, SEPARATED) || /* userdata is already separated... */ - isfinalized(&u->uv) || /* ... or is finalized... */ + if (testbit(u->uv.marked, SEPARATED) || /* udata is already separated... */ + isfinalized(&u->uv) || /* ... or is finalized... */ gfasttm(g, u->uv.metatable, TM_GC) == NULL) /* or has no finalizer? */ return; /* nothing to be done */ else { /* move 'u' to 'udgc' list */ @@ -756,7 +756,7 @@ void luaC_checkfinalizer (lua_State *L, Udata *u) { u->uv.next = g->udgc; /* link it in list 'udgc' */ g->udgc = obj2gco(u); l_setbit(u->uv.marked, SEPARATED); /* mark it as such */ - resetbit(u->uv.marked, OLDBIT); + resetoldbit(obj2gco(u)); } } diff --git a/lgc.h b/lgc.h index c8aed91c..938a1d49 100644 --- a/lgc.h +++ b/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.38 2010/05/07 18:08:05 roberto Exp roberto $ +** $Id: lgc.h,v 2.39 2010/05/07 18:43:51 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -80,6 +80,7 @@ #define SEPARATED 4 /* " ": it's in 'udgc' list or in 'tobefnz' */ #define FIXEDBIT 5 /* object is fixed (should not be collected) */ #define OLDBIT 6 /* object is old (only in generational mode) */ +/* bit 7 is currently used by tests (luaL_checkmemory) */ #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) @@ -90,6 +91,7 @@ (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) #define isold(x) testbit((x)->gch.marked, OLDBIT) +#define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT) #define otherwhite(g) (g->currentwhite ^ WHITEBITS) #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow)))