1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00

barrier conditions rewritten to test first 'isblack' and then 'iswhite'

(during a pause all objects are white, so 'isblack' fails much more
often than 'iswhite')
This commit is contained in:
Roberto Ierusalimschy 2013-08-13 14:36:44 -03:00
parent 78b941039d
commit 3679d33b02
2 changed files with 11 additions and 9 deletions

4
lgc.c
View File

@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.143 2013/08/07 12:18:11 roberto Exp roberto $
** $Id: lgc.c,v 2.144 2013/08/07 15:39:09 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -63,6 +63,8 @@
#define black2gray(x) resetbit(gch(x)->marked, BLACKBIT)
#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
#define isfinalized(x) testbit(gch(x)->marked, FINALIZEDBIT)
#define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n)))

16
lgc.h
View File

@ -1,5 +1,5 @@
/*
** $Id: lgc.h,v 2.58 2012/09/11 12:53:08 roberto Exp roberto $
** $Id: lgc.h,v 2.59 2013/08/05 16:58:28 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -97,8 +97,6 @@
#define changewhite(x) ((x)->gch.marked ^= WHITEBITS)
#define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT)
#define valiswhite(x) (iscollectable(x) && iswhite(gcvalue(x)))
#define luaC_white(g) cast(lu_byte, (g)->currentwhite & WHITEBITS)
@ -107,18 +105,20 @@
#define luaC_checkGC(L) luaC_condGC(L, luaC_step(L);)
#define luaC_barrier(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
#define luaC_barrier(L,p,v) { \
if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \
luaC_barrier_(L,obj2gco(p),gcvalue(v)); }
#define luaC_barrierback(L,p,v) { if (valiswhite(v) && isblack(obj2gco(p))) \
#define luaC_barrierback(L,p,v) { \
if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \
luaC_barrierback_(L,p); }
#define luaC_objbarrier(L,p,o) \
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) \
#define luaC_objbarrier(L,p,o) { \
if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) \
luaC_barrier_(L,obj2gco(p),obj2gco(o)); }
#define luaC_objbarrierback(L,p,o) \
{ if (iswhite(obj2gco(o)) && isblack(obj2gco(p))) luaC_barrierback_(L,p); }
{ if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) luaC_barrierback_(L,p); }
#define luaC_barrierproto(L,p,c) \
{ if (isblack(obj2gco(p))) luaC_barrierproto_(L,p,c); }