diff options
Diffstat (limited to 'lgc.h')
-rw-r--r-- | lgc.h | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -12,16 +12,16 @@ | |||
12 | #include "lstate.h" | 12 | #include "lstate.h" |
13 | 13 | ||
14 | /* | 14 | /* |
15 | ** Collectable objects may have one of three colors: white, which | 15 | ** Collectable objects may have one of three colors: white, which means |
16 | ** means the object is not marked; gray, which means the | 16 | ** the object is not marked; gray, which means the object is marked, but |
17 | ** object is marked, but its references may be not marked; and | 17 | ** its references may be not marked; and black, which means that the |
18 | ** black, which means that the object and all its references are marked. | 18 | ** object and all its references are marked. The main invariant of the |
19 | ** The main invariant of the garbage collector, while marking objects, | 19 | ** garbage collector, while marking objects, is that a black object can |
20 | ** is that a black object can never point to a white one. Moreover, | 20 | ** never point to a white one. Moreover, any gray object must be in a |
21 | ** any gray object must be in a "gray list" (gray, grayagain, weak, | 21 | ** "gray list" (gray, grayagain, weak, allweak, ephemeron) so that it |
22 | ** allweak, ephemeron) so that it can be visited again before finishing | 22 | ** can be visited again before finishing the collection cycle. (Open |
23 | ** the collection cycle. These lists have no meaning when the invariant | 23 | ** upvalues are an exception to this rule.) These lists have no meaning |
24 | ** is not being enforced (e.g., sweep phase). | 24 | ** when the invariant is not being enforced (e.g., sweep phase). |
25 | */ | 25 | */ |
26 | 26 | ||
27 | 27 | ||
@@ -96,7 +96,8 @@ | |||
96 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) | 96 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) |
97 | 97 | ||
98 | #define changewhite(x) ((x)->marked ^= WHITEBITS) | 98 | #define changewhite(x) ((x)->marked ^= WHITEBITS) |
99 | #define gray2black(x) l_setbit((x)->marked, BLACKBIT) | 99 | #define nw2black(x) \ |
100 | check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT)) | ||
100 | 101 | ||
101 | #define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) | 102 | #define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) |
102 | 103 | ||