barrier for prototype's cache (with new gray list 'protogray' to keep

prototypes to have their caches visited again) + constant 'MAXMISS'
This commit is contained in:
Roberto Ierusalimschy
2017-05-04 10:32:01 -03:00
parent 8634b2a011
commit 2376eb6347
7 changed files with 95 additions and 22 deletions

12
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.274 2017/04/28 20:57:45 roberto Exp roberto $
** $Id: lvm.c,v 2.275 2017/04/30 20:43:26 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -626,9 +626,7 @@ static LClosure *getcached (Proto *p, UpVal **encup, StkId base) {
/*
** create a new Lua closure, push it in the stack, and initialize
** its upvalues. Note that the closure is not cached if prototype is
** already black (which means that 'cache' was already cleared by the
** GC).
** its upvalues. ???
*/
static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
StkId ra) {
@@ -645,11 +643,11 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
ncl->upvals[i] = encup[uv[i].idx];
/* new closure is white, so we do not need a barrier here */
}
if (p->cachemiss >= 10) /* too many missings? */
if (p->cachemiss >= MAXMISS) /* too many missings? */
p->cache = NULL; /* give up cache */
else {
if (!isblack(p)) /* cache will not break GC invariant? */
p->cache = ncl; /* save it on cache for reuse */
p->cache = ncl; /* save it on cache for reuse */
luaC_protobarrier(L, p, ncl);
p->cachemiss++;
}
}