aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-19 12:14:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-19 12:14:46 -0300
commit3c6d0aaa7d07de2cf24d09195b6678abbfee2268 (patch)
tree92e7da72cd89505e8d1326b71593df9b1e7b0fdf /lgc.c
parente43612aaf62bbb92fd7555b132d9ee1c0394dc58 (diff)
downloadlua-3c6d0aaa7d07de2cf24d09195b6678abbfee2268.tar.gz
lua-3c6d0aaa7d07de2cf24d09195b6678abbfee2268.tar.bz2
lua-3c6d0aaa7d07de2cf24d09195b6678abbfee2268.zip
'iswhite' and related macros now can work directly on any object
(no need to convert to 'GCObject')
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lgc.c b/lgc.c
index 896aeef0..0fe426e8 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.189 2014/07/19 14:44:19 roberto Exp roberto $ 2** $Id: lgc.c,v 2.190 2014/07/19 15:09:37 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*/
@@ -81,7 +81,7 @@
81 if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } 81 if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
82 82
83#define markobject(g,t) \ 83#define markobject(g,t) \
84 { if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); } 84 { if ((t) && iswhite(t)) reallymarkobject(g, obj2gco(t)); }
85 85
86static void reallymarkobject (global_State *g, GCObject *o); 86static void reallymarkobject (global_State *g, GCObject *o);
87 87
@@ -301,8 +301,8 @@ static void remarkupvals (global_State *g) {
301 lua_State *thread; 301 lua_State *thread;
302 lua_State **p = &g->twups; 302 lua_State **p = &g->twups;
303 while ((thread = *p) != NULL) { 303 while ((thread = *p) != NULL) {
304 lua_assert(!isblack(obj2gco(thread))); /* threads are never black */ 304 lua_assert(!isblack(thread)); /* threads are never black */
305 if (isgray(obj2gco(thread)) && thread->openupval != NULL) 305 if (isgray(thread) && thread->openupval != NULL)
306 p = &thread->twups; /* keep marked thread with upvalues in the list */ 306 p = &thread->twups; /* keep marked thread with upvalues in the list */
307 else { /* thread is not marked or without upvalues */ 307 else { /* thread is not marked or without upvalues */
308 UpVal *uv; 308 UpVal *uv;
@@ -427,7 +427,7 @@ static lu_mem traversetable (global_State *g, Table *h) {
427 ((weakkey = strchr(svalue(mode), 'k')), 427 ((weakkey = strchr(svalue(mode), 'k')),
428 (weakvalue = strchr(svalue(mode), 'v')), 428 (weakvalue = strchr(svalue(mode), 'v')),
429 (weakkey || weakvalue))) { /* is really weak? */ 429 (weakkey || weakvalue))) { /* is really weak? */
430 black2gray(obj2gco(h)); /* keep table gray */ 430 black2gray(h); /* keep table gray */
431 if (!weakkey) /* strong keys? */ 431 if (!weakkey) /* strong keys? */
432 traverseweakvalue(g, h); 432 traverseweakvalue(g, h);
433 else if (!weakvalue) /* strong values? */ 433 else if (!weakvalue) /* strong values? */
@@ -444,7 +444,7 @@ static lu_mem traversetable (global_State *g, Table *h) {
444 444
445static int traverseproto (global_State *g, Proto *f) { 445static int traverseproto (global_State *g, Proto *f) {
446 int i; 446 int i;
447 if (f->cache && iswhite(obj2gco(f->cache))) 447 if (f->cache && iswhite(f->cache))
448 f->cache = NULL; /* allow cache to be collected */ 448 f->cache = NULL; /* allow cache to be collected */
449 markobject(g, f->source); 449 markobject(g, f->source);
450 for (i = 0; i < f->sizek; i++) /* mark literals */ 450 for (i = 0; i < f->sizek; i++) /* mark literals */
@@ -973,7 +973,7 @@ static l_mem atomic (lua_State *L) {
973 l_mem work; 973 l_mem work;
974 GCObject *origweak, *origall; 974 GCObject *origweak, *origall;
975 g->GCmemtrav = 0; /* start counting work */ 975 g->GCmemtrav = 0; /* start counting work */
976 lua_assert(!iswhite(obj2gco(g->mainthread))); 976 lua_assert(!iswhite(g->mainthread));
977 g->gcstate = GCSinsideatomic; 977 g->gcstate = GCSinsideatomic;
978 markobject(g, L); /* mark running thread */ 978 markobject(g, L); /* mark running thread */
979 /* registry and global metatables may be changed by API */ 979 /* registry and global metatables may be changed by API */
@@ -1064,7 +1064,7 @@ static lu_mem singlestep (lua_State *L) {
1064 return sweepstep(L, g, GCSswpend, NULL); 1064 return sweepstep(L, g, GCSswpend, NULL);
1065 } 1065 }
1066 case GCSswpend: { /* finish sweeps */ 1066 case GCSswpend: { /* finish sweeps */
1067 makewhite(g, obj2gco(g->mainthread)); /* sweep main thread */ 1067 makewhite(g, g->mainthread); /* sweep main thread */
1068 checkSizes(L, g); 1068 checkSizes(L, g);
1069 g->gcstate = GCScallfin; 1069 g->gcstate = GCScallfin;
1070 return 0; 1070 return 0;