Skip to content

Commit b931199

Browse files
committed
Avoid duping cc table when cme == NULL
1 parent 4fc9ad5 commit b931199

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

vm_insnhelper.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,17 +2143,6 @@ vm_populate_cc(VALUE klass, const struct rb_callinfo * const ci, ID mid)
21432143
{
21442144
ASSERT_vm_locking();
21452145

2146-
VALUE cc_tbl = RCLASS_WRITABLE_CC_TBL(klass);
2147-
const VALUE original_cc_table = cc_tbl;
2148-
struct rb_class_cc_entries *ccs = NULL;
2149-
2150-
if (!cc_tbl) {
2151-
cc_tbl = rb_vm_cc_table_create(1);
2152-
}
2153-
else if (rb_multi_ractor_p()) {
2154-
cc_tbl = rb_vm_cc_table_dup(cc_tbl);
2155-
}
2156-
21572146
RB_DEBUG_COUNTER_INC(cc_not_found_in_ccs);
21582147

21592148
const rb_callable_method_entry_t *cme = rb_callable_method_entry(klass, mid);
@@ -2166,12 +2155,23 @@ vm_populate_cc(VALUE klass, const struct rb_callinfo * const ci, ID mid)
21662155
return &vm_empty_cc;
21672156
}
21682157

2158+
VALUE cc_tbl = RCLASS_WRITABLE_CC_TBL(klass);
2159+
const VALUE original_cc_table = cc_tbl;
2160+
if (!cc_tbl) {
2161+
// Is this possible after rb_callable_method_entry ?
2162+
cc_tbl = rb_vm_cc_table_create(1);
2163+
}
2164+
else if (rb_multi_ractor_p()) {
2165+
cc_tbl = rb_vm_cc_table_dup(cc_tbl);
2166+
}
2167+
21692168
VM_ASSERT(cme == rb_callable_method_entry(klass, mid));
21702169

21712170
METHOD_ENTRY_CACHED_SET((struct rb_callable_method_entry_struct *)cme);
21722171

21732172
VM_ASSERT(cc_tbl);
21742173

2174+
struct rb_class_cc_entries *ccs = NULL;
21752175
{
21762176
VALUE ccs_obj;
21772177
if (UNLIKELY(rb_managed_id_table_lookup(cc_tbl, mid, &ccs_obj))) {

0 commit comments

Comments
 (0)