aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-11 16:22:33 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2012-05-11 16:22:33 -0300
commit31829ad1770223833bcbdab634e25cdfd911633d (patch)
treea3c5becabd437e7fc550ef19e1f38c69e18e70c9
parentc2361e0b6108a2e7e53dcfcdc3a569fcc4a1e31d (diff)
downloadlua-31829ad1770223833bcbdab634e25cdfd911633d.tar.gz
lua-31829ad1770223833bcbdab634e25cdfd911633d.tar.bz2
lua-31829ad1770223833bcbdab634e25cdfd911633d.zip
test for whether collector is running moved from function to
macro 'luaC_condGC'.
-rw-r--r--lapi.c6
-rw-r--r--lgc.c14
-rw-r--r--lgc.h4
3 files changed, 8 insertions, 16 deletions
diff --git a/lapi.c b/lapi.c
index 924a9124..93616244 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.158 2011/11/29 15:55:08 roberto Exp roberto $ 2** $Id: lapi.c,v 2.159 2011/11/30 12:32:05 roberto Exp roberto $
3** Lua API 3** Lua API
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1046,11 +1046,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
1046 case LUA_GCSTEP: { 1046 case LUA_GCSTEP: {
1047 if (g->gckind == KGC_GEN) { /* generational mode? */ 1047 if (g->gckind == KGC_GEN) { /* generational mode? */
1048 res = (g->lastmajormem == 0); /* 1 if will do major collection */ 1048 res = (g->lastmajormem == 0); /* 1 if will do major collection */
1049 luaC_forcestep(L); /* do a single step */ 1049 luaC_step(L); /* do a single step */
1050 } 1050 }
1051 else { 1051 else {
1052 while (data-- >= 0) { 1052 while (data-- >= 0) {
1053 luaC_forcestep(L); 1053 luaC_step(L);
1054 if (g->gcstate == GCSpause) { /* end of cycle? */ 1054 if (g->gcstate == GCSpause) { /* end of cycle? */
1055 res = 1; /* signal it */ 1055 res = 1; /* signal it */
1056 break; 1056 break;
diff --git a/lgc.c b/lgc.c
index 06196724..02adfecf 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.119 2012/01/25 21:05:40 roberto Exp roberto $ 2** $Id: lgc.c,v 2.120 2012/05/08 13:53:33 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*/
@@ -1069,9 +1069,9 @@ static void step (lua_State *L) {
1069 1069
1070 1070
1071/* 1071/*
1072** performs a basic GC step even if the collector is stopped 1072** performs a basic GC step
1073*/ 1073*/
1074void luaC_forcestep (lua_State *L) { 1074void luaC_step (lua_State *L) {
1075 global_State *g = G(L); 1075 global_State *g = G(L);
1076 int i; 1076 int i;
1077 if (isgenerational(g)) generationalcollection(L); 1077 if (isgenerational(g)) generationalcollection(L);
@@ -1082,14 +1082,6 @@ void luaC_forcestep (lua_State *L) {
1082 1082
1083 1083
1084/* 1084/*
1085** performs a basic GC step only if collector is running
1086*/
1087void luaC_step (lua_State *L) {
1088 if (G(L)->gcrunning) luaC_forcestep(L);
1089}
1090
1091
1092/*
1093** performs a full GC cycle; if "isemergency", does not call 1085** performs a full GC cycle; if "isemergency", does not call
1094** finalizers (which could change stack positions) 1086** finalizers (which could change stack positions)
1095*/ 1087*/
diff --git a/lgc.h b/lgc.h
index e71743e9..bc63ab98 100644
--- a/lgc.h
+++ b/lgc.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.h,v 2.52 2011/10/03 17:54:25 roberto Exp roberto $ 2** $Id: lgc.h,v 2.53 2012/01/23 20:29:12 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*/
@@ -104,7 +104,7 @@
104 104
105 105
106#define luaC_condGC(L,c) \ 106#define luaC_condGC(L,c) \
107 {if (G(L)->GCdebt > 0) {c;}; condchangemem(L);} 107 {if (G(L)->GCdebt > 0 && G(L)->gcrunning) {c;}; condchangemem(L);}
108#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);) 108#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);)
109 109
110 110