Przeglądaj źródła

Avoid moving the collector while in 'GCSenteratomic' state

The 'GCSenteratomic' is just an auxiliary state for transitioning
to 'GCSatomic'. All GC traversals should be done either on the
'GCSpropagate' state or the 'GCSatomic' state.
Roberto Ierusalimschy 6 lat temu
rodzic
commit
38425e0692
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      lgc.c

+ 2 - 2
lgc.c

@@ -1423,6 +1423,7 @@ static lu_mem atomic (lua_State *L) {
   /* registry and global metatables may be changed by API */
   /* registry and global metatables may be changed by API */
   markvalue(g, &g->l_registry);
   markvalue(g, &g->l_registry);
   markmt(g);  /* mark global metatables */
   markmt(g);  /* mark global metatables */
+  work += propagateall(g);  /* empties 'gray' list */
   /* remark occasional upvalues of (maybe) dead threads */
   /* remark occasional upvalues of (maybe) dead threads */
   work += remarkupvals(g);
   work += remarkupvals(g);
   work += propagateall(g);  /* propagate changes */
   work += propagateall(g);  /* propagate changes */
@@ -1486,8 +1487,7 @@ static lu_mem singlestep (lua_State *L) {
         return propagatemark(g);  /* traverse one gray object */
         return propagatemark(g);  /* traverse one gray object */
     }
     }
     case GCSenteratomic: {
     case GCSenteratomic: {
-      lu_mem work = propagateall(g);  /* make sure gray list is empty */
-      work += atomic(L);  /* work is what was traversed by 'atomic' */
+      lu_mem work = atomic(L);  /* work is what was traversed by 'atomic' */
       entersweep(L);
       entersweep(L);
       g->GCestimate = gettotalbytes(g);  /* first estimate */;
       g->GCestimate = gettotalbytes(g);  /* first estimate */;
       return work;
       return work;