aboutsummaryrefslogtreecommitdiff
path: root/lgc.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-19 14:02:50 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-19 14:02:50 -0300
commitc7bdc0e0e8ab03820b472a87b87c04475def5997 (patch)
tree991bf63ed4a9f108411529db4db468334d686dc2 /lgc.c
parenta45945b6d511b00b1c84dc73881474030737e956 (diff)
downloadlua-c7bdc0e0e8ab03820b472a87b87c04475def5997.tar.gz
lua-c7bdc0e0e8ab03820b472a87b87c04475def5997.tar.bz2
lua-c7bdc0e0e8ab03820b472a87b87c04475def5997.zip
first version of control for the generational collector
Diffstat (limited to 'lgc.c')
-rw-r--r--lgc.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lgc.c b/lgc.c
index c8d401e6..9995fbed 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.221 2017/04/11 19:00:27 roberto Exp roberto $ 2** $Id: lgc.c,v 2.222 2017/04/12 18:01:40 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*/
@@ -1158,6 +1158,7 @@ static void entergen (lua_State *L, global_State *g) {
1158 1158
1159 finishgencycle(L, g); 1159 finishgencycle(L, g);
1160 g->gckind = KGC_GEN; 1160 g->gckind = KGC_GEN;
1161 g->GCestimate = gettotalbytes(g); /* base for memory control */
1161} 1162}
1162 1163
1163 1164
@@ -1205,10 +1206,17 @@ static void fullgen (lua_State *L, global_State *g) {
1205** collection. (We still has to implement the full control.) 1206** collection. (We still has to implement the full control.)
1206*/ 1207*/
1207static void genstep (lua_State *L, global_State *g) { 1208static void genstep (lua_State *L, global_State *g) {
1208 lu_mem mem; 1209 lu_mem majorbase = g->GCestimate;
1209 youngcollection(L, g); 1210lua_checkmemory(L);
1210 mem = gettotalbytes(g); 1211 if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul))
1211 luaE_setdebt(g, -((mem / 100) * 20)); 1212 fullgen(L, g);
1213 else {
1214 lu_mem mem;
1215 youngcollection(L, g);
1216 mem = gettotalbytes(g);
1217 luaE_setdebt(g, -((mem / 100) * g->genminormul));
1218 g->GCestimate = mem;
1219 }
1212lua_checkmemory(L); 1220lua_checkmemory(L);
1213} 1221}
1214 1222