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 /lapi.c | |
| parent | 3aa95981779aa8144da11f328a25bf79bd141c41 (diff) | |
| download | lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.tar.gz lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.tar.bz2 lua-5c87f61e6b1567400d2bd8f452939bb948f16dda.zip | |
major collections in generational mode
Diffstat (limited to 'lapi.c')
| -rw-r--r-- | lapi.c | 24 |
1 files changed, 15 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 2.114 2010/03/08 16:55:52 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.115 2010/03/22 18:28:03 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -928,7 +928,6 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
| 928 | break; | 928 | break; |
| 929 | } | 929 | } |
| 930 | case LUA_GCRESTART: { | 930 | case LUA_GCRESTART: { |
| 931 | g->gckind = KGC_NORMAL; | ||
| 932 | g->GCthreshold = g->totalbytes; | 931 | g->GCthreshold = g->totalbytes; |
| 933 | break; | 932 | break; |
| 934 | } | 933 | } |
| @@ -947,13 +946,19 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
| 947 | } | 946 | } |
| 948 | case LUA_GCSTEP: { | 947 | case LUA_GCSTEP: { |
| 949 | lu_mem oldts = g->GCthreshold; | 948 | lu_mem oldts = g->GCthreshold; |
| 950 | lu_mem a = (cast(lu_mem, data) << 10); | 949 | if (g->gckind == KGC_GEN) { /* generational mode? */ |
| 951 | g->GCthreshold = (a <= g->totalbytes) ? g->totalbytes - a : 0; | 950 | res = (g->lastmajormem == 0); /* 1 if will do major collection */ |
| 952 | while (g->GCthreshold <= g->totalbytes) { | 951 | luaC_step(L); /* do a single step */ |
| 953 | luaC_step(L); | 952 | } |
| 954 | if (g->gcstate == GCSpause) { /* end of cycle? */ | 953 | else { |
| 955 | res = 1; /* signal it */ | 954 | lu_mem a = (cast(lu_mem, data) << 10); |
| 956 | break; | 955 | g->GCthreshold = (a <= g->totalbytes) ? g->totalbytes - a : 0; |
| 956 | while (g->GCthreshold <= g->totalbytes) { | ||
| 957 | luaC_step(L); | ||
| 958 | if (g->gcstate == GCSpause) { /* end of cycle? */ | ||
| 959 | res = 1; /* signal it */ | ||
| 960 | break; | ||
| 961 | } | ||
| 957 | } | 962 | } |
| 958 | } | 963 | } |
| 959 | if (oldts == MAX_LUMEM) /* collector was stopped? */ | 964 | if (oldts == MAX_LUMEM) /* collector was stopped? */ |
| @@ -976,6 +981,7 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
| 976 | } | 981 | } |
| 977 | case LUA_GCGEN: { /* change collector to generational mode */ | 982 | case LUA_GCGEN: { /* change collector to generational mode */ |
| 978 | luaC_runtilstate(L, bitmask(GCSpropagate)); | 983 | luaC_runtilstate(L, bitmask(GCSpropagate)); |
| 984 | g->lastmajormem = g->totalbytes; | ||
| 979 | g->gckind = KGC_GEN; | 985 | g->gckind = KGC_GEN; |
| 980 | break; | 986 | break; |
| 981 | } | 987 | } |
