summaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-01 13:21:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-11-01 13:21:00 -0300
commite8c779736f3029df353038352c14c8ab63728811 (patch)
tree23f75fa455ec333677650198cd889b187228b735 /ltests.c
parent2fc6b55dae7a120b4272ca0e9c356d1f96053bd9 (diff)
downloadlua-e8c779736f3029df353038352c14c8ab63728811.tar.gz
lua-e8c779736f3029df353038352c14c8ab63728811.tar.bz2
lua-e8c779736f3029df353038352c14c8ab63728811.zip
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.)
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c4
1 files changed, 0 insertions, 4 deletions
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) {
283static void checkproto (global_State *g, Proto *f) { 283static void checkproto (global_State *g, Proto *f) {
284 int i; 284 int i;
285 GCObject *fgc = obj2gco(f); 285 GCObject *fgc = obj2gco(f);
286 checkobjref(g, fgc, f->cache);
287 checkobjref(g, fgc, f->source); 286 checkobjref(g, fgc, f->source);
288 for (i=0; i<f->sizek; i++) { 287 for (i=0; i<f->sizek; i++) {
289 if (ttisstring(f->k + i)) 288 if (ttisstring(f->k + i))
@@ -417,8 +416,6 @@ static void checkobject (global_State *g, GCObject *o, int maybedead,
417 getage(o) == G_TOUCHED1 || 416 getage(o) == G_TOUCHED1 ||
418 getage(o) == G_OLD0 || 417 getage(o) == G_OLD0 ||
419 o->tt == LUA_TTHREAD || 418 o->tt == LUA_TTHREAD ||
420 (o->tt == LUA_TPROTO &&
421 (gco2p(o)->cache != NULL || gco2p(o)->cachemiss >= MAXMISS)) ||
422 (o->tt == LUA_TUPVAL && upisopen(gco2upv(o)))); 419 (o->tt == LUA_TUPVAL && upisopen(gco2upv(o))));
423 } 420 }
424 } 421 }
@@ -452,7 +449,6 @@ static void checkgrays (global_State *g) {
452 checkgraylist(g, g->grayagain); 449 checkgraylist(g, g->grayagain);
453 checkgraylist(g, g->weak); 450 checkgraylist(g, g->weak);
454 checkgraylist(g, g->ephemeron); 451 checkgraylist(g, g->ephemeron);
455 checkgraylist(g, g->protogray);
456} 452}
457 453
458 454