diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-10 11:25:02 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-02-10 11:25:02 -0200 |
commit | 4df8800a01c7e44800ce59339c66b9257cd75c2a (patch) | |
tree | 226ae5cfc06164f6f01e33d778336c1ffd561d72 /lgc.h | |
parent | 0e60572606684458b18febfcef0bc68235b461f4 (diff) | |
download | lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.tar.gz lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.tar.bz2 lua-4df8800a01c7e44800ce59339c66b9257cd75c2a.zip |
cleaner way to free all objects
Diffstat (limited to 'lgc.h')
-rw-r--r-- | lgc.h | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.h,v 2.9 2004/09/15 20:38:15 roberto Exp $ | 2 | ** $Id: lgc.h,v 2.10 2005/01/19 15:54:26 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 | */ |
@@ -47,8 +47,10 @@ | |||
47 | ** bit 3 - for tables: has weak keys | 47 | ** bit 3 - for tables: has weak keys |
48 | ** bit 4 - for tables: has weak values | 48 | ** bit 4 - for tables: has weak values |
49 | ** bit 5 - object is fixed (should not be collected) | 49 | ** bit 5 - object is fixed (should not be collected) |
50 | ** bit 6 - object is "super" fixed (only the main thread) | ||
50 | */ | 51 | */ |
51 | 52 | ||
53 | |||
52 | #define WHITE0BIT 0 | 54 | #define WHITE0BIT 0 |
53 | #define WHITE1BIT 1 | 55 | #define WHITE1BIT 1 |
54 | #define BLACKBIT 2 | 56 | #define BLACKBIT 2 |
@@ -56,21 +58,23 @@ | |||
56 | #define KEYWEAKBIT 3 | 58 | #define KEYWEAKBIT 3 |
57 | #define VALUEWEAKBIT 4 | 59 | #define VALUEWEAKBIT 4 |
58 | #define FIXEDBIT 5 | 60 | #define FIXEDBIT 5 |
61 | #define SFIXEDBIT 6 | ||
62 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | ||
59 | 63 | ||
60 | 64 | ||
61 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) | 65 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) |
62 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) | 66 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) |
63 | #define isgray(x) (!isblack(x) && !iswhite(x)) | 67 | #define isgray(x) (!isblack(x) && !iswhite(x)) |
64 | 68 | ||
65 | #define otherwhite(g) (g->currentwhite ^ bit2mask(WHITE0BIT, WHITE1BIT)) | 69 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) |
66 | #define isdead(g,v) ((v)->gch.marked & otherwhite(g)) | 70 | #define isdead(g,v) ((v)->gch.marked & otherwhite(g) & WHITEBITS) |
67 | 71 | ||
68 | #define changewhite(x) ((x)->gch.marked ^= bit2mask(WHITE0BIT, WHITE1BIT)) | 72 | #define changewhite(x) ((x)->gch.marked ^= WHITEBITS) |
69 | #define gray2black(x) setbit((x)->gch.marked, BLACKBIT) | 73 | #define gray2black(x) setbit((x)->gch.marked, BLACKBIT) |
70 | 74 | ||
71 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) | 75 | #define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x))) |
72 | 76 | ||
73 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite) | 77 | #define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS) |
74 | 78 | ||
75 | 79 | ||
76 | #define luaC_checkGC(L) { if (G(L)->totalbytes >= G(L)->GCthreshold) \ | 80 | #define luaC_checkGC(L) { if (G(L)->totalbytes >= G(L)->GCthreshold) \ |