diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-19 12:14:46 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-19 12:14:46 -0300 |
commit | 3c6d0aaa7d07de2cf24d09195b6678abbfee2268 (patch) | |
tree | 92e7da72cd89505e8d1326b71593df9b1e7b0fdf | |
parent | e43612aaf62bbb92fd7555b132d9ee1c0394dc58 (diff) | |
download | lua-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')
-rw-r--r-- | lgc.c | 16 | ||||
-rw-r--r-- | lgc.h | 8 | ||||
-rw-r--r-- | ltests.c | 6 |
3 files changed, 15 insertions, 15 deletions
@@ -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 | ||
86 | static void reallymarkobject (global_State *g, GCObject *o); | 86 | static 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 | ||
445 | static int traverseproto (global_State *g, Proto *f) { | 445 | static 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; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.83 2014/07/17 17:27:49 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.84 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 | */ |
@@ -107,15 +107,15 @@ | |||
107 | 107 | ||
108 | 108 | ||
109 | #define luaC_barrier(L,p,v) { \ | 109 | #define luaC_barrier(L,p,v) { \ |
110 | if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \ | 110 | if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) \ |
111 | luaC_barrier_(L,obj2gco(p),gcvalue(v)); } | 111 | luaC_barrier_(L,obj2gco(p),gcvalue(v)); } |
112 | 112 | ||
113 | #define luaC_barrierback(L,p,v) { \ | 113 | #define luaC_barrierback(L,p,v) { \ |
114 | if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \ | 114 | if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v))) \ |
115 | luaC_barrierback_(L,p); } | 115 | luaC_barrierback_(L,p); } |
116 | 116 | ||
117 | #define luaC_objbarrier(L,p,o) { \ | 117 | #define luaC_objbarrier(L,p,o) { \ |
118 | if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ | 118 | if (isblack(p) && iswhite(o)) \ |
119 | luaC_barrier_(L,obj2gco(p),obj2gco(o)); } | 119 | luaC_barrier_(L,obj2gco(p),obj2gco(o)); } |
120 | 120 | ||
121 | #define luaC_upvalbarrier(L,uv) \ | 121 | #define luaC_upvalbarrier(L,uv) \ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.179 2014/07/18 13:36:14 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.180 2014/07/18 14:46:47 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 | */ |
@@ -294,7 +294,7 @@ static void checkstack (global_State *g, lua_State *L1) { | |||
294 | StkId o; | 294 | StkId o; |
295 | CallInfo *ci; | 295 | CallInfo *ci; |
296 | UpVal *uv; | 296 | UpVal *uv; |
297 | lua_assert(!isdead(g, obj2gco(L1))); | 297 | lua_assert(!isdead(g, L1)); |
298 | for (uv = L1->openupval; uv != NULL; uv = uv->u.open.next) | 298 | for (uv = L1->openupval; uv != NULL; uv = uv->u.open.next) |
299 | lua_assert(upisopen(uv)); /* must be open */ | 299 | lua_assert(upisopen(uv)); /* must be open */ |
300 | for (ci = L1->ci; ci != NULL; ci = ci->previous) { | 300 | for (ci = L1->ci; ci != NULL; ci = ci->previous) { |
@@ -404,7 +404,7 @@ int lua_checkmemory (lua_State *L) { | |||
404 | GCObject *o; | 404 | GCObject *o; |
405 | int maybedead; | 405 | int maybedead; |
406 | if (keepinvariant(g)) { | 406 | if (keepinvariant(g)) { |
407 | lua_assert(!iswhite(obj2gco(g->mainthread))); | 407 | lua_assert(!iswhite(g->mainthread)); |
408 | lua_assert(!iswhite(gcvalue(&g->l_registry))); | 408 | lua_assert(!iswhite(gcvalue(&g->l_registry))); |
409 | } | 409 | } |
410 | lua_assert(!isdead(g, gcvalue(&g->l_registry))); | 410 | lua_assert(!isdead(g, gcvalue(&g->l_registry))); |