diff options
Diffstat (limited to 'src/lj_gc.h')
-rw-r--r-- | src/lj_gc.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lj_gc.h b/src/lj_gc.h index e3973d8e..ec1a9643 100644 --- a/src/lj_gc.h +++ b/src/lj_gc.h | |||
@@ -39,6 +39,7 @@ enum { | |||
39 | #define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) | 39 | #define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES) |
40 | #define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) | 40 | #define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g)) |
41 | #define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) | 41 | #define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES) |
42 | #define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK) | ||
42 | #define fixstring(s) ((s)->marked |= LJ_GC_FIXED) | 43 | #define fixstring(s) ((s)->marked |= LJ_GC_FIXED) |
43 | 44 | ||
44 | /* Collector. */ | 45 | /* Collector. */ |
@@ -66,7 +67,6 @@ LJ_FUNC void lj_gc_fullgc(lua_State *L); | |||
66 | lj_gc_step_fixtop(L); } | 67 | lj_gc_step_fixtop(L); } |
67 | 68 | ||
68 | /* Write barriers. */ | 69 | /* Write barriers. */ |
69 | LJ_FUNC void lj_gc_barrierback(global_State *g, GCtab *t); | ||
70 | LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); | 70 | LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v); |
71 | LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); | 71 | LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv); |
72 | LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); | 72 | LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); |
@@ -74,9 +74,20 @@ LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv); | |||
74 | LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); | 74 | LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | /* Move the GC propagation frontier back for tables (make it gray again). */ | ||
78 | static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t) | ||
79 | { | ||
80 | GCobj *o = obj2gco(t); | ||
81 | lua_assert(isblack(o) && !isdead(g, o)); | ||
82 | lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause); | ||
83 | black2gray(o); | ||
84 | setgcrefr(t->gclist, g->gc.grayagain); | ||
85 | setgcref(g->gc.grayagain, o); | ||
86 | } | ||
87 | |||
77 | /* Barrier for stores to table objects. TValue and GCobj variant. */ | 88 | /* Barrier for stores to table objects. TValue and GCobj variant. */ |
78 | #define lj_gc_anybarriert(L, t) \ | 89 | #define lj_gc_anybarriert(L, t) \ |
79 | { if (isblack(obj2gco(t))) lj_gc_barrierback(G(L), (t)); } | 90 | { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); } |
80 | #define lj_gc_barriert(L, t, tv) \ | 91 | #define lj_gc_barriert(L, t, tv) \ |
81 | { if (tviswhite(tv) && isblack(obj2gco(t))) \ | 92 | { if (tviswhite(tv) && isblack(obj2gco(t))) \ |
82 | lj_gc_barrierback(G(L), (t)); } | 93 | lj_gc_barrierback(G(L), (t)); } |