aboutsummaryrefslogtreecommitdiff
path: root/lgc.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-04-29 14:32:40 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-04-29 14:32:40 -0300
commitaaa5d7adab1fd4a2f2d0c1f2996e354445ad163f (patch)
treef11ddbfe31e2e82604e280d9ae5b026bc917429b /lgc.h
parent3eb1788bb4236cd983f1230ee14e2adb1b5b3ff5 (diff)
downloadlua-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.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/lgc.h b/lgc.h
index 38564849..b7e00b38 100644
--- a/lgc.h
+++ b/lgc.h
@@ -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);
100LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency); 117LUAI_FUNC void luaC_fullgc (lua_State *L, int isemergency);
101LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz, 118LUAI_FUNC GCObject *luaC_newobj (lua_State *L, int tt, size_t sz,
102 GCObject **list, int offset); 119 GCObject **list, int offset);
103LUAI_FUNC void luaC_linkupval (lua_State *L, UpVal *uv);
104LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); 120LUAI_FUNC void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v);
105LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t); 121LUAI_FUNC void luaC_barrierback (lua_State *L, Table *t);
106LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u); 122LUAI_FUNC void luaC_checkfinalizer (lua_State *L, Udata *u);