aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-11 10:28:47 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-02-11 10:28:47 -0200
commit6b307744691a70778da77f4c7d5589ed7f4fcabf (patch)
tree2cc5ff101b96748f1f45d54af1cdaf39d9a0fa83 /lgc.c
parentba3586cc90d1ab8d499437dd7c504798371b0e4f (diff)
downloadlua-6b307744691a70778da77f4c7d5589ed7f4fcabf.tar.gz
lua-6b307744691a70778da77f4c7d5589ed7f4fcabf.tar.bz2
lua-6b307744691a70778da77f4c7d5589ed7f4fcabf.zip
detail (better presentation for 'luaC_step')
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lgc.c b/lgc.c
index a06af829..4fb65ef3 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.168 2013/12/13 15:42:08 roberto Exp roberto $ 2** $Id: lgc.c,v 2.169 2014/02/11 12:18: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*/
@@ -1208,24 +1208,23 @@ void luaC_forcestep (lua_State *L) {
1208 1208
1209 1209
1210/* 1210/*
1211** performs a basic GC step only if collector is running 1211** performs a basic GC step or a local collection when collector is running
1212*/ 1212*/
1213void luaC_step (lua_State *L) { 1213void luaC_step (lua_State *L) {
1214 global_State *g = G(L); 1214 global_State *g = G(L);
1215 if (g->gcrunning) { 1215 if (!g->gcrunning)
1216 if (g->gcstate != GCSpause) { 1216 luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */
1217 luaC_forcestep(L); 1217 else {
1218 } 1218 if (g->gcstate != GCSpause) /* in the middle of a cycle? */
1219 luaC_forcestep(L); /* continue it */
1219 else { 1220 else {
1220 luaC_localcollection(L); 1221 luaC_localcollection(L); /* try a local collection */
1221 if (gettotalbytes(g) > g->GCthreshold) { 1222 if (gettotalbytes(g) <= g->GCthreshold) /* enough? */
1222 luaC_forcestep(L); /* restart collection */
1223 }
1224 else
1225 luaE_setdebt(g, -g->gclocalpause); 1223 luaE_setdebt(g, -g->gclocalpause);
1224 else /* local collection did not collect enough memory */
1225 luaC_forcestep(L); /* start a full collection */
1226 } 1226 }
1227 } 1227 }
1228 else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */
1229} 1228}
1230 1229
1231 1230