From e8c779736f3029df353038352c14c8ab63728811 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 1 Nov 2018 13:21:00 -0300 Subject: Removed internal cache for closures The mechanism of "caching the last closure created for a prototype to try to reuse it the next time a closure for that prototype is created" was removed. There are several reasons: - It is hard to find a natural example where this cache has a measurable impact on performance. - Programmers already perceive closure creation as something slow, so they tend to avoid it inside hot paths. (Any case where the cache could reuse a closure can be rewritten predefining the closure in some variable and using that variable.) - The implementation was somewhat complex, due to a bad interaction with the generational collector. (Typically, new closures are new, while prototypes are old. So, the cache breaks the invariant that old objects should not point to new ones.) --- ltests.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 7cf08891..aba44b87 100644 --- a/ltests.c +++ b/ltests.c @@ -283,7 +283,6 @@ static void checkudata (global_State *g, Udata *u) { static void checkproto (global_State *g, Proto *f) { int i; GCObject *fgc = obj2gco(f); - checkobjref(g, fgc, f->cache); checkobjref(g, fgc, f->source); for (i=0; isizek; i++) { if (ttisstring(f->k + i)) @@ -417,8 +416,6 @@ static void checkobject (global_State *g, GCObject *o, int maybedead, getage(o) == G_TOUCHED1 || getage(o) == G_OLD0 || o->tt == LUA_TTHREAD || - (o->tt == LUA_TPROTO && - (gco2p(o)->cache != NULL || gco2p(o)->cachemiss >= MAXMISS)) || (o->tt == LUA_TUPVAL && upisopen(gco2upv(o)))); } } @@ -452,7 +449,6 @@ static void checkgrays (global_State *g) { checkgraylist(g, g->grayagain); checkgraylist(g, g->weak); checkgraylist(g, g->ephemeron); - checkgraylist(g, g->protogray); } -- cgit v1.2.3-55-g6feb