mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Reorganize mrb_cache_entry and mrb_method_t types
The purpose is to remove the `mid` field from the `mrb_cache_entry` structure.
The resulting RAM requirement for the method cache is reduced from 5 words per entry to 4 words per entry for 32-bit CPUs.
The relevant changes are as follows:
- Removed `MRB_USE_METHOD_T_STRUCT`.
The `mrb_method_t` type is now always defined as a structure.
- Include method IDs in `mrb_method_t`
Change the `flags` member to `uint32_t`.
The bitstring structure should be the same as the keys of the `mt` table in `class.c`.
I believe the impact on API compatibility with previous versions is minimal.
This commit is contained in:
+3
-6
@@ -230,22 +230,19 @@ mrb_static_assert_powerof2(MRB_METHOD_CACHE_SIZE);
|
||||
*/
|
||||
typedef mrb_value (*mrb_func_t)(struct mrb_state *mrb, mrb_value self);
|
||||
|
||||
#ifndef MRB_USE_METHOD_T_STRUCT
|
||||
typedef uintptr_t mrb_method_t;
|
||||
#else
|
||||
typedef struct {
|
||||
uint8_t flags;
|
||||
uint32_t flags; /* compatible with mt keys in class.c */
|
||||
|
||||
union {
|
||||
struct RProc *proc;
|
||||
mrb_func_t func;
|
||||
};
|
||||
} mrb_method_t;
|
||||
#endif
|
||||
|
||||
#ifndef MRB_NO_METHOD_CACHE
|
||||
struct mrb_cache_entry {
|
||||
struct RClass *c, *c0;
|
||||
mrb_sym mid;
|
||||
/* mrb_sym mid; // mid is stored in mrb_method_t::flags */
|
||||
mrb_method_t m;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user