diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-25 16:37:23 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-25 16:37:23 -0300 |
commit | 5c87f61e6b1567400d2bd8f452939bb948f16dda (patch) | |
tree | 1d0944372d58c5dab9f7271c3c3b1a70fe0be0d3 /lgc.c | |
parent | 3aa95981779aa8144da11f328a25bf79bd141c41 (diff) | |
download | lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.tar.gz lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.tar.bz2 lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.zip |
major collections in generational mode
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.71 2010/03/24 15:51:10 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.72 2010/03/25 13:06:36 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 | */ |
@@ -835,11 +835,19 @@ static int prev = 0; | |||
835 | global_State *g = G(L); | 835 | global_State *g = G(L); |
836 | int a = g->totalbytes; | 836 | int a = g->totalbytes; |
837 | lua_assert(g->gcstate == GCSpropagate); | 837 | lua_assert(g->gcstate == GCSpropagate); |
838 | luaC_runtilstate(L, bitmask(GCSpause)); | 838 | if (g->lastmajormem == 0) { /* signal for another major collection? */ |
839 | g->gcstate = GCSpropagate; /* do not run 'markroot' */ | 839 | luaC_fullgc(L, 0); /* perform a full regular collection */ |
840 | g->lastmajormem = g->totalbytes; /* update control */ | ||
841 | } | ||
842 | else { | ||
843 | luaC_runtilstate(L, bitmask(GCSpause)); | ||
844 | g->gcstate = GCSpropagate; /* do not run 'markroot' */ | ||
845 | if (g->totalbytes > g->lastmajormem/100 * g->gcpause) | ||
846 | g->lastmajormem = 0; /* signal for a major collection */ | ||
847 | } | ||
840 | g->GCthreshold = (g->totalbytes/100) * g->gcpause; | 848 | g->GCthreshold = (g->totalbytes/100) * g->gcpause; |
841 | /*printf("count: %d old: %d new: %d dif: %d\n", c++, a, g->totalbytes, | 849 | /*printf("count: %d old: %d new: %d dif: %d lim: %d threshold: %d\n", |
842 | g->totalbytes - prev);*/ | 850 | c++, a, g->totalbytes, g->totalbytes - prev, g->lastmajormem, g->GCthreshold);*/ |
843 | prev = g->totalbytes; | 851 | prev = g->totalbytes; |
844 | } | 852 | } |
845 | 853 | ||
@@ -890,7 +898,7 @@ void luaC_fullgc (lua_State *L, int isemergency) { | |||
890 | if (!isemergency) /* do not run finalizers during emergency GC */ | 898 | if (!isemergency) /* do not run finalizers during emergency GC */ |
891 | luaC_runtilstate(L, bitmask(GCSpause)); | 899 | luaC_runtilstate(L, bitmask(GCSpause)); |
892 | if (origkind == KGC_GEN) { /* generational mode? */ | 900 | if (origkind == KGC_GEN) { /* generational mode? */ |
893 | g->gckind = GCSpause; /* collector must be always in... */ | 901 | g->gcstate = GCSpause; /* collector must be always in... */ |
894 | luaC_runtilstate(L, bitmask(GCSpropagate)); /* ...propagate phase */ | 902 | luaC_runtilstate(L, bitmask(GCSpropagate)); /* ...propagate phase */ |
895 | } | 903 | } |
896 | g->GCthreshold = (g->totalbytes/100) * g->gcpause; | 904 | g->GCthreshold = (g->totalbytes/100) * g->gcpause; |