diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-12-09 14:56:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-12-09 14:56:11 -0200 |
commit | df429f163ada6581d921e7f51b016f1abfeefddd (patch) | |
tree | a1af3ce961377e6548074f706f65e2b34181918f /lgc.h | |
parent | fe595a45c246faf2cf12084e7aac4b772f8f72da (diff) | |
download | lua-df429f163ada6581d921e7f51b016f1abfeefddd.tar.gz lua-df429f163ada6581d921e7f51b016f1abfeefddd.tar.bz2 lua-df429f163ada6581d921e7f51b016f1abfeefddd.zip |
First version of incremental GC
Diffstat (limited to 'lgc.h')
-rw-r--r-- | lgc.h | 25 |
1 files changed, 22 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 1.26 2003/12/03 20:03:07 roberto Exp roberto $ | 2 | ** $Id: lgc.h,v 1.27 2003/12/04 17:22:42 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 | */ |
@@ -58,18 +58,37 @@ | |||
58 | #define FIXEDBIT 5 | 58 | #define FIXEDBIT 5 |
59 | 59 | ||
60 | 60 | ||
61 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) | ||
62 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) | ||
63 | |||
64 | |||
65 | #define otherwhite(g) (g->currentwhite ^ bit2mask(WHITE0BIT, WHITE1BIT)) | ||
66 | #define isdead(g,v) ((v)->gch.marked & otherwhite(g)) | ||
67 | |||
68 | #define changewhite(x) ((x)->gch.marked ^= bit2mask(WHITE0BIT, WHITE1BIT)) | ||
69 | |||
70 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) | ||
71 | |||
61 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite) | 72 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite) |
62 | 73 | ||
63 | 74 | ||
64 | #define luaC_checkGC(L) { if (G(L)->nblocks >= G(L)->GCthreshold) \ | 75 | #define luaC_checkGC(L) { if (G(L)->nblocks >= G(L)->GCthreshold) \ |
65 | luaC_collectgarbage(L); } | 76 | luaC_step(L); } |
77 | |||
78 | |||
79 | #define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(valtogco(p))) \ | ||
80 | luaC_barrierf(L,valtogco(p),gcvalue(v)); } | ||
66 | 81 | ||
82 | #define luaC_objbarrier(L,p,o) \ | ||
83 | { if (iswhite(valtogco(o)) && isblack(valtogco(p))) \ | ||
84 | luaC_barrierf(L,valtogco(p),valtogco(o)); } | ||
67 | 85 | ||
68 | size_t luaC_separateudata (lua_State *L); | 86 | size_t luaC_separateudata (lua_State *L); |
69 | void luaC_callGCTM (lua_State *L); | 87 | void luaC_callGCTM (lua_State *L); |
70 | void luaC_sweepall (lua_State *L); | 88 | void luaC_sweepall (lua_State *L); |
71 | void luaC_collectgarbage (lua_State *L); | 89 | void luaC_step (lua_State *L); |
72 | void luaC_link (lua_State *L, GCObject *o, lu_byte tt); | 90 | void luaC_link (lua_State *L, GCObject *o, lu_byte tt); |
91 | void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v); | ||
73 | 92 | ||
74 | 93 | ||
75 | #endif | 94 | #endif |