diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-07-02 10:40:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2012-07-02 10:40:05 -0300 |
commit | 4fc15bbfb731d1258c2771d45078bbbb51bff700 (patch) | |
tree | 7b1f50529ae31a1df00918f61fa1f9e7255d14e6 | |
parent | f7ec36ab1652742c69f838825938b1a7127acda8 (diff) | |
download | lua-4fc15bbfb731d1258c2771d45078bbbb51bff700.tar.gz lua-4fc15bbfb731d1258c2771d45078bbbb51bff700.tar.bz2 lua-4fc15bbfb731d1258c2771d45078bbbb51bff700.zip |
major collections in generational mode are triggered by comparison with
the memory estimate from last major collection
-rw-r--r-- | lgc.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.132 2012/05/31 20:26:14 roberto Exp $ | 2 | ** $Id: lgc.c,v 2.133 2012/05/31 21:28:59 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 | */ |
@@ -343,7 +343,7 @@ static void remarkupvals (global_State *g) { | |||
343 | ** mark root set and reset all gray lists, to start a new | 343 | ** mark root set and reset all gray lists, to start a new |
344 | ** incremental (or full) collection | 344 | ** incremental (or full) collection |
345 | */ | 345 | */ |
346 | static void markroot (global_State *g) { | 346 | static void startcollection (global_State *g) { |
347 | g->gray = g->grayagain = NULL; | 347 | g->gray = g->grayagain = NULL; |
348 | g->weak = g->allweak = g->ephemeron = NULL; | 348 | g->weak = g->allweak = g->ephemeron = NULL; |
349 | markobject(g, g->mainthread); | 349 | markobject(g, g->mainthread); |
@@ -1030,7 +1030,7 @@ static lu_mem singlestep (lua_State *L) { | |||
1030 | case GCSpause: { | 1030 | case GCSpause: { |
1031 | g->GCmemtrav = 0; /* start to count memory traversed */ | 1031 | g->GCmemtrav = 0; /* start to count memory traversed */ |
1032 | if (!isgenerational(g)) | 1032 | if (!isgenerational(g)) |
1033 | markroot(g); /* start a new collection */ | 1033 | startcollection(g); |
1034 | /* in any case, root must be marked at this point */ | 1034 | /* in any case, root must be marked at this point */ |
1035 | lua_assert(!iswhite(obj2gco(g->mainthread)) | 1035 | lua_assert(!iswhite(obj2gco(g->mainthread)) |
1036 | && !iswhite(gcvalue(&g->l_registry))); | 1036 | && !iswhite(gcvalue(&g->l_registry))); |
@@ -1115,6 +1115,9 @@ static void generationalcollection (lua_State *L) { | |||
1115 | luaC_runtilstate(L, bitmask(GCSpause)); | 1115 | luaC_runtilstate(L, bitmask(GCSpause)); |
1116 | if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) | 1116 | if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) |
1117 | g->GCestimate = 0; /* signal for a major collection */ | 1117 | g->GCestimate = 0; /* signal for a major collection */ |
1118 | else | ||
1119 | g->GCestimate = estimate; /* keep estimate from last major coll. */ | ||
1120 | |||
1118 | } | 1121 | } |
1119 | luaE_setdebt(g, stddebt(g)); | 1122 | luaE_setdebt(g, stddebt(g)); |
1120 | } | 1123 | } |