Browse Source

new macro 'resetoldbit'

pull/9/head
Roberto Ierusalimschy 15 years ago
parent
commit
c006f085d9
  1. 12
      lgc.c
  2. 4
      lgc.h

12
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 ** Garbage Collector
** See Copyright Notice in lua.h ** 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 */ lua_assert(!isblack(o)); /* open upvalues are never black */
if (isgray(o)) { if (isgray(o)) {
if (keepinvariant(g)) { if (keepinvariant(g)) {
resetbit(o->gch.marked, OLDBIT); resetoldbit(o);
gray2black(o); /* it is being visited now */ gray2black(o); /* it is being visited now */
markvalue(g, uv->v); 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 */ p = &gch(curr)->next; /* don't bother with it */
else { else {
l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ 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 */ *p = gch(curr)->next; /* remove 'curr' from 'udgc' list */
gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */
*lastnext = curr; *lastnext = curr;
@ -745,8 +745,8 @@ void luaC_separateudata (lua_State *L, int all) {
*/ */
void luaC_checkfinalizer (lua_State *L, Udata *u) { void luaC_checkfinalizer (lua_State *L, Udata *u) {
global_State *g = G(L); global_State *g = G(L);
if (testbit(u->uv.marked, SEPARATED) || /* userdata is already separated... */ if (testbit(u->uv.marked, SEPARATED) || /* udata is already separated... */
isfinalized(&u->uv) || /* ... or is finalized... */ isfinalized(&u->uv) || /* ... or is finalized... */
gfasttm(g, u->uv.metatable, TM_GC) == NULL) /* or has no finalizer? */ gfasttm(g, u->uv.metatable, TM_GC) == NULL) /* or has no finalizer? */
return; /* nothing to be done */ return; /* nothing to be done */
else { /* move 'u' to 'udgc' list */ 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' */ u->uv.next = g->udgc; /* link it in list 'udgc' */
g->udgc = obj2gco(u); g->udgc = obj2gco(u);
l_setbit(u->uv.marked, SEPARATED); /* mark it as such */ l_setbit(u->uv.marked, SEPARATED); /* mark it as such */
resetbit(u->uv.marked, OLDBIT); resetoldbit(obj2gco(u));
} }
} }

4
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 ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -80,6 +80,7 @@
#define SEPARATED 4 /* " ": it's in 'udgc' list or in 'tobefnz' */ #define SEPARATED 4 /* " ": it's in 'udgc' list or in 'tobefnz' */
#define FIXEDBIT 5 /* object is fixed (should not be collected) */ #define FIXEDBIT 5 /* object is fixed (should not be collected) */
#define OLDBIT 6 /* object is old (only in generational mode) */ #define OLDBIT 6 /* object is old (only in generational mode) */
/* bit 7 is currently used by tests (luaL_checkmemory) */
#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
@ -90,6 +91,7 @@
(!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT)))
#define isold(x) testbit((x)->gch.marked, OLDBIT) #define isold(x) testbit((x)->gch.marked, OLDBIT)
#define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT)
#define otherwhite(g) (g->currentwhite ^ WHITEBITS) #define otherwhite(g) (g->currentwhite ^ WHITEBITS)
#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow)))

Loading…
Cancel
Save