diff options
Diffstat (limited to '')
-rw-r--r-- | lgc.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.124 2012/05/21 13:18:10 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.125 2012/05/22 17:32:25 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 | */ |
@@ -917,7 +917,7 @@ void luaC_changemode (lua_State *L, int mode) { | |||
917 | if (mode == KGC_GEN) { /* change to generational mode */ | 917 | if (mode == KGC_GEN) { /* change to generational mode */ |
918 | /* make sure gray lists are consistent */ | 918 | /* make sure gray lists are consistent */ |
919 | luaC_runtilstate(L, bitmask(GCSpropagate)); | 919 | luaC_runtilstate(L, bitmask(GCSpropagate)); |
920 | g->lastmajormem = gettotalbytes(g); | 920 | g->GCestimate = gettotalbytes(g); |
921 | g->gckind = KGC_GEN; | 921 | g->gckind = KGC_GEN; |
922 | } | 922 | } |
923 | else { /* change to incremental mode */ | 923 | else { /* change to incremental mode */ |
@@ -1014,7 +1014,7 @@ static lu_mem singlestep (lua_State *L) { | |||
1014 | } | 1014 | } |
1015 | else { /* no more `gray' objects */ | 1015 | else { /* no more `gray' objects */ |
1016 | g->gcstate = GCSatomic; /* finish mark phase */ | 1016 | g->gcstate = GCSatomic; /* finish mark phase */ |
1017 | g->estimate = g->GCmemtrav; /* save what was counted */ | 1017 | g->GCestimate = g->GCmemtrav; /* save what was counted */ |
1018 | atomic(L); | 1018 | atomic(L); |
1019 | return GCATOMICCOST; | 1019 | return GCATOMICCOST; |
1020 | } | 1020 | } |
@@ -1070,15 +1070,16 @@ void luaC_runtilstate (lua_State *L, int statesmask) { | |||
1070 | 1070 | ||
1071 | static void generationalcollection (lua_State *L) { | 1071 | static void generationalcollection (lua_State *L) { |
1072 | global_State *g = G(L); | 1072 | global_State *g = G(L); |
1073 | if (g->lastmajormem == 0) { /* signal for another major collection? */ | 1073 | if (g->GCestimate == 0) { /* signal for another major collection? */ |
1074 | luaC_fullgc(L, 0); /* perform a full regular collection */ | 1074 | luaC_fullgc(L, 0); /* perform a full regular collection */ |
1075 | g->lastmajormem = gettotalbytes(g); /* update control */ | 1075 | g->GCestimate = gettotalbytes(g); /* update control */ |
1076 | } | 1076 | } |
1077 | else { | 1077 | else { |
1078 | lu_mem estimate = g->GCestimate; | ||
1078 | luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ | 1079 | luaC_runtilstate(L, ~bitmask(GCSpause)); /* run complete cycle */ |
1079 | luaC_runtilstate(L, bitmask(GCSpause)); | 1080 | luaC_runtilstate(L, bitmask(GCSpause)); |
1080 | if (gettotalbytes(g) > g->lastmajormem/100 * g->gcmajorinc) | 1081 | if (gettotalbytes(g) > (estimate / 100) * g->gcmajorinc) |
1081 | g->lastmajormem = 0; /* signal for a major collection */ | 1082 | g->GCestimate = 0; /* signal for a major collection */ |
1082 | } | 1083 | } |
1083 | luaE_setdebt(g, stddebt(g)); | 1084 | luaE_setdebt(g, stddebt(g)); |
1084 | } | 1085 | } |
@@ -1095,7 +1096,7 @@ static void step (lua_State *L) { | |||
1095 | debt -= work; | 1096 | debt -= work; |
1096 | } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); | 1097 | } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); |
1097 | if (g->gcstate == GCSpause) | 1098 | if (g->gcstate == GCSpause) |
1098 | debt = stddebtest(g, g->estimate); /* pause until next cycle */ | 1099 | debt = stddebtest(g, g->GCestimate); /* pause until next cycle */ |
1099 | luaE_setdebt(g, debt); | 1100 | luaE_setdebt(g, debt); |
1100 | } | 1101 | } |
1101 | 1102 | ||