Added method cache.

To enable method cache, define `MRB_METHOD_CACHE` or
`MRB_METHOD_CACHE_SIZE`. The cache size must be power of 2.
The default cache size is 128.

The measurement:
I measured simple benchmarks found in benchmark/ directory. With
method cache enabled, we gained 6-8% performance improvement, with
97-99% cache hit rate.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-08-22 22:17:01 +09:00
parent a65f4dbb32
commit 4c9a604877
3 changed files with 87 additions and 1 deletions
+1
View File
@@ -63,6 +63,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
}\
}\
} while (0)
#define MRB_FLAG_IS_INHERITED (1 << 21)
#define MRB_INSTANCE_TT_MASK (0xFF)
#define MRB_SET_INSTANCE_TT(c, tt) c->flags = ((c->flags & ~MRB_INSTANCE_TT_MASK) | (char)tt)
#define MRB_INSTANCE_TT(c) (enum mrb_vtype)(c->flags & MRB_INSTANCE_TT_MASK)