diff options
| author | Li Jin <dragon-fly@qq.com> | 2020-09-11 15:31:51 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2020-09-11 15:31:51 +0800 |
| commit | 85b9ec82247f6e06b802188af35d09d3159625df (patch) | |
| tree | 487152fb9639a74e323f7db962f558ba0514322d /src/lua/lgc.h | |
| parent | dfd4e3b2b2abc0137d26ed3df303a398741bb6a0 (diff) | |
| download | yuescript-85b9ec82247f6e06b802188af35d09d3159625df.tar.gz yuescript-85b9ec82247f6e06b802188af35d09d3159625df.tar.bz2 yuescript-85b9ec82247f6e06b802188af35d09d3159625df.zip | |
update Lua.
Diffstat (limited to 'src/lua/lgc.h')
| -rw-r--r-- | src/lua/lgc.h | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/lua/lgc.h b/src/lua/lgc.h index b972472..073e2a4 100644 --- a/src/lua/lgc.h +++ b/src/lua/lgc.h | |||
| @@ -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 | ||
| @@ -69,14 +69,16 @@ | |||
| 69 | 69 | ||
| 70 | /* | 70 | /* |
| 71 | ** Layout for bit use in 'marked' field. First three bits are | 71 | ** Layout for bit use in 'marked' field. First three bits are |
| 72 | ** used for object "age" in generational mode. Last bit is free | 72 | ** used for object "age" in generational mode. Last bit is used |
| 73 | ** to be used by respective objects. | 73 | ** by tests. |
| 74 | */ | 74 | */ |
| 75 | #define WHITE0BIT 3 /* object is white (type 0) */ | 75 | #define WHITE0BIT 3 /* object is white (type 0) */ |
| 76 | #define WHITE1BIT 4 /* object is white (type 1) */ | 76 | #define WHITE1BIT 4 /* object is white (type 1) */ |
| 77 | #define BLACKBIT 5 /* object is black */ | 77 | #define BLACKBIT 5 /* object is black */ |
| 78 | #define FINALIZEDBIT 6 /* object has been marked for finalization */ | 78 | #define FINALIZEDBIT 6 /* object has been marked for finalization */ |
| 79 | 79 | ||
| 80 | #define TESTBIT 7 | ||
| 81 | |||
| 80 | 82 | ||
| 81 | 83 | ||
| 82 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) | 84 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) |
| @@ -94,7 +96,8 @@ | |||
| 94 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) | 96 | #define isdead(g,v) isdeadm(otherwhite(g), (v)->marked) |
| 95 | 97 | ||
| 96 | #define changewhite(x) ((x)->marked ^= WHITEBITS) | 98 | #define changewhite(x) ((x)->marked ^= WHITEBITS) |
| 97 | #define gray2black(x) l_setbit((x)->marked, BLACKBIT) | 99 | #define nw2black(x) \ |
| 100 | check_exp(!iswhite(x), l_setbit((x)->marked, BLACKBIT)) | ||
| 98 | 101 | ||
| 99 | #define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) | 102 | #define luaC_white(g) cast_byte((g)->currentwhite & WHITEBITS) |
| 100 | 103 | ||
