use existing vm_search_method()
Ko1 plans to implement Guild. That can interface the caching mechanism introduced here. To prevent future breakage we would better avoid rolling our own code here. Instead use the existing vm_search_method() which would be modified by him. This commit deletes some asserions, but they are in fact checked inside of vm_search_method().
This commit is contained in:
parent
7a1f650c13
commit
b005d7c2e2
26
vm_eval.c
26
vm_eval.c
@ -879,15 +879,8 @@ VALUE
|
|||||||
rb_funcallv_with_cc(void **ptr, VALUE recv, ID mid, int argc, const VALUE *argv)
|
rb_funcallv_with_cc(void **ptr, VALUE recv, ID mid, int argc, const VALUE *argv)
|
||||||
{
|
{
|
||||||
VM_ASSERT(ptr);
|
VM_ASSERT(ptr);
|
||||||
const VALUE klass = CLASS_OF(recv);
|
|
||||||
VM_ASSERT(klass != Qfalse);
|
|
||||||
VM_ASSERT(RBASIC_CLASS(klass) == 0 || rb_obj_is_kind_of(klass, rb_cClass));
|
|
||||||
rb_serial_t now = GET_GLOBAL_METHOD_STATE();
|
|
||||||
rb_serial_t serial = RCLASS_SERIAL(klass);
|
|
||||||
struct opaque {
|
struct opaque {
|
||||||
const rb_callable_method_entry_t *me;
|
struct rb_call_cache cc;
|
||||||
rb_serial_t updated_at;
|
|
||||||
rb_serial_t class_at;
|
|
||||||
ID mid;
|
ID mid;
|
||||||
} *cc;
|
} *cc;
|
||||||
if (UNLIKELY(! *ptr)) {
|
if (UNLIKELY(! *ptr)) {
|
||||||
@ -895,20 +888,21 @@ rb_funcallv_with_cc(void **ptr, VALUE recv, ID mid, int argc, const VALUE *argv)
|
|||||||
}
|
}
|
||||||
cc = *ptr;
|
cc = *ptr;
|
||||||
|
|
||||||
if (cc->updated_at != now ||
|
const struct rb_call_info ci = { mid, VM_CALL_ARGS_SIMPLE, argc, };
|
||||||
cc->class_at != serial ||
|
if (UNLIKELY(cc->mid != mid)) {
|
||||||
cc->mid != mid) {
|
*cc = (struct opaque) /* reset */ { { 0, }, mid, };
|
||||||
*cc = (struct opaque) {
|
return rb_funcallv(recv, mid, argc, argv);
|
||||||
rb_callable_method_entry(klass, mid), now, serial, mid,
|
}
|
||||||
};
|
else {
|
||||||
|
vm_search_method(&ci, &cc->cc, recv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UNLIKELY(UNDEFINED_METHOD_ENTRY_P(cc->me))) {
|
if (UNLIKELY(UNDEFINED_METHOD_ENTRY_P(cc->cc.me))) {
|
||||||
/* :FIXME: this path can be made faster */
|
/* :FIXME: this path can be made faster */
|
||||||
return rb_funcallv(recv, mid, argc, argv);
|
return rb_funcallv(recv, mid, argc, argv);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return rb_vm_call0(GET_EC(), recv, mid, argc, argv, cc->me);
|
return rb_vm_call0(GET_EC(), recv, mid, argc, argv, cc->cc.me);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user