[前][次][番号順一覧][スレッド一覧]

ruby-changes:41910

From: nobu <ko1@a...>
Date: Wed, 2 Mar 2016 16:28:55 +0900 (JST)
Subject: [ruby-changes:41910] nobu:r53984 (trunk): vm_eval.c: call method_missing by method entry

nobu	2016-03-02 16:28:50 +0900 (Wed, 02 Mar 2016)

  New Revision: 53984

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53984

  Log:
    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.

  Modified files:
    trunk/ChangeLog
    trunk/vm_eval.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53983)
+++ ChangeLog	(revision 53984)
@@ -1,4 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Wed Mar  2 16:18:30 2016  Nobuyoshi Nakada  <nobu@r...>
+Wed Mar  2 16:28:48 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* vm_eval.c (method_missing): call by found method entry and get
+	  rid of searching the same method entry twice.
 
 	* vm_eval.c (vm_call0_body): calling method_missing method is
 	  method_missing().
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 53983)
+++ vm_eval.c	(revision 53984)
@@ -747,26 +747,31 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L747
 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;
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]