mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
variable.c: add object shapes for MRB_TT_OBJECT IV storage
Introduce "object shapes" (hidden classes) that share IV key layouts across objects with the same instance variable assignment order. This eliminates per-object key storage overhead. Memory savings: ~22% heap reduction for object-heavy workloads (e.g., 150k objects with 2-6 IVs). Per-object: 40->24 bytes for 2 IVs. Objects exceeding 16 IVs or using remove_instance_variable fall back to traditional iv_tbl. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -325,6 +325,8 @@ typedef struct mrb_state {
|
||||
|
||||
struct mrb_mt_rom_list *rom_mt; /* heap-allocated ROM wrappers (freed at close) */
|
||||
|
||||
struct mrb_iv_shape *root_shape; /* root of IV shape tree */
|
||||
|
||||
void *ud; /* auxiliary data */
|
||||
|
||||
#ifdef MRB_FIXED_STATE_ATEXIT_STACK
|
||||
|
||||
Reference in New Issue
Block a user