Przeglądaj źródła

test for whether collector is running moved from function to
macro 'luaC_condGC'.

Roberto Ierusalimschy 13 lat temu
rodzic
commit
31829ad177
3 zmienionych plików z 8 dodań i 16 usunięć
  1. 3 3
      lapi.c
  2. 3 11
      lgc.c
  3. 2 2
      lgc.h

+ 3 - 3
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 2.158 2011/11/29 15:55:08 roberto Exp roberto $
+** $Id: lapi.c,v 2.159 2011/11/30 12:32:05 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -1046,11 +1046,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
     case LUA_GCSTEP: {
     case LUA_GCSTEP: {
       if (g->gckind == KGC_GEN) {  /* generational mode? */
       if (g->gckind == KGC_GEN) {  /* generational mode? */
         res = (g->lastmajormem == 0);  /* 1 if will do major collection */
         res = (g->lastmajormem == 0);  /* 1 if will do major collection */
-        luaC_forcestep(L);  /* do a single step */
+        luaC_step(L);  /* do a single step */
       }
       }
       else {
       else {
         while (data-- >= 0) {
         while (data-- >= 0) {
-          luaC_forcestep(L);
+          luaC_step(L);
           if (g->gcstate == GCSpause) {  /* end of cycle? */
           if (g->gcstate == GCSpause) {  /* end of cycle? */
             res = 1;  /* signal it */
             res = 1;  /* signal it */
             break;
             break;

+ 3 - 11
lgc.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.c,v 2.119 2012/01/25 21:05:40 roberto Exp roberto $
+** $Id: lgc.c,v 2.120 2012/05/08 13:53:33 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -1069,9 +1069,9 @@ static void step (lua_State *L) {
 
 
 
 
 /*
 /*
-** performs a basic GC step even if the collector is stopped
+** performs a basic GC step
 */
 */
-void luaC_forcestep (lua_State *L) {
+void luaC_step (lua_State *L) {
   global_State *g = G(L);
   global_State *g = G(L);
   int i;
   int i;
   if (isgenerational(g)) generationalcollection(L);
   if (isgenerational(g)) generationalcollection(L);
@@ -1081,14 +1081,6 @@ void luaC_forcestep (lua_State *L) {
 }
 }
 
 
 
 
-/*
-** performs a basic GC step only if collector is running
-*/
-void luaC_step (lua_State *L) {
-  if (G(L)->gcrunning) luaC_forcestep(L);
-}
-
-
 /*
 /*
 ** performs a full GC cycle; if "isemergency", does not call
 ** performs a full GC cycle; if "isemergency", does not call
 ** finalizers (which could change stack positions)
 ** finalizers (which could change stack positions)

+ 2 - 2
lgc.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lgc.h,v 2.52 2011/10/03 17:54:25 roberto Exp roberto $
+** $Id: lgc.h,v 2.53 2012/01/23 20:29:12 roberto Exp roberto $
 ** Garbage Collector
 ** Garbage Collector
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -104,7 +104,7 @@
 
 
 
 
 #define luaC_condGC(L,c) \
 #define luaC_condGC(L,c) \
-	{if (G(L)->GCdebt > 0) {c;}; condchangemem(L);}
+	{if (G(L)->GCdebt > 0 && G(L)->gcrunning) {c;}; condchangemem(L);}
 #define luaC_checkGC(L)		luaC_condGC(L, luaC_step(L);)
 #define luaC_checkGC(L)		luaC_condGC(L, luaC_step(L);)