diff options
-rw-r--r-- | lgc.c | 12 | ||||
-rw-r--r-- | lgc.h | 4 |
2 files changed, 9 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.91 2010/05/07 18:19:36 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.92 2010/05/07 18:43:24 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -164,7 +164,7 @@ void luaC_checkupvalcolor (global_State *g, UpVal *uv) { | |||
164 | lua_assert(!isblack(o)); /* open upvalues are never black */ | 164 | lua_assert(!isblack(o)); /* open upvalues are never black */ |
165 | if (isgray(o)) { | 165 | if (isgray(o)) { |
166 | if (keepinvariant(g)) { | 166 | if (keepinvariant(g)) { |
167 | resetbit(o->gch.marked, OLDBIT); | 167 | resetoldbit(o); |
168 | gray2black(o); /* it is being visited now */ | 168 | gray2black(o); /* it is being visited now */ |
169 | markvalue(g, uv->v); | 169 | markvalue(g, uv->v); |
170 | } | 170 | } |
@@ -729,7 +729,7 @@ void luaC_separateudata (lua_State *L, int all) { | |||
729 | p = &gch(curr)->next; /* don't bother with it */ | 729 | p = &gch(curr)->next; /* don't bother with it */ |
730 | else { | 730 | else { |
731 | l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ | 731 | l_setbit(gch(curr)->marked, FINALIZEDBIT); /* won't be finalized again */ |
732 | resetbit(gch(curr)->marked, OLDBIT); /* may be old when 'all' */ | 732 | resetoldbit(curr); /* may be old when 'all' is true */ |
733 | *p = gch(curr)->next; /* remove 'curr' from 'udgc' list */ | 733 | *p = gch(curr)->next; /* remove 'curr' from 'udgc' list */ |
734 | gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ | 734 | gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ |
735 | *lastnext = curr; | 735 | *lastnext = curr; |
@@ -745,8 +745,8 @@ void luaC_separateudata (lua_State *L, int all) { | |||
745 | */ | 745 | */ |
746 | void luaC_checkfinalizer (lua_State *L, Udata *u) { | 746 | void luaC_checkfinalizer (lua_State *L, Udata *u) { |
747 | global_State *g = G(L); | 747 | global_State *g = G(L); |
748 | if (testbit(u->uv.marked, SEPARATED) || /* userdata is already separated... */ | 748 | if (testbit(u->uv.marked, SEPARATED) || /* udata is already separated... */ |
749 | isfinalized(&u->uv) || /* ... or is finalized... */ | 749 | isfinalized(&u->uv) || /* ... or is finalized... */ |
750 | gfasttm(g, u->uv.metatable, TM_GC) == NULL) /* or has no finalizer? */ | 750 | gfasttm(g, u->uv.metatable, TM_GC) == NULL) /* or has no finalizer? */ |
751 | return; /* nothing to be done */ | 751 | return; /* nothing to be done */ |
752 | else { /* move 'u' to 'udgc' list */ | 752 | else { /* move 'u' to 'udgc' list */ |
@@ -756,7 +756,7 @@ void luaC_checkfinalizer (lua_State *L, Udata *u) { | |||
756 | u->uv.next = g->udgc; /* link it in list 'udgc' */ | 756 | u->uv.next = g->udgc; /* link it in list 'udgc' */ |
757 | g->udgc = obj2gco(u); | 757 | g->udgc = obj2gco(u); |
758 | l_setbit(u->uv.marked, SEPARATED); /* mark it as such */ | 758 | l_setbit(u->uv.marked, SEPARATED); /* mark it as such */ |
759 | resetbit(u->uv.marked, OLDBIT); | 759 | resetoldbit(obj2gco(u)); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | 762 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.38 2010/05/07 18:08:05 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.39 2010/05/07 18:43:51 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -80,6 +80,7 @@ | |||
80 | #define SEPARATED 4 /* " ": it's in 'udgc' list or in 'tobefnz' */ | 80 | #define SEPARATED 4 /* " ": it's in 'udgc' list or in 'tobefnz' */ |
81 | #define FIXEDBIT 5 /* object is fixed (should not be collected) */ | 81 | #define FIXEDBIT 5 /* object is fixed (should not be collected) */ |
82 | #define OLDBIT 6 /* object is old (only in generational mode) */ | 82 | #define OLDBIT 6 /* object is old (only in generational mode) */ |
83 | /* bit 7 is currently used by tests (luaL_checkmemory) */ | ||
83 | 84 | ||
84 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | 85 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) |
85 | 86 | ||
@@ -90,6 +91,7 @@ | |||
90 | (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) | 91 | (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) |
91 | 92 | ||
92 | #define isold(x) testbit((x)->gch.marked, OLDBIT) | 93 | #define isold(x) testbit((x)->gch.marked, OLDBIT) |
94 | #define resetoldbit(o) resetbit((o)->gch.marked, OLDBIT) | ||
93 | 95 | ||
94 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) | 96 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) |
95 | #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) | 97 | #define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) |