summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-03-09 21:21:21 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2022-03-24 09:14:38 -0700
commit8f6eaca2e19828e92ecdb28b0fe693d606a03f96 (patch)
treed52498f01ac22de09e7d9220d882a3da5c9a49db /iseq.c
parent629908586b4bead1103267652f8b96b1083573a8 (diff)
Delete ID from constant cache table if it becomes empty on ISEQ free
Co-authored-by: John Hawthorn <john@hawthorn.email>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5433
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index 800ea1f883..5d294e9d31 100644
--- a/iseq.c
+++ b/iseq.c
@@ -129,6 +129,11 @@ iseq_clear_ic_references_i(VALUE *code, VALUE insn, size_t index, void *data)
if (rb_id_table_lookup(vm->constant_cache, id, (VALUE *) &ics)) {
st_delete(ics, (st_data_t *) &ic_data->ic, (st_data_t *) NULL);
+
+ if (ics->num_entries == 0) {
+ rb_id_table_delete(vm->constant_cache, id);
+ st_free_table(ics);
+ }
}
return true;