Skip to content

Commit 2ee5a89

Browse files
authored
Make vm_search_method return a cme instead of a cc (ruby#14299)
Make vm_search_method return a cme instead of a cc Both of its callers ended up calling `vm_cc_cme` on the result and only used the cme, so it's probably better to return a cme directly. This will also make it easier for ZJIT to later inline the `rb_vm_objtostring` call.
1 parent 8ad290b commit 2ee5a89

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

vm_insnhelper.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,14 +2324,15 @@ vm_search_method_fastpath(VALUE cd_owner, struct rb_call_data *cd, VALUE klass)
23242324
return vm_search_method_slowpath0(cd_owner, cd, klass);
23252325
}
23262326

2327-
static const struct rb_callcache *
2327+
static const struct rb_callable_method_entry_struct *
23282328
vm_search_method(VALUE cd_owner, struct rb_call_data *cd, VALUE recv)
23292329
{
23302330
VALUE klass = CLASS_OF(recv);
23312331
VM_ASSERT(klass != Qfalse);
23322332
VM_ASSERT(RBASIC_CLASS(klass) == 0 || rb_obj_is_kind_of(klass, rb_cClass));
23332333

2334-
return vm_search_method_fastpath(cd_owner, cd, klass);
2334+
const struct rb_callcache *cc = vm_search_method_fastpath(cd_owner, cd, klass);
2335+
return vm_cc_cme(cc);
23352336
}
23362337

23372338
#if __has_attribute(transparent_union)
@@ -2394,8 +2395,8 @@ static inline int
23942395
vm_method_cfunc_is(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv, cfunc_type func)
23952396
{
23962397
VM_ASSERT(iseq != NULL);
2397-
const struct rb_callcache *cc = vm_search_method((VALUE)iseq, cd, recv);
2398-
return check_cfunc(vm_cc_cme(cc), func);
2398+
const struct rb_callable_method_entry_struct *cme = vm_search_method((VALUE)iseq, cd, recv);
2399+
return check_cfunc(cme, func);
23992400
}
24002401

24012402
#define check_cfunc(me, func) check_cfunc(me, make_cfunc_type(func))
@@ -6161,11 +6162,11 @@ vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
61616162
return recv;
61626163
}
61636164

6164-
const struct rb_callcache *cc = vm_search_method((VALUE)iseq, cd, recv);
6165+
const struct rb_callable_method_entry_struct *cme = vm_search_method((VALUE)iseq, cd, recv);
61656166

61666167
switch (type) {
61676168
case T_SYMBOL:
6168-
if (check_method_basic_definition(vm_cc_cme(cc))) {
6169+
if (check_method_basic_definition(cme)) {
61696170
// rb_sym_to_s() allocates a mutable string, but since we are only
61706171
// going to use this string for interpolation, it's fine to use the
61716172
// frozen string.
@@ -6174,7 +6175,7 @@ vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
61746175
break;
61756176
case T_MODULE:
61766177
case T_CLASS:
6177-
if (check_cfunc(vm_cc_cme(cc), rb_mod_to_s)) {
6178+
if (check_cfunc(cme, rb_mod_to_s)) {
61786179
// rb_mod_to_s() allocates a mutable string, but since we are only
61796180
// going to use this string for interpolation, it's fine to use the
61806181
// frozen string.
@@ -6186,22 +6187,22 @@ vm_objtostring(const rb_iseq_t *iseq, VALUE recv, CALL_DATA cd)
61866187
}
61876188
break;
61886189
case T_NIL:
6189-
if (check_cfunc(vm_cc_cme(cc), rb_nil_to_s)) {
6190+
if (check_cfunc(cme, rb_nil_to_s)) {
61906191
return rb_nil_to_s(recv);
61916192
}
61926193
break;
61936194
case T_TRUE:
6194-
if (check_cfunc(vm_cc_cme(cc), rb_true_to_s)) {
6195+
if (check_cfunc(cme, rb_true_to_s)) {
61956196
return rb_true_to_s(recv);
61966197
}
61976198
break;
61986199
case T_FALSE:
6199-
if (check_cfunc(vm_cc_cme(cc), rb_false_to_s)) {
6200+
if (check_cfunc(cme, rb_false_to_s)) {
62006201
return rb_false_to_s(recv);
62016202
}
62026203
break;
62036204
case T_FIXNUM:
6204-
if (check_cfunc(vm_cc_cme(cc), rb_int_to_s)) {
6205+
if (check_cfunc(cme, rb_int_to_s)) {
62056206
return rb_fix_to_s(recv);
62066207
}
62076208
break;

0 commit comments

Comments
 (0)