aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-12 15:01:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-12 15:01:40 -0300
commit16001acb15456c832474edc9f0323e0238e28a11 (patch)
treec5f40e06b3e4dcf27e9df5bef20c4998befd4319
parent0c8a7e071b00a1ea9822101f3b9fe4392d05c3c6 (diff)
downloadlua-16001acb15456c832474edc9f0323e0238e28a11.tar.gz
lua-16001acb15456c832474edc9f0323e0238e28a11.tar.bz2
lua-16001acb15456c832474edc9f0323e0238e28a11.zip
small corrections + removal of debugging functions 'count' and
'printgray'.
-rw-r--r--lgc.c52
1 files changed, 4 insertions, 48 deletions
diff --git a/lgc.c b/lgc.c
index c0af55f4..c8d401e6 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.220 2017/04/11 18:41:09 roberto Exp roberto $ 2** $Id: lgc.c,v 2.221 2017/04/11 19:00:27 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*/
@@ -425,6 +425,8 @@ static int traverseephemeron (global_State *g, Table *h) {
425 linkgclist(h, g->allweak); /* may have to clean white keys */ 425 linkgclist(h, g->allweak); /* may have to clean white keys */
426 else if (g->gckind == KGC_GEN) 426 else if (g->gckind == KGC_GEN)
427 linkgclist(h, g->grayagain); /* keep it in some list */ 427 linkgclist(h, g->grayagain); /* keep it in some list */
428 else
429 gray2black(h);
428 return marked; 430 return marked;
429} 431}
430 432
@@ -939,16 +941,6 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
939/* mask to erase all color bits, not changing gen-related stuff */ 941/* mask to erase all color bits, not changing gen-related stuff */
940#define maskgencolors (~(bitmask(BLACKBIT) | WHITEBITS)) 942#define maskgencolors (~(bitmask(BLACKBIT) | WHITEBITS))
941 943
942#if 0
943static int count (GCObject *p, GCObject *limit) {
944 int res = 0;
945 for (; p != NULL && p != limit; p = p->next) {
946 res++;
947 }
948 return res;
949}
950#endif
951
952 944
953/* 945/*
954** Sweep a list of objects, deleting dead ones and turning 946** Sweep a list of objects, deleting dead ones and turning
@@ -1017,42 +1009,6 @@ static void whitelist (global_State *g, GCObject *p) {
1017 p->marked = cast_byte((p->marked & maskcolors) | white); 1009 p->marked = cast_byte((p->marked & maskcolors) | white);
1018} 1010}
1019 1011
1020static void printgray (GCObject *o) {
1021 printf("gray: ");
1022 while (o) {
1023 printf("%p %d %02x ", (void*)o, o->tt, o->marked);
1024 switch (o->tt) {
1025 case LUA_TTABLE: {
1026 Table *h = gco2t(o);
1027 o = h->gclist;
1028 break;
1029 }
1030 case LUA_TLCL: {
1031 LClosure *cl = gco2lcl(o);
1032 o = cl->gclist;
1033 break;
1034 }
1035 case LUA_TCCL: {
1036 CClosure *cl = gco2ccl(o);
1037 o = cl->gclist;
1038 break;
1039 }
1040 case LUA_TTHREAD: {
1041 lua_State *th = gco2th(o);
1042 o = th->gclist;
1043 break;
1044 }
1045 case LUA_TPROTO: {
1046 Proto *p = gco2p(o);
1047 o = p->gclist;
1048 break;
1049 }
1050 default: lua_assert(0); return;
1051 }
1052 }
1053 printf("\n");
1054}
1055
1056 1012
1057/* 1013/*
1058** Correct a list of gray objects. Because this correction is 1014** Correct a list of gray objects. Because this correction is
@@ -1317,7 +1273,7 @@ void luaC_freeallobjects (lua_State *L) {
1317 separatetobefnz(g, 1); /* separate all objects with finalizers */ 1273 separatetobefnz(g, 1); /* separate all objects with finalizers */
1318 lua_assert(g->finobj == NULL); 1274 lua_assert(g->finobj == NULL);
1319 callallpendingfinalizers(L); 1275 callallpendingfinalizers(L);
1320 deletealllist(L, g->allgc, g->mainthread); 1276 deletealllist(L, g->allgc, obj2gco(g->mainthread));
1321 deletealllist(L, g->finobj, NULL); 1277 deletealllist(L, g->finobj, NULL);
1322 deletealllist(L, g->fixedgc, NULL); /* collect fixed objects */ 1278 deletealllist(L, g->fixedgc, NULL); /* collect fixed objects */
1323 lua_assert(g->strt.nuse == 0); 1279 lua_assert(g->strt.nuse == 0);