diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-13 15:23:21 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-08-13 15:23:21 -0300 |
commit | f849885a4b49f2d766e6befc67475c05240023eb (patch) | |
tree | ab680958b8cac3cef61c63d5c54c448db7f100ae /lgc.h | |
parent | f7ce7e5faae69fcab0126d8bfd34b685f1dcb019 (diff) | |
download | lua-f849885a4b49f2d766e6befc67475c05240023eb.tar.gz lua-f849885a4b49f2d766e6befc67475c05240023eb.tar.bz2 lua-f849885a4b49f2d766e6befc67475c05240023eb.zip |
Small changes in macros that change GC colors
- Macro 'gray2black' was renamed 'nw2black' (Non-White to black), as it
was already being used on objects that could be already black.
- Macros 'white2gray' and 'black2gray' were unified in 'set2gray'; no
reason to have two macros when one will do and, again, 'black2gray' was
already being used on objects that could be already gray.
Moreover, macros 'maskcolors' and 'maskgcbits' were negated to have
ones in the described bits, instead of zeros. (This naming seems more
intuitive.)
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 | ||