/* Macros to set GCobj colors and flags. */
#define white2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES)
-#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK)
#define gray2black(x) ((x)->gch.marked |= LJ_GC_BLACK)
#define makewhite(g, x) \
((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g))
/* -- Write barriers ------------------------------------------------------ */
-/* Move the GC propagation frontier back for tables (make it gray again). */
-void lj_gc_barrierback(global_State *g, GCtab *t)
-{
- GCobj *o = obj2gco(t);
- lua_assert(isblack(o) && !isdead(g, o));
- lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause);
- black2gray(o);
- setgcrefr(t->gclist, g->gc.grayagain);
- setgcref(g->gc.grayagain, o);
-}
-
/* Move the GC propagation frontier forward. */
void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v)
{
#define curwhite(g) ((g)->gc.currentwhite & LJ_GC_WHITES)
#define newwhite(g, x) (obj2gco(x)->gch.marked = (uint8_t)curwhite(g))
#define flipwhite(x) ((x)->gch.marked ^= LJ_GC_WHITES)
+#define black2gray(x) ((x)->gch.marked &= (uint8_t)~LJ_GC_BLACK)
#define fixstring(s) ((s)->marked |= LJ_GC_FIXED)
/* Collector. */
lj_gc_step_fixtop(L); }
/* Write barriers. */
-LJ_FUNC void lj_gc_barrierback(global_State *g, GCtab *t);
LJ_FUNC void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v);
LJ_FUNCA void LJ_FASTCALL lj_gc_barrieruv(global_State *g, TValue *tv);
LJ_FUNC void lj_gc_closeuv(global_State *g, GCupval *uv);
LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno);
#endif
+/* Move the GC propagation frontier back for tables (make it gray again). */
+static LJ_AINLINE void lj_gc_barrierback(global_State *g, GCtab *t)
+{
+ GCobj *o = obj2gco(t);
+ lua_assert(isblack(o) && !isdead(g, o));
+ lua_assert(g->gc.state != GCSfinalize && g->gc.state != GCSpause);
+ black2gray(o);
+ setgcrefr(t->gclist, g->gc.grayagain);
+ setgcref(g->gc.grayagain, o);
+}
+
/* Barrier for stores to table objects. TValue and GCobj variant. */
#define lj_gc_anybarriert(L, t) \
- { if (isblack(obj2gco(t))) lj_gc_barrierback(G(L), (t)); }
+ { if (LJ_UNLIKELY(isblack(obj2gco(t)))) lj_gc_barrierback(G(L), (t)); }
#define lj_gc_barriert(L, t, tv) \
{ if (tviswhite(tv) && isblack(obj2gco(t))) \
lj_gc_barrierback(G(L), (t)); }