Pass a callinfo object to global call cache search

Global call cache can be used with only a CI
This commit is contained in:
Aaron Patterson 2024-04-24 10:20:07 -07:00 коммит произвёл Aaron Patterson
Родитель 2cc59c1b31
Коммит 73a7e51535
2 изменённых файлов: 37 добавлений и 26 удалений

Просмотреть файл

@ -415,8 +415,32 @@ gccct_method_search_slowpath(rb_vm_t *vm, VALUE klass, unsigned int index, const
return vm->global_cc_cache_table[index] = cd.cc;
}
static void
scope_to_ci(call_type scope, ID mid, int argc, struct rb_callinfo *ci)
{
int flags = 0;
switch(scope) {
case CALL_PUBLIC:
break;
case CALL_FCALL:
flags |= VM_CALL_FCALL;
break;
case CALL_VCALL:
flags |= VM_CALL_VCALL;
break;
case CALL_PUBLIC_KW:
flags |= VM_CALL_KWARG;
break;
case CALL_FCALL_KW:
flags |= (VM_CALL_KWARG | VM_CALL_FCALL);
break;
}
*ci = VM_CI_ON_STACK(mid, flags, argc, NULL);
}
static inline const struct rb_callcache *
gccct_method_search(rb_execution_context_t *ec, VALUE recv, ID mid, int argc, call_type call_scope)
gccct_method_search(rb_execution_context_t *ec, VALUE recv, ID mid, const struct rb_callinfo *ci)
{
VALUE klass;
@ -451,27 +475,7 @@ gccct_method_search(rb_execution_context_t *ec, VALUE recv, ID mid, int argc, ca
}
RB_DEBUG_COUNTER_INC(gccct_miss);
int flags = 0;
switch(call_scope) {
case CALL_PUBLIC:
break;
case CALL_FCALL:
flags |= VM_CALL_FCALL;
break;
case CALL_VCALL:
flags |= VM_CALL_VCALL;
break;
case CALL_PUBLIC_KW:
flags |= VM_CALL_KWARG;
break;
case CALL_FCALL_KW:
flags |= (VM_CALL_KWARG | VM_CALL_FCALL);
break;
}
return gccct_method_search_slowpath(vm, klass, index, &VM_CI_ON_STACK(mid, flags, argc, NULL));
return gccct_method_search_slowpath(vm, klass, index, ci);
}
/**
@ -512,7 +516,10 @@ rb_call0(rb_execution_context_t *ec,
break;
}
const struct rb_callcache *cc = gccct_method_search(ec, recv, mid, argc, scope);
struct rb_callinfo ci;
scope_to_ci(scope, mid, argc, &ci);
const struct rb_callcache *cc = gccct_method_search(ec, recv, mid, &ci);
if (scope == CALL_PUBLIC) {
RB_DEBUG_COUNTER_INC(call0_public);
@ -1029,7 +1036,11 @@ static inline VALUE
rb_funcallv_scope(VALUE recv, ID mid, int argc, const VALUE *argv, call_type scope)
{
rb_execution_context_t *ec = GET_EC();
const struct rb_callcache *cc = gccct_method_search(ec, recv, mid, argc, scope);
struct rb_callinfo ci;
scope_to_ci(scope, mid, argc, &ci);
const struct rb_callcache *cc = gccct_method_search(ec, recv, mid, &ci);
VALUE self = ec->cfp->self;
if (LIKELY(cc) &&

Просмотреть файл

@ -2421,13 +2421,13 @@ opt_equality(const rb_iseq_t *cd_owner, VALUE recv, VALUE obj, CALL_DATA cd)
#undef EQ_UNREDEFINED_P
static inline const struct rb_callcache *gccct_method_search(rb_execution_context_t *ec, VALUE recv, ID mid, int argc, call_type scope); // vm_eval.c
static inline const struct rb_callcache *gccct_method_search(rb_execution_context_t *ec, VALUE recv, ID mid, const struct rb_callinfo *ci); // vm_eval.c
NOINLINE(static VALUE opt_equality_by_mid_slowpath(VALUE recv, VALUE obj, ID mid));
static VALUE
opt_equality_by_mid_slowpath(VALUE recv, VALUE obj, ID mid)
{
const struct rb_callcache *cc = gccct_method_search(GET_EC(), recv, mid, 1, CALL_PUBLIC);
const struct rb_callcache *cc = gccct_method_search(GET_EC(), recv, mid, &VM_CI_ON_STACK(mid, 0, 1, NULL));
if (cc && check_cfunc(vm_cc_cme(cc), rb_obj_equal)) {
return RBOOL(recv == obj);