diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-04 10:32:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-05-04 10:32:01 -0300 |
commit | 2376eb634751f92e6bcb9dc8dbc1ef88b9873319 (patch) | |
tree | 579780bc7ff3d1374a701298749eca3634a17edb /lvm.c | |
parent | 8634b2a0119e698e362fdb765f30258e79e1dfd0 (diff) | |
download | lua-2376eb634751f92e6bcb9dc8dbc1ef88b9873319.tar.gz lua-2376eb634751f92e6bcb9dc8dbc1ef88b9873319.tar.bz2 lua-2376eb634751f92e6bcb9dc8dbc1ef88b9873319.zip |
barrier for prototype's cache (with new gray list 'protogray' to keep
prototypes to have their caches visited again) + constant 'MAXMISS'
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.274 2017/04/28 20:57:45 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.275 2017/04/30 20:43:26 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -626,9 +626,7 @@ static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { | |||
626 | 626 | ||
627 | /* | 627 | /* |
628 | ** create a new Lua closure, push it in the stack, and initialize | 628 | ** create a new Lua closure, push it in the stack, and initialize |
629 | ** its upvalues. Note that the closure is not cached if prototype is | 629 | ** its upvalues. ??? |
630 | ** already black (which means that 'cache' was already cleared by the | ||
631 | ** GC). | ||
632 | */ | 630 | */ |
633 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | 631 | static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, |
634 | StkId ra) { | 632 | StkId ra) { |
@@ -645,11 +643,11 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | |||
645 | ncl->upvals[i] = encup[uv[i].idx]; | 643 | ncl->upvals[i] = encup[uv[i].idx]; |
646 | /* new closure is white, so we do not need a barrier here */ | 644 | /* new closure is white, so we do not need a barrier here */ |
647 | } | 645 | } |
648 | if (p->cachemiss >= 10) /* too many missings? */ | 646 | if (p->cachemiss >= MAXMISS) /* too many missings? */ |
649 | p->cache = NULL; /* give up cache */ | 647 | p->cache = NULL; /* give up cache */ |
650 | else { | 648 | else { |
651 | if (!isblack(p)) /* cache will not break GC invariant? */ | 649 | p->cache = ncl; /* save it on cache for reuse */ |
652 | p->cache = ncl; /* save it on cache for reuse */ | 650 | luaC_protobarrier(L, p, ncl); |
653 | p->cachemiss++; | 651 | p->cachemiss++; |
654 | } | 652 | } |
655 | } | 653 | } |