소스 검색

'iswhite' and related macros now can work directly on any object
(no need to convert to 'GCObject')

Roberto Ierusalimschy 11 년 전
부모
커밋
3c6d0aaa7d
3개의 변경된 파일15개의 추가작업 그리고 15개의 파일을 삭제
  1. 8 8
      lgc.c
  2. 4 4
      lgc.h
  3. 3 3
      ltests.c

+ 8 - 8
lgc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.c,v 2.189 2014/07/19 14:44:19 roberto Exp roberto $
+** $Id: lgc.c,v 2.190 2014/07/19 15:09:37 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -81,7 +81,7 @@
   if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); }
 
 #define markobject(g,t) \
-  { if ((t) && iswhite(obj2gco(t))) reallymarkobject(g, obj2gco(t)); }
+  { if ((t) && iswhite(t)) reallymarkobject(g, obj2gco(t)); }
 
 static void reallymarkobject (global_State *g, GCObject *o);
 
@@ -301,8 +301,8 @@ static void remarkupvals (global_State *g) {
   lua_State *thread;
   lua_State **p = &g->twups;
   while ((thread = *p) != NULL) {
-    lua_assert(!isblack(obj2gco(thread)));  /* threads are never black */
-    if (isgray(obj2gco(thread)) && thread->openupval != NULL)
+    lua_assert(!isblack(thread));  /* threads are never black */
+    if (isgray(thread) && thread->openupval != NULL)
       p = &thread->twups;  /* keep marked thread with upvalues in the list */
     else {  /* thread is not marked or without upvalues */
       UpVal *uv;
@@ -427,7 +427,7 @@ static lu_mem traversetable (global_State *g, Table *h) {
       ((weakkey = strchr(svalue(mode), 'k')),
        (weakvalue = strchr(svalue(mode), 'v')),
        (weakkey || weakvalue))) {  /* is really weak? */
-    black2gray(obj2gco(h));  /* keep table gray */
+    black2gray(h);  /* keep table gray */
     if (!weakkey)  /* strong keys? */
       traverseweakvalue(g, h);
     else if (!weakvalue)  /* strong values? */
@@ -444,7 +444,7 @@ static lu_mem traversetable (global_State *g, Table *h) {
 
 static int traverseproto (global_State *g, Proto *f) {
   int i;
-  if (f->cache && iswhite(obj2gco(f->cache)))
+  if (f->cache && iswhite(f->cache))
     f->cache = NULL;  /* allow cache to be collected */
   markobject(g, f->source);
   for (i = 0; i < f->sizek; i++)  /* mark literals */
@@ -973,7 +973,7 @@ static l_mem atomic (lua_State *L) {
   l_mem work;
   GCObject *origweak, *origall;
   g->GCmemtrav = 0;  /* start counting work */
-  lua_assert(!iswhite(obj2gco(g->mainthread)));
+  lua_assert(!iswhite(g->mainthread));
   g->gcstate = GCSinsideatomic;
   markobject(g, L);  /* mark running thread */
   /* registry and global metatables may be changed by API */
@@ -1064,7 +1064,7 @@ static lu_mem singlestep (lua_State *L) {
       return sweepstep(L, g, GCSswpend, NULL);
     }
     case GCSswpend: {  /* finish sweeps */
-      makewhite(g, obj2gco(g->mainthread));  /* sweep main thread */
+      makewhite(g, g->mainthread);  /* sweep main thread */
       checkSizes(L, g);
       g->gcstate = GCScallfin;
       return 0;

+ 4 - 4
lgc.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lgc.h,v 2.83 2014/07/17 17:27:49 roberto Exp roberto $
+** $Id: lgc.h,v 2.84 2014/07/19 15:09:37 roberto Exp roberto $
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 */
@@ -107,15 +107,15 @@
 
 
 #define luaC_barrier(L,p,v) {  \
-	if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v)))  \
+	if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v)))  \
 	luaC_barrier_(L,obj2gco(p),gcvalue(v)); }
 
 #define luaC_barrierback(L,p,v) {  \
-	if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v)))  \
+	if (iscollectable(v) && isblack(p) && iswhite(gcvalue(v)))  \
 	luaC_barrierback_(L,p); }
 
 #define luaC_objbarrier(L,p,o) {  \
-	if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) \
+	if (isblack(p) && iswhite(o)) \
 		luaC_barrier_(L,obj2gco(p),obj2gco(o)); }
 
 #define luaC_upvalbarrier(L,uv) \

+ 3 - 3
ltests.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltests.c,v 2.179 2014/07/18 13:36:14 roberto Exp roberto $
+** $Id: ltests.c,v 2.180 2014/07/18 14:46:47 roberto Exp roberto $
 ** Internal Module for Debugging of the Lua Implementation
 ** See Copyright Notice in lua.h
 */
@@ -294,7 +294,7 @@ static void checkstack (global_State *g, lua_State *L1) {
   StkId o;
   CallInfo *ci;
   UpVal *uv;
-  lua_assert(!isdead(g, obj2gco(L1)));
+  lua_assert(!isdead(g, L1));
   for (uv = L1->openupval; uv != NULL; uv = uv->u.open.next)
     lua_assert(upisopen(uv));  /* must be open */
   for (ci = L1->ci; ci != NULL; ci = ci->previous) {
@@ -404,7 +404,7 @@ int lua_checkmemory (lua_State *L) {
   GCObject *o;
   int maybedead;
   if (keepinvariant(g)) {
-    lua_assert(!iswhite(obj2gco(g->mainthread)));
+    lua_assert(!iswhite(g->mainthread));
     lua_assert(!iswhite(gcvalue(&g->l_registry)));
   }
   lua_assert(!isdead(g, gcvalue(&g->l_registry)));