21 #include "lstring.h" |
21 #include "lstring.h" |
22 #include "ltable.h" |
22 #include "ltable.h" |
23 #include "ltm.h" |
23 #include "ltm.h" |
24 |
24 |
25 |
25 |
26 #define GCSTEPSIZE 1024u |
26 #define GCSTEPSIZE 1024u |
27 #define GCSWEEPMAX 40 |
27 #define GCSWEEPMAX 40 |
28 #define GCSWEEPCOST 10 |
28 #define GCSWEEPCOST 10 |
29 #define GCFINALIZECOST 100 |
29 #define GCFINALIZECOST 100 |
30 |
30 |
31 |
31 |
32 #define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) |
32 #define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) |
33 |
33 |
34 #define makewhite(g,x) \ |
34 #define makewhite(g,x) \ |
35 ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) |
35 ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) |
36 |
36 |
37 #define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) |
37 #define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) |
38 #define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) |
38 #define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) |
39 |
39 |
40 #define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) |
40 #define stringmark(s) reset2bits((s)->tsv.marked, WHITE0BIT, WHITE1BIT) |
41 |
41 |
42 |
42 |
43 #define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) |
43 #define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) |
44 #define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) |
44 #define markfinalized(u) l_setbit((u)->marked, FINALIZEDBIT) |
45 |
45 |
46 |
46 |
47 #define KEYWEAK bitmask(KEYWEAKBIT) |
47 #define KEYWEAK bitmask(KEYWEAKBIT) |
48 #define VALUEWEAK bitmask(VALUEWEAKBIT) |
48 #define VALUEWEAK bitmask(VALUEWEAKBIT) |
49 |
49 |
51 |
51 |
52 #define markvalue(g,o) { checkconsistency(o); \ |
52 #define markvalue(g,o) { checkconsistency(o); \ |
53 if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } |
53 if (iscollectable(o) && iswhite(gcvalue(o))) reallymarkobject(g,gcvalue(o)); } |
54 |
54 |
55 #define markobject(g,t) { if (iswhite(obj2gco(t))) \ |
55 #define markobject(g,t) { if (iswhite(obj2gco(t))) \ |
56 reallymarkobject(g, obj2gco(t)); } |
56 reallymarkobject(g, obj2gco(t)); } |
57 |
57 |
58 |
58 |
59 #define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) |
59 #define setthreshold(g) (g->GCthreshold = (g->estimate/100) * g->gcpause) |
60 |
60 |
61 |
61 |
399 } |
399 } |
400 } |
400 } |
401 |
401 |
402 |
402 |
403 |
403 |
404 #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) |
404 #define sweepwholelist(L,p) sweeplist(L,p,MAX_LUMEM) |
405 |
405 |
406 |
406 |
407 static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { |
407 static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) { |
408 GCObject *curr; |
408 GCObject *curr; |
409 global_State *g = G(L); |
409 global_State *g = G(L); |