diff options
author | Lua Team <team@lua.org> | 2012-05-28 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2012-05-28 12:00:00 +0000 |
commit | 5a152a0a57f98f38472fac54b62fa8cdb9708d29 (patch) | |
tree | a6438cac84faa16532305c4d65642b86af9d2b61 | |
parent | ad17e8349cfc1992f1df7ae937fc146b1a0d564e (diff) | |
download | lua-github-5a152a0a57f98f38472fac54b62fa8cdb9708d29.tar.gz |
Lua 5.2.1-rc25.2.1-rc2
-rw-r--r-- | doc/contents.html | 4 | ||||
-rw-r--r-- | doc/manual.html | 2 | ||||
-rw-r--r-- | src/lgc.c | 47 | ||||
-rw-r--r-- | src/llimits.h | 4 |
4 files changed, 35 insertions, 22 deletions
diff --git a/doc/contents.html b/doc/contents.html index 8340ff35..9f506051 100644 --- a/doc/contents.html +++ b/doc/contents.html @@ -35,7 +35,7 @@ For a complete introduction to Lua programming, see the book <SMALL> Copyright © 2011–2012 Lua.org, PUC-Rio. Freely available under the terms of the -<A HREF="http://www.lua.org/license.html#5">Lua license</A>. +<A HREF="http://www.lua.org/license.html">Lua license</A>. </SMALL> <H2><A NAME="contents">Contents</A></H2> @@ -521,7 +521,7 @@ Freely available under the terms of the <HR> <SMALL CLASS="footer"> Last update: -Wed May 23 13:28:09 BRT 2012 +Sat May 26 08:52:25 BRT 2012 </SMALL> <!-- Last change: revised for Lua 5.2.1 diff --git a/doc/manual.html b/doc/manual.html index cd6dda52..71b607d4 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -21,7 +21,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes <small> Copyright © 2011–2012 Lua.org, PUC-Rio. Freely available under the terms of the -<a href="http://www.lua.org/license.html#5">Lua license</a>. +<a href="http://www.lua.org/license.html">Lua license</a>. </small> <hr> <p> @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.128 2012/05/23 15:43:14 roberto Exp $ +** $Id: lgc.c,v 2.129 2012/05/28 20:41:00 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -24,8 +24,11 @@ -/* cost of sweeping one element (half the size of a small object) */ -#define GCSWEEPCOST ((sizeof(TString) + 4) / 2) +/* +** cost of sweeping one element (the size of a small object divided +** by some adjust for the sweep speed) +*/ +#define GCSWEEPCOST ((sizeof(TString) + 4) / 4) /* maximum number of elements to sweep in each single step */ #define GCSWEEPMAX (cast_int((GCSTEPSIZE / GCSWEEPCOST) / 4)) @@ -33,25 +36,27 @@ /* maximum number of finalizers to call in each GC step */ #define GCFINALIZENUM 4 -/* (arbitrary) cost of atomic step */ -#define GCATOMICCOST GCSTEPSIZE +/* +** macro to adjust 'stepmul': 'stepmul' is actually used like +** 'stepmul / STEPMULADJ' (value chosen by tests) +*/ +#define STEPMULADJ 200 /* -** macro to apply the "speed" of the garbage collector: the constant -** 80 makes the standard 'stepmul' of 200 results in the GC handling -** 80/200 = 1/2.5 = 0.4Kbytes for every 1Kb allocated. -** (The computation tries to avoid overflows or underflows.) +** macro to adjust 'pause': 'pause' is actually used like +** 'pause / PAUSEADJ' (value chosen by tests) */ -#define workrate(x,mul) \ - ((x) < MAX_INT/80 ? ((x) * 80) / mul : ((x) / mul) * 80) +#define PAUSEADJ 200 + + /* ** standard negative debt for GC; a reasonable "time" to wait before ** starting a new cycle */ -#define stddebtest(g,e) (-cast(l_mem, (e)/100) * g->gcpause) +#define stddebtest(g,e) (-cast(l_mem, (e)/PAUSEADJ) * g->gcpause) #define stddebt(g) stddebtest(g, gettotalbytes(g)) @@ -672,7 +677,7 @@ static void freeobj (lua_State *L, GCObject *o) { case LUA_TTABLE: luaH_free(L, gco2t(o)); break; case LUA_TTHREAD: luaE_freethread(L, gco2th(o)); break; case LUA_TUSERDATA: luaM_freemem(L, o, sizeudata(gco2u(o))); break; - case LUA_TSHRSTR: + case LUA_TSHRSTR: G(L)->strt.nuse--; /* go through */ case LUA_TLNGSTR: { @@ -955,8 +960,9 @@ void luaC_freeallobjects (lua_State *L) { } -static void atomic (lua_State *L) { +static l_mem atomic (lua_State *L) { global_State *g = G(L); + l_mem trav = g->GCmemtrav; GCObject *origweak, *origall; lua_assert(!iswhite(obj2gco(g->mainthread))); markobject(g, L); /* mark running thread */ @@ -976,6 +982,7 @@ static void atomic (lua_State *L) { separatetobefnz(L, 0); /* separate objects to be finalized */ markbeingfnz(g); /* mark userdata that will be finalized */ propagateall(g); /* remark, to propagate `preserveness' */ + trav = g->GCmemtrav - trav; /* avoid adding convergence twice */ convergeephemerons(g); /* at this point, all resurrected objects are marked. */ /* remove dead objects from weak tables */ @@ -987,6 +994,7 @@ static void atomic (lua_State *L) { g->currentwhite = cast_byte(otherwhite(g)); /* flip current white */ entersweep(L); /* prepare to sweep strings */ /*lua_checkmemory(L);*/ + return trav; /* reasonable estimate of the work done by 'atomic' */ } @@ -1012,8 +1020,7 @@ static lu_mem singlestep (lua_State *L) { else { /* no more `gray' objects */ g->gcstate = GCSatomic; /* finish mark phase */ g->GCestimate = g->GCmemtrav; /* save what was counted */ - atomic(L); - return GCATOMICCOST; + return atomic(L); } } case GCSsweepstring: { @@ -1086,14 +1093,18 @@ static void step (lua_State *L) { global_State *g = G(L); l_mem debt = g->GCdebt; int stepmul = g->gcstepmul; - if (stepmul <= 0) stepmul = 1; + if (stepmul < 40) stepmul = 40; /* avoid ridiculous low values */ + /* convert debt from Kb to 'work units' (avoid zero debt and overflows) */ + debt = (debt / STEPMULADJ) + 1; + debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; do { /* always perform at least one single step */ lu_mem work = singlestep(L); /* do some work */ - work = workrate(work, stepmul); /* apply work rate */ debt -= work; } while (debt > -GCSTEPSIZE && g->gcstate != GCSpause); if (g->gcstate == GCSpause) debt = stddebtest(g, g->GCestimate); /* pause until next cycle */ + else + debt = (debt / stepmul) * STEPMULADJ; /* convert 'work units' to Kb */ luaE_setdebt(g, debt); } diff --git a/src/llimits.h b/src/llimits.h index 6b2b4b9a..fc9de1a1 100644 --- a/src/llimits.h +++ b/src/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.98 2012/05/11 14:10:50 roberto Exp $ +** $Id: llimits.h,v 1.99 2012/05/28 20:32:28 roberto Exp $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -31,6 +31,8 @@ typedef unsigned char lu_byte; #define MAX_LUMEM ((lu_mem)(~(lu_mem)0)-2) +#define MAX_LMEM ((l_mem) ((MAX_LUMEM >> 1) - 2)) + #define MAX_INT (INT_MAX-2) /* maximum value of an int (-2 for safety) */ |