diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-04-30 17:43:26 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-04-30 17:43:26 -0300 |
| commit | 8634b2a0119e698e362fdb765f30258e79e1dfd0 (patch) | |
| tree | c20c79efbbf0bc8fa565c34932e283fc428c9219 /lvm.c | |
| parent | 5ecb31003f8086f057444468d0356771526ec7b4 (diff) | |
| download | lua-8634b2a0119e698e362fdb765f30258e79e1dfd0.tar.gz lua-8634b2a0119e698e362fdb765f30258e79e1dfd0.tar.bz2 lua-8634b2a0119e698e362fdb765f30258e79e1dfd0.zip | |
added 'cachemiss' field to prototype to avoid wasting time checking
hits that fail too often
Diffstat (limited to '')
| -rw-r--r-- | lvm.c | 12 |
1 files changed, 9 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.273 2017/04/26 17:46:52 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.274 2017/04/28 20:57:45 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 | */ |
| @@ -618,6 +618,7 @@ static LClosure *getcached (Proto *p, UpVal **encup, StkId base) { | |||
| 618 | if (c->upvals[i]->v != v) | 618 | if (c->upvals[i]->v != v) |
| 619 | return NULL; /* wrong upvalue; cannot reuse closure */ | 619 | return NULL; /* wrong upvalue; cannot reuse closure */ |
| 620 | } | 620 | } |
| 621 | p->cachemiss = 0; /* got a hit */ | ||
| 621 | } | 622 | } |
| 622 | return c; /* return cached closure (or NULL if no cached closure) */ | 623 | return c; /* return cached closure (or NULL if no cached closure) */ |
| 623 | } | 624 | } |
| @@ -644,8 +645,13 @@ static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base, | |||
| 644 | ncl->upvals[i] = encup[uv[i].idx]; | 645 | ncl->upvals[i] = encup[uv[i].idx]; |
| 645 | /* new closure is white, so we do not need a barrier here */ | 646 | /* new closure is white, so we do not need a barrier here */ |
| 646 | } | 647 | } |
| 647 | if (!isblack(p)) /* cache will not break GC invariant? */ | 648 | if (p->cachemiss >= 10) /* too many missings? */ |
| 648 | p->cache = ncl; /* save it on cache for reuse */ | 649 | p->cache = NULL; /* give up cache */ |
| 650 | else { | ||
| 651 | if (!isblack(p)) /* cache will not break GC invariant? */ | ||
| 652 | p->cache = ncl; /* save it on cache for reuse */ | ||
| 653 | p->cachemiss++; | ||
| 654 | } | ||
| 649 | } | 655 | } |
| 650 | 656 | ||
| 651 | 657 | ||
