diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-06-27 17:38:24 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:22 +0900 |
| commit | 639946a006c29f648551512af8aa0bb0cd969412 (patch) | |
| tree | 772fd60110e0492a42df513106d9e150b932645c /include | |
| parent | fb5e8ab6d5fa9b7ca08c7b66ac8038940534db70 (diff) | |
| download | mruby-639946a006c29f648551512af8aa0bb0cd969412.tar.gz mruby-639946a006c29f648551512af8aa0bb0cd969412.zip | |
Enable method cache by default.
Introduced `MRB_NO_METHOD_CACHE` which is inverse of `MRB_METHOD_CACHE`
that should be enabled intestinally. In addition, the default cache is
made bigger (128 -> 256).
Diffstat (limited to 'include')
| -rw-r--r-- | include/mrbconf.h | 18 | ||||
| -rw-r--r-- | include/mruby.h | 10 | ||||
| -rw-r--r-- | include/mruby/class.h | 2 |
3 files changed, 13 insertions, 17 deletions
diff --git a/include/mrbconf.h b/include/mrbconf.h index 2b1adb24e..81ab36977 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -31,10 +31,10 @@ /* exclude floating point numbers */ //#define MRB_WITHOUT_FLOAT -/* add -DMRB_METHOD_CACHE to use method cache to improve performance */ -//#define MRB_METHOD_CACHE +/* add -DMRB_NO_METHOD_CACHE to disable method cache to save memory */ +//#define MRB_NO_METHOD_CACHE /* size of the method cache (need to be the power of 2) */ -//#define MRB_METHOD_CACHE_SIZE (1<<7) +//#define MRB_METHOD_CACHE_SIZE (1<<8) /* add -DMRB_METHOD_T_STRUCT on machines that use higher bits of pointers */ /* no MRB_METHOD_T_STRUCT requires highest 2 bits of function pointers to be zero */ @@ -160,6 +160,10 @@ /* A profile for micro controllers */ #if defined(MRB_CONSTRAINED_BASELINE_PROFILE) +# ifndef MRB_NO_METHOD_CACHE +# define MRB_NO_METHOD_CACHE +# endif + # ifndef KHASH_DEFAULT_SIZE # define KHASH_DEFAULT_SIZE 16 # endif @@ -177,10 +181,6 @@ /* A profile for desktop computers or workstations; rich memory! */ #elif defined(MRB_MAIN_PROFILE) -# ifndef MRB_METHOD_CACHE -# define MRB_METHOD_CACHE -# endif - # ifndef MRB_METHOD_CACHE_SIZE # define MRB_METHOD_CACHE_SIZE (1<<10) # endif @@ -195,10 +195,6 @@ /* A profile for server; mruby vm is long life */ #elif defined(MRB_HIGH_PROFILE) -# ifndef MRB_METHOD_CACHE -# define MRB_METHOD_CACHE -# endif - # ifndef MRB_METHOD_CACHE_SIZE # define MRB_METHOD_CACHE_SIZE (1<<12) # endif diff --git a/include/mruby.h b/include/mruby.h index 27c428e85..c9425e8a7 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -188,11 +188,11 @@ struct mrb_context { }; #ifdef MRB_METHOD_CACHE_SIZE -# define MRB_METHOD_CACHE +# undef MRB_NO_METHOD_CACHE #else -/* default method cache size: 128 */ +/* default method cache size: 256 */ /* cache size needs to be power of 2 */ -# define MRB_METHOD_CACHE_SIZE (1<<7) +# define MRB_METHOD_CACHE_SIZE (1<<8) #endif /** @@ -218,7 +218,7 @@ typedef struct { } mrb_method_t; #endif -#ifdef MRB_METHOD_CACHE +#ifndef MRB_NO_METHOD_CACHE struct mrb_cache_entry { struct RClass *c, *c0; mrb_sym mid; @@ -264,7 +264,7 @@ typedef struct mrb_state { mrb_gc gc; -#ifdef MRB_METHOD_CACHE +#ifndef MRB_NO_METHOD_CACHE struct mrb_cache_entry cache[MRB_METHOD_CACHE_SIZE]; #endif diff --git a/include/mruby/class.h b/include/mruby/class.h index 94356d3b2..88e5915e5 100644 --- a/include/mruby/class.h +++ b/include/mruby/class.h @@ -92,7 +92,7 @@ void mrb_gc_mark_mt(mrb_state*, struct RClass*); size_t mrb_gc_mark_mt_size(mrb_state*, struct RClass*); void mrb_gc_free_mt(mrb_state*, struct RClass*); -#ifdef MRB_METHOD_CACHE +#ifndef MRB_NO_METHOD_CACHE void mrb_mc_clear_by_class(mrb_state *mrb, struct RClass* c); #else #define mrb_mc_clear_by_class(mrb,c) |
