aboutsummaryrefslogtreecommitdiffstats
path: root/vm_eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-02 07:28:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-02 07:28:50 +0000
commitbc1c3ff229de5eb45d28f9f050f648a6050117a3 (patch)
treeab3ec937d674ff708934cc24a89effb6a80578da /vm_eval.c
parent0e4e49aa07b34a39a093714d38da8e47e2f9a4b9 (diff)
downloadruby-bc1c3ff229de5eb45d28f9f050f648a6050117a3.tar.gz
vm_eval.c: call method_missing by method entry
* vm_eval.c (method_missing): call by found method entry and get rid of searching the same method entry twice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 5e099d464b..c2fca2c844 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -747,26 +747,31 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
static inline VALUE
method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum method_missing_reason call_status)
{
- VALUE *nargv, result, work;
+ VALUE *nargv, result, work, klass;
rb_thread_t *th = GET_THREAD();
const rb_block_t *blockptr = th->passed_block;
+ const rb_callable_method_entry_t *me;
th->method_missing_reason = call_status;
th->passed_block = 0;
if (id == idMethodMissing) {
+ missing:
raise_method_missing(th, argc, argv, obj, call_status | MISSING_MISSING);
}
nargv = ALLOCV_N(VALUE, work, argc + 1);
nargv[0] = ID2SYM(id);
MEMCPY(nargv + 1, argv, VALUE, argc);
+ ++argc;
+ argv = nargv;
- if (rb_method_basic_definition_p(CLASS_OF(obj) , idMethodMissing)) {
- raise_method_missing(th, argc+1, nargv, obj, call_status | MISSING_MISSING);
- }
+ klass = CLASS_OF(obj);
+ if (!klass) goto missing;
+ me = rb_callable_method_entry(klass, idMethodMissing);
+ if (!me || METHOD_ENTRY_BASIC(me)) goto missing;
th->passed_block = blockptr;
- result = rb_funcall2(obj, idMethodMissing, argc + 1, nargv);
+ result = vm_call0(th, obj, idMethodMissing, argc, argv, me);
if (work) ALLOCV_END(work);
return result;
}