From efcaef22bd5e7dc54c87e8f1a23b514fbda97d29 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 10 Apr 2011 20:45:36 +0200 Subject: [PATCH] Inline lj_gc_barrierback(). --- src/lj_gc.c | 12 ------------ src/lj_gc.h | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/lj_gc.c b/src/lj_gc.c index 5d795596..aba19d3f 100644 --- a/src/lj_gc.c +++ b/src/lj_gc.c @@ -33,7 +33,6 @@ /* 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)) @@ -740,17 +739,6 @@ void lj_gc_fullgc(lua_State *L) /* -- 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) { 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 { #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. */ @@ -66,7 +67,6 @@ LJ_FUNC void lj_gc_fullgc(lua_State *L); 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); @@ -74,9 +74,20 @@ 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)); }