mirror of https://github.com/rusefi/lua.git
new macro 'resetoldbit'
This commit is contained in:
parent
a48e330f37
commit
c006f085d9
12
lgc.c
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
|
||||
** 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
lgc.h
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
|
||||
** 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)))
|
||||
|
|
Loading…
Reference in New Issue