diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-01 13:21:00 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-11-01 13:21:00 -0300 |
commit | e8c779736f3029df353038352c14c8ab63728811 (patch) | |
tree | 23f75fa455ec333677650198cd889b187228b735 /lobject.h | |
parent | 2fc6b55dae7a120b4272ca0e9c356d1f96053bd9 (diff) | |
download | lua-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 'lobject.h')
-rw-r--r-- | lobject.h | 2 |
1 files changed, 0 insertions, 2 deletions
@@ -505,7 +505,6 @@ typedef struct Proto { | |||
505 | lu_byte numparams; /* number of fixed (named) parameters */ | 505 | lu_byte numparams; /* number of fixed (named) parameters */ |
506 | lu_byte is_vararg; | 506 | lu_byte is_vararg; |
507 | lu_byte maxstacksize; /* number of registers needed by this function */ | 507 | lu_byte maxstacksize; /* number of registers needed by this function */ |
508 | lu_byte cachemiss; /* count for successive misses for 'cache' field */ | ||
509 | int sizeupvalues; /* size of 'upvalues' */ | 508 | int sizeupvalues; /* size of 'upvalues' */ |
510 | int sizek; /* size of 'k' */ | 509 | int sizek; /* size of 'k' */ |
511 | int sizecode; | 510 | int sizecode; |
@@ -516,7 +515,6 @@ typedef struct Proto { | |||
516 | int linedefined; /* debug information */ | 515 | int linedefined; /* debug information */ |
517 | int lastlinedefined; /* debug information */ | 516 | int lastlinedefined; /* debug information */ |
518 | TValue *k; /* constants used by the function */ | 517 | TValue *k; /* constants used by the function */ |
519 | struct LClosure *cache; /* last-created closure with this prototype */ | ||
520 | Instruction *code; /* opcodes */ | 518 | Instruction *code; /* opcodes */ |
521 | struct Proto **p; /* functions defined inside the function */ | 519 | struct Proto **p; /* functions defined inside the function */ |
522 | Upvaldesc *upvalues; /* upvalue information */ | 520 | Upvaldesc *upvalues; /* upvalue information */ |