diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-29 14:32:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-04-29 14:32:40 -0300 |
commit | aaa5d7adab1fd4a2f2d0c1f2996e354445ad163f (patch) | |
tree | f11ddbfe31e2e82604e280d9ae5b026bc917429b /lgc.h | |
parent | 3eb1788bb4236cd983f1230ee14e2adb1b5b3ff5 (diff) | |
download | lua-aaa5d7adab1fd4a2f2d0c1f2996e354445ad163f.tar.gz lua-aaa5d7adab1fd4a2f2d0c1f2996e354445ad163f.tar.bz2 lua-aaa5d7adab1fd4a2f2d0c1f2996e354445ad163f.zip |
'luaC_linkupval' moved into 'lfunc.c' code + new way to control GC speed
Diffstat (limited to 'lgc.h')
-rw-r--r-- | lgc.h | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.29 2010/03/24 15:51:10 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 2.30 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 | */ |
@@ -23,6 +23,24 @@ | |||
23 | #define GCSfinalize 6 | 23 | #define GCSfinalize 6 |
24 | 24 | ||
25 | 25 | ||
26 | #define issweepphase(g) \ | ||
27 | (GCSsweepstring <= (g)->gcstate && (g)->gcstate <= GCSsweep) | ||
28 | |||
29 | |||
30 | /* | ||
31 | ** macro to tell when main invariant (white objects cannot point to black | ||
32 | ** ones) must be kept. During a non-generational collection, the sweep | ||
33 | ** phase may brak the invariant, as objects turned white may point to | ||
34 | ** still-black objects. The invariant is restored when sweep ends and | ||
35 | ** all objects are white again. During a generational collection, the | ||
36 | ** invariant must be kept all times. | ||
37 | */ | ||
38 | #define keepinvariant(g) (g->gckind == KGC_GEN || g->gcstate == GCSpropagate) | ||
39 | |||
40 | |||
41 | #define gcstopped(g) ((g)->GCdebt == MIN_LMEM) | ||
42 | #define stopgc(g) ((g)->GCdebt = MIN_LMEM) | ||
43 | |||
26 | 44 | ||
27 | /* | 45 | /* |
28 | ** some useful bit tricks | 46 | ** some useful bit tricks |
@@ -76,8 +94,7 @@ | |||
76 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) | 94 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) |
77 | 95 | ||
78 | 96 | ||
79 | #define luaC_checkGC(L) \ | 97 | #define luaC_checkGC(L) {condchangemem(L); if (G(L)->GCdebt > 0) luaC_step(L);} |
80 | {condchangemem(L); if (G(L)->totalbytes >= G(L)->GCthreshold) luaC_step(L);} | ||
81 | 98 | ||
82 | 99 | ||
83 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ | 100 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \ |
@@ -100,7 +117,6 @@ LUAI_FUNC void luaC_runtilstate (lua_State *L, int statesmask); | |||
100 | LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); | 117 | LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); |
101 | LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, | 118 | LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, |
102 | GCObject **list, int offset); | 119 | GCObject **list, int offset); |
103 | LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv); | ||
104 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); | 120 | LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); |
105 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); | 121 | LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); |
106 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); | 122 | LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); |