Browse Source

Inline lj_gc_barrierback().

Mike Pall 14 years ago
parent
commit
efcaef22bd
2 changed files with 13 additions and 14 deletions
  1. 0 12
      src/lj_gc.c
  2. 13 2
      src/lj_gc.h

+ 0 - 12
src/lj_gc.c

@@ -33,7 +33,6 @@
 
 
 /* Macros to set GCobj colors and flags. */
 /* Macros to set GCobj colors and flags. */
 #define white2gray(x)		((x)->gch.marked &= (uint8_t)~LJ_GC_WHITES)
 #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 gray2black(x)		((x)->gch.marked |= LJ_GC_BLACK)
 #define makewhite(g, x) \
 #define makewhite(g, x) \
   ((x)->gch.marked = ((x)->gch.marked & (uint8_t)~LJ_GC_COLORS) | curwhite(g))
   ((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 ------------------------------------------------------ */
 /* -- 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. */
 /* Move the GC propagation frontier forward. */
 void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v)
 void lj_gc_barrierf(global_State *g, GCobj *o, GCobj *v)
 {
 {

+ 13 - 2
src/lj_gc.h

@@ -39,6 +39,7 @@ enum {
 #define curwhite(g)	((g)->gc.currentwhite & LJ_GC_WHITES)
 #define curwhite(g)	((g)->gc.currentwhite & LJ_GC_WHITES)
 #define newwhite(g, x)	(obj2gco(x)->gch.marked = (uint8_t)curwhite(g))
 #define newwhite(g, x)	(obj2gco(x)->gch.marked = (uint8_t)curwhite(g))
 #define flipwhite(x)	((x)->gch.marked ^= LJ_GC_WHITES)
 #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)
 #define fixstring(s)	((s)->marked |= LJ_GC_FIXED)
 
 
 /* Collector. */
 /* Collector. */
@@ -66,7 +67,6 @@ LJ_FUNC void lj_gc_fullgc(lua_State *L);
       lj_gc_step_fixtop(L); }
       lj_gc_step_fixtop(L); }
 
 
 /* Write barriers. */
 /* 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_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_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_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);
 LJ_FUNC void lj_gc_barriertrace(global_State *g, uint32_t traceno);
 #endif
 #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. */
 /* Barrier for stores to table objects. TValue and GCobj variant. */
 #define lj_gc_anybarriert(L, t)  \
 #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) \
 #define lj_gc_barriert(L, t, tv) \
   { if (tviswhite(tv) && isblack(obj2gco(t))) \
   { if (tviswhite(tv) && isblack(obj2gco(t))) \
       lj_gc_barrierback(G(L), (t)); }
       lj_gc_barrierback(G(L), (t)); }