aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lgc.c64
-rw-r--r--lgc.h16
-rw-r--r--lobject.h10
-rw-r--r--lstate.h26
-rw-r--r--ltests.c36
5 files changed, 71 insertions, 81 deletions
diff --git a/lgc.c b/lgc.c
index 495eb4ac..24278dab 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.183 2014/05/25 19:08:32 roberto Exp roberto $ 2** $Id: lgc.c,v 2.184 2014/06/30 19:48:08 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*/
@@ -62,10 +62,10 @@
62*/ 62*/
63#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS)) 63#define maskcolors (~(bitmask(BLACKBIT) | WHITEBITS))
64#define makewhite(g,x) \ 64#define makewhite(g,x) \
65 (gch(x)->marked = cast_byte((gch(x)->marked & maskcolors) | luaC_white(g))) 65 (x->marked = cast_byte((x->marked & maskcolors) | luaC_white(g)))
66 66
67#define white2gray(x) resetbits(gch(x)->marked, WHITEBITS) 67#define white2gray(x) resetbits(x->marked, WHITEBITS)
68#define black2gray(x) resetbit(gch(x)->marked, BLACKBIT) 68#define black2gray(x) resetbit(x->marked, BLACKBIT)
69 69
70 70
71#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) 71#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
@@ -141,7 +141,7 @@ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
141 global_State *g = G(L); 141 global_State *g = G(L);
142 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o)); 142 lua_assert(isblack(o) && iswhite(v) && !isdead(g, v) && !isdead(g, o));
143 lua_assert(g->gcstate != GCSpause); 143 lua_assert(g->gcstate != GCSpause);
144 lua_assert(gch(o)->tt != LUA_TTABLE); /* tables use a back barrier */ 144 lua_assert(o->tt != LUA_TTABLE); /* tables use a back barrier */
145 if (keepinvariant(g)) /* must keep invariant? */ 145 if (keepinvariant(g)) /* must keep invariant? */
146 reallymarkobject(g, v); /* restore invariant */ 146 reallymarkobject(g, v); /* restore invariant */
147 else { /* sweep phase */ 147 else { /* sweep phase */
@@ -159,7 +159,7 @@ void luaC_barrier_ (lua_State *L, GCObject *o, GCObject *v) {
159*/ 159*/
160void luaC_barrierback_ (lua_State *L, GCObject *o) { 160void luaC_barrierback_ (lua_State *L, GCObject *o) {
161 global_State *g = G(L); 161 global_State *g = G(L);
162 lua_assert(isblack(o) && !isdead(g, o) && gch(o)->tt == LUA_TTABLE); 162 lua_assert(isblack(o) && !isdead(g, o) && o->tt == LUA_TTABLE);
163 black2gray(o); /* make object gray (again) */ 163 black2gray(o); /* make object gray (again) */
164 gco2t(o)->gclist = g->grayagain; 164 gco2t(o)->gclist = g->grayagain;
165 g->grayagain = o; 165 g->grayagain = o;
@@ -185,8 +185,8 @@ void luaC_fix (lua_State *L, GCObject *o) {
185 global_State *g = G(L); 185 global_State *g = G(L);
186 lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */ 186 lua_assert(g->allgc == o); /* object must be 1st in 'allgc' list! */
187 white2gray(o); /* they will be gray forever */ 187 white2gray(o); /* they will be gray forever */
188 g->allgc = o->gch.next; /* remove object from 'allgc' list */ 188 g->allgc = o->next; /* remove object from 'allgc' list */
189 o->gch.next = g->fixedgc; /* link it to 'fixedgc' list */ 189 o->next = g->fixedgc; /* link it to 'fixedgc' list */
190 g->fixedgc = o; 190 g->fixedgc = o;
191} 191}
192 192
@@ -198,9 +198,9 @@ void luaC_fix (lua_State *L, GCObject *o) {
198GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) { 198GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) {
199 global_State *g = G(L); 199 global_State *g = G(L);
200 GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz)); 200 GCObject *o = cast(GCObject *, luaM_newobject(L, novariant(tt), sz));
201 gch(o)->marked = luaC_white(g); 201 o->marked = luaC_white(g);
202 gch(o)->tt = tt; 202 o->tt = tt;
203 gch(o)->next = g->allgc; 203 o->next = g->allgc;
204 g->allgc = o; 204 g->allgc = o;
205 return o; 205 return o;
206} 206}
@@ -225,7 +225,7 @@ GCObject *luaC_newobj (lua_State *L, int tt, size_t sz) {
225static void reallymarkobject (global_State *g, GCObject *o) { 225static void reallymarkobject (global_State *g, GCObject *o) {
226 reentry: 226 reentry:
227 white2gray(o); 227 white2gray(o);
228 switch (gch(o)->tt) { 228 switch (o->tt) {
229 case LUA_TSHRSTR: 229 case LUA_TSHRSTR:
230 case LUA_TLNGSTR: { 230 case LUA_TLNGSTR: {
231 gray2black(o); 231 gray2black(o);
@@ -288,7 +288,7 @@ static void markmt (global_State *g) {
288*/ 288*/
289static void markbeingfnz (global_State *g) { 289static void markbeingfnz (global_State *g) {
290 GCObject *o; 290 GCObject *o;
291 for (o = g->tobefnz; o != NULL; o = gch(o)->next) 291 for (o = g->tobefnz; o != NULL; o = o->next)
292 markobject(g, o); 292 markobject(g, o);
293} 293}
294 294
@@ -528,7 +528,7 @@ static void propagatemark (global_State *g) {
528 GCObject *o = g->gray; 528 GCObject *o = g->gray;
529 lua_assert(isgray(o)); 529 lua_assert(isgray(o));
530 gray2black(o); 530 gray2black(o);
531 switch (gch(o)->tt) { 531 switch (o->tt) {
532 case LUA_TTABLE: { 532 case LUA_TTABLE: {
533 Table *h = gco2t(o); 533 Table *h = gco2t(o);
534 g->gray = h->gclist; /* remove from 'gray' list */ 534 g->gray = h->gclist; /* remove from 'gray' list */
@@ -685,7 +685,7 @@ static void freeLclosure (lua_State *L, LClosure *cl) {
685 685
686 686
687static void freeobj (lua_State *L, GCObject *o) { 687static void freeobj (lua_State *L, GCObject *o) {
688 switch (gch(o)->tt) { 688 switch (o->tt) {
689 case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break; 689 case LUA_TPROTO: luaF_freeproto(L, gco2p(o)); break;
690 case LUA_TLCL: { 690 case LUA_TLCL: {
691 freeLclosure(L, gco2lcl(o)); 691 freeLclosure(L, gco2lcl(o));
@@ -727,14 +727,14 @@ static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
727 int white = luaC_white(g); /* current white */ 727 int white = luaC_white(g); /* current white */
728 while (*p != NULL && count-- > 0) { 728 while (*p != NULL && count-- > 0) {
729 GCObject *curr = *p; 729 GCObject *curr = *p;
730 int marked = gch(curr)->marked; 730 int marked = curr->marked;
731 if (isdeadm(ow, marked)) { /* is 'curr' dead? */ 731 if (isdeadm(ow, marked)) { /* is 'curr' dead? */
732 *p = gch(curr)->next; /* remove 'curr' from list */ 732 *p = curr->next; /* remove 'curr' from list */
733 freeobj(L, curr); /* erase 'curr' */ 733 freeobj(L, curr); /* erase 'curr' */
734 } 734 }
735 else { /* update marks */ 735 else { /* update marks */
736 gch(curr)->marked = cast_byte((marked & maskcolors) | white); 736 curr->marked = cast_byte((marked & maskcolors) | white);
737 p = &gch(curr)->next; /* go to next element */ 737 p = &curr->next; /* go to next element */
738 } 738 }
739 } 739 }
740 return (*p == NULL) ? NULL : p; 740 return (*p == NULL) ? NULL : p;
@@ -781,10 +781,10 @@ static void checkSizes (lua_State *L, global_State *g) {
781static GCObject *udata2finalize (global_State *g) { 781static GCObject *udata2finalize (global_State *g) {
782 GCObject *o = g->tobefnz; /* get first element */ 782 GCObject *o = g->tobefnz; /* get first element */
783 lua_assert(tofinalize(o)); 783 lua_assert(tofinalize(o));
784 g->tobefnz = gch(o)->next; /* remove it from 'tobefnz' list */ 784 g->tobefnz = o->next; /* remove it from 'tobefnz' list */
785 gch(o)->next = g->allgc; /* return it to 'allgc' list */ 785 o->next = g->allgc; /* return it to 'allgc' list */
786 g->allgc = o; 786 g->allgc = o;
787 resetbit(gch(o)->marked, FINALIZEDBIT); /* object is "normal" again */ 787 resetbit(o->marked, FINALIZEDBIT); /* object is "normal" again */
788 if (issweepphase(g)) 788 if (issweepphase(g))
789 makewhite(g, o); /* "sweep" object */ 789 makewhite(g, o); /* "sweep" object */
790 return o; 790 return o;
@@ -859,7 +859,7 @@ static void callallpendingfinalizers (lua_State *L, int propagateerrors) {
859*/ 859*/
860static GCObject **findlast (GCObject **p) { 860static GCObject **findlast (GCObject **p) {
861 while (*p != NULL) 861 while (*p != NULL)
862 p = &gch(*p)->next; 862 p = &(*p)->next;
863 return p; 863 return p;
864} 864}
865 865
@@ -875,12 +875,12 @@ static void separatetobefnz (global_State *g, int all) {
875 while ((curr = *p) != NULL) { /* traverse all finalizable objects */ 875 while ((curr = *p) != NULL) { /* traverse all finalizable objects */
876 lua_assert(tofinalize(curr)); 876 lua_assert(tofinalize(curr));
877 if (!(iswhite(curr) || all)) /* not being collected? */ 877 if (!(iswhite(curr) || all)) /* not being collected? */
878 p = &gch(curr)->next; /* don't bother with it */ 878 p = &curr->next; /* don't bother with it */
879 else { 879 else {
880 *p = gch(curr)->next; /* remove 'curr' from "fin" list */ 880 *p = curr->next; /* remove 'curr' from "fin" list */
881 gch(curr)->next = *lastnext; /* link at the end of 'tobefnz' list */ 881 curr->next = *lastnext; /* link at the end of 'tobefnz' list */
882 *lastnext = curr; 882 *lastnext = curr;
883 lastnext = &gch(curr)->next; 883 lastnext = &curr->next;
884 } 884 }
885 } 885 }
886} 886}
@@ -899,15 +899,15 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
899 GCObject **p; 899 GCObject **p;
900 if (issweepphase(g)) { 900 if (issweepphase(g)) {
901 makewhite(g, o); /* "sweep" object 'o' */ 901 makewhite(g, o); /* "sweep" object 'o' */
902 if (g->sweepgc == &o->gch.next) /* should not remove 'sweepgc' object */ 902 if (g->sweepgc == &o->next) /* should not remove 'sweepgc' object */
903 g->sweepgc = sweeptolive(L, g->sweepgc, NULL); /* change 'sweepgc' */ 903 g->sweepgc = sweeptolive(L, g->sweepgc, NULL); /* change 'sweepgc' */
904 } 904 }
905 /* search for pointer pointing to 'o' */ 905 /* search for pointer pointing to 'o' */
906 for (p = &g->allgc; *p != o; p = &gch(*p)->next) { /* empty */ } 906 for (p = &g->allgc; *p != o; p = &(*p)->next) { /* empty */ }
907 *p = o->gch.next; /* remove 'o' from 'allgc' list */ 907 *p = o->next; /* remove 'o' from 'allgc' list */
908 o->gch.next = g->finobj; /* link it in "fin" list */ 908 o->next = g->finobj; /* link it in "fin" list */
909 g->finobj = o; 909 g->finobj = o;
910 l_setbit(o->gch.marked, FINALIZEDBIT); /* mark it as such */ 910 l_setbit(o->marked, FINALIZEDBIT); /* mark it as such */
911 } 911 }
912} 912}
913 913
diff --git a/lgc.h b/lgc.h
index c94b91ce..1d0403f3 100644
--- a/lgc.h
+++ b/lgc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.h,v 2.81 2014/02/18 13:46:26 roberto Exp roberto $ 2** $Id: lgc.h,v 2.82 2014/03/19 18:51:16 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*/
@@ -84,19 +84,19 @@
84#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 84#define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT)
85 85
86 86
87#define iswhite(x) testbits((x)->gch.marked, WHITEBITS) 87#define iswhite(x) testbits((x)->marked, WHITEBITS)
88#define isblack(x) testbit((x)->gch.marked, BLACKBIT) 88#define isblack(x) testbit((x)->marked, BLACKBIT)
89#define isgray(x) /* neither white nor black */ \ 89#define isgray(x) /* neither white nor black */ \
90 (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) 90 (!testbits((x)->marked, WHITEBITS | bitmask(BLACKBIT)))
91 91
92#define tofinalize(x) testbit((x)->gch.marked, FINALIZEDBIT) 92#define tofinalize(x) testbit((x)->marked, FINALIZEDBIT)
93 93
94#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS) 94#define otherwhite(g) ((g)->currentwhite ^ WHITEBITS)
95#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow))) 95#define isdeadm(ow,m) (!(((m) ^ WHITEBITS) & (ow)))
96#define isdead(g,v) isdeadm(otherwhite(g), (v)->gch.marked) 96#define isdead(g,v) isdeadm(otherwhite(g), (v)->marked)
97 97
98#define changewhite(x) ((x)->gch.marked ^= WHITEBITS) 98#define changewhite(x) ((x)->marked ^= WHITEBITS)
99#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) 99#define gray2black(x) l_setbit((x)->marked, BLACKBIT)
100 100
101#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) 101#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
102 102
diff --git a/lobject.h b/lobject.h
index d55a347f..05008668 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.94 2014/06/19 18:39:36 roberto Exp roberto $ 2** $Id: lobject.h,v 2.95 2014/07/17 17:09:50 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -85,9 +85,7 @@ typedef struct GCObject GCObject;
85** Common type has only the common header 85** Common type has only the common header
86*/ 86*/
87struct GCObject { 87struct GCObject {
88 struct { 88 CommonHeader;
89 CommonHeader;
90 } gch;
91}; 89};
92 90
93 91
@@ -179,7 +177,7 @@ typedef struct lua_TValue TValue;
179 177
180 178
181/* Macros for internal tests */ 179/* Macros for internal tests */
182#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) 180#define righttt(obj) (ttype(obj) == gcvalue(obj)->tt)
183 181
184#define checkliveness(g,obj) \ 182#define checkliveness(g,obj) \
185 lua_longassert(!iscollectable(obj) || \ 183 lua_longassert(!iscollectable(obj) || \
@@ -208,7 +206,7 @@ typedef struct lua_TValue TValue;
208 206
209#define setgcovalue(L,obj,x) \ 207#define setgcovalue(L,obj,x) \
210 { TValue *io = (obj); GCObject *i_g=(x); \ 208 { TValue *io = (obj); GCObject *i_g=(x); \
211 val_(io).gc = i_g; settt_(io, ctb(gch(i_g)->tt)); } 209 val_(io).gc = i_g; settt_(io, ctb(i_g->tt)); }
212 210
213#define setsvalue(L,obj,x) \ 211#define setsvalue(L,obj,x) \
214 { TValue *io = (obj); TString *x_ = (x); \ 212 { TValue *io = (obj); TString *x_ = (x); \
diff --git a/lstate.h b/lstate.h
index e7feb099..dafaefea 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.108 2014/07/17 13:53:37 roberto Exp roberto $ 2** $Id: lstate.h,v 2.109 2014/07/17 17:09:50 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -183,29 +183,21 @@ union GCUnion {
183}; 183};
184 184
185 185
186#define gch(o) (&(o)->gch)
187
188#define cast_u(o) cast(union GCUnion *, (o)) 186#define cast_u(o) cast(union GCUnion *, (o))
189 187
190/* macros to convert a GCObject into a specific value */ 188/* macros to convert a GCObject into a specific value */
191#define rawgco2ts(o) \ 189#define rawgco2ts(o) \
192 check_exp(novariant((o)->gch.tt) == LUA_TSTRING, &((cast_u(o))->ts)) 190 check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
193#define gco2ts(o) (&rawgco2ts(o)->tsv) 191#define gco2ts(o) (&rawgco2ts(o)->tsv)
194#define rawgco2u(o) \ 192#define rawgco2u(o) check_exp((o)->tt == LUA_TUSERDATA, &((cast_u(o))->u))
195 check_exp((o)->gch.tt == LUA_TUSERDATA, &((cast_u(o))->u))
196#define gco2u(o) (&rawgco2u(o)->uv) 193#define gco2u(o) (&rawgco2u(o)->uv)
197#define gco2lcl(o) \ 194#define gco2lcl(o) check_exp((o)->tt == LUA_TLCL, &((cast_u(o))->cl.l))
198 check_exp((o)->gch.tt == LUA_TLCL, &((cast_u(o))->cl.l)) 195#define gco2ccl(o) check_exp((o)->tt == LUA_TCCL, &((cast_u(o))->cl.c))
199#define gco2ccl(o) \
200 check_exp((o)->gch.tt == LUA_TCCL, &((cast_u(o))->cl.c))
201#define gco2cl(o) \ 196#define gco2cl(o) \
202 check_exp(novariant((o)->gch.tt) == LUA_TFUNCTION, &((cast_u(o))->cl)) 197 check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
203#define gco2t(o) \ 198#define gco2t(o) check_exp((o)->tt == LUA_TTABLE, &((cast_u(o))->h))
204 check_exp((o)->gch.tt == LUA_TTABLE, &((cast_u(o))->h)) 199#define gco2p(o) check_exp((o)->tt == LUA_TPROTO, &((cast_u(o))->p))
205#define gco2p(o) \ 200#define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th))
206 check_exp((o)->gch.tt == LUA_TPROTO, &((cast_u(o))->p))
207#define gco2th(o) \
208 check_exp((o)->gch.tt == LUA_TTHREAD, &((cast_u(o))->th))
209 201
210 202
211/* macro to convert any Lua object into a GCObject */ 203/* macro to convert any Lua object into a GCObject */
diff --git a/ltests.c b/ltests.c
index 803b3be2..f054b2f0 100644
--- a/ltests.c
+++ b/ltests.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltests.c,v 2.175 2014/07/16 14:51:36 roberto Exp roberto $ 2** $Id: ltests.c,v 2.176 2014/07/17 13:53:37 roberto Exp roberto $
3** Internal Module for Debugging of the Lua Implementation 3** Internal Module for Debugging of the Lua Implementation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -190,8 +190,8 @@ static int testobjref1 (global_State *g, GCObject *f, GCObject *t) {
190 190
191static void printobj (global_State *g, GCObject *o) { 191static void printobj (global_State *g, GCObject *o) {
192 printf("||%s(%p)-%c(%02X)||", 192 printf("||%s(%p)-%c(%02X)||",
193 ttypename(novariant(gch(o)->tt)), (void *)o, 193 ttypename(novariant(o->tt)), (void *)o,
194 isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', gch(o)->marked); 194 isdead(g,o)?'d':isblack(o)?'b':iswhite(o)?'w':'g', o->marked);
195} 195}
196 196
197 197
@@ -316,7 +316,7 @@ static void checkobject (global_State *g, GCObject *o, int maybedead) {
316 lua_assert(maybedead); 316 lua_assert(maybedead);
317 else { 317 else {
318 lua_assert(g->gcstate != GCSpause || iswhite(o)); 318 lua_assert(g->gcstate != GCSpause || iswhite(o));
319 switch (gch(o)->tt) { 319 switch (o->tt) {
320 case LUA_TUSERDATA: { 320 case LUA_TUSERDATA: {
321 TValue uservalue; 321 TValue uservalue;
322 Table *mt = gco2u(o)->metatable; 322 Table *mt = gco2u(o)->metatable;
@@ -362,9 +362,9 @@ static void checkgraylist (global_State *g, GCObject *o) {
362 ((void)g); /* better to keep it available if we need to print an object */ 362 ((void)g); /* better to keep it available if we need to print an object */
363 while (o) { 363 while (o) {
364 lua_assert(isgray(o)); 364 lua_assert(isgray(o));
365 lua_assert(!testbit(o->gch.marked, TESTGRAYBIT)); 365 lua_assert(!testbit(o->marked, TESTGRAYBIT));
366 l_setbit(o->gch.marked, TESTGRAYBIT); 366 l_setbit(o->marked, TESTGRAYBIT);
367 switch (gch(o)->tt) { 367 switch (o->tt) {
368 case LUA_TTABLE: o = gco2t(o)->gclist; break; 368 case LUA_TTABLE: o = gco2t(o)->gclist; break;
369 case LUA_TLCL: o = gco2lcl(o)->gclist; break; 369 case LUA_TLCL: o = gco2lcl(o)->gclist; break;
370 case LUA_TCCL: o = gco2ccl(o)->gclist; break; 370 case LUA_TCCL: o = gco2ccl(o)->gclist; break;
@@ -391,12 +391,12 @@ static void markgrays (global_State *g) {
391 391
392 392
393static void checkgray (global_State *g, GCObject *o) { 393static void checkgray (global_State *g, GCObject *o) {
394 for (; o != NULL; o = gch(o)->next) { 394 for (; o != NULL; o = o->next) {
395 if (isgray(o)) { 395 if (isgray(o)) {
396 lua_assert(!keepinvariant(g) || testbit(o->gch.marked, TESTGRAYBIT)); 396 lua_assert(!keepinvariant(g) || testbit(o->marked, TESTGRAYBIT));
397 resetbit(o->gch.marked, TESTGRAYBIT); 397 resetbit(o->marked, TESTGRAYBIT);
398 } 398 }
399 lua_assert(!testbit(o->gch.marked, TESTGRAYBIT)); 399 lua_assert(!testbit(o->marked, TESTGRAYBIT));
400 } 400 }
401} 401}
402 402
@@ -415,29 +415,29 @@ int lua_checkmemory (lua_State *L) {
415 lua_assert(g->sweepgc == NULL || issweepphase(g)); 415 lua_assert(g->sweepgc == NULL || issweepphase(g));
416 markgrays(g); 416 markgrays(g);
417 /* check 'fixedgc' list */ 417 /* check 'fixedgc' list */
418 for (o = g->fixedgc; o != NULL; o = gch(o)->next) { 418 for (o = g->fixedgc; o != NULL; o = o->next) {
419 lua_assert(gch(o)->tt == LUA_TSHRSTR && isgray(o)); 419 lua_assert(o->tt == LUA_TSHRSTR && isgray(o));
420 } 420 }
421 /* check 'allgc' list */ 421 /* check 'allgc' list */
422 checkgray(g, g->allgc); 422 checkgray(g, g->allgc);
423 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc); 423 maybedead = (GCSatomic < g->gcstate && g->gcstate <= GCSswpallgc);
424 for (o = g->allgc; o != NULL; o = gch(o)->next) { 424 for (o = g->allgc; o != NULL; o = o->next) {
425 checkobject(g, o, maybedead); 425 checkobject(g, o, maybedead);
426 lua_assert(!tofinalize(o)); 426 lua_assert(!tofinalize(o));
427 } 427 }
428 /* check 'finobj' list */ 428 /* check 'finobj' list */
429 checkgray(g, g->finobj); 429 checkgray(g, g->finobj);
430 for (o = g->finobj; o != NULL; o = gch(o)->next) { 430 for (o = g->finobj; o != NULL; o = o->next) {
431 checkobject(g, o, 0); 431 checkobject(g, o, 0);
432 lua_assert(tofinalize(o)); 432 lua_assert(tofinalize(o));
433 lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); 433 lua_assert(o->tt == LUA_TUSERDATA || o->tt == LUA_TTABLE);
434 } 434 }
435 /* check 'tobefnz' list */ 435 /* check 'tobefnz' list */
436 checkgray(g, g->tobefnz); 436 checkgray(g, g->tobefnz);
437 for (o = g->tobefnz; o != NULL; o = gch(o)->next) { 437 for (o = g->tobefnz; o != NULL; o = o->next) {
438 checkobject(g, o, 0); 438 checkobject(g, o, 0);
439 lua_assert(tofinalize(o)); 439 lua_assert(tofinalize(o));
440 lua_assert(gch(o)->tt == LUA_TUSERDATA || gch(o)->tt == LUA_TTABLE); 440 lua_assert(o->tt == LUA_TUSERDATA || o->tt == LUA_TTABLE);
441 } 441 }
442 return 0; 442 return 0;
443} 443}