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

ruby-changes:39119

From: ko1 <ko1@a...>
Date: Thu, 9 Jul 2015 11:11:18 +0900 (JST)
Subject: [ruby-changes:39119] ko1:r51200 (trunk): * vm_core.h: remove rb_call_info_t::klass because

ko1	2015-07-09 11:10:51 +0900 (Thu, 09 Jul 2015)

  New Revision: 51200

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

  Log:
    * vm_core.h: remove rb_call_info_t::klass because
      rb_callable_method_entry_t has information about defined class.
    * vm_insnhelper.c (vm_search_method): don't set ci->klass because
      it is removed.
    * vm_insnhelper.c (rb_equal_opt): ditto.
    * vm_insnhelper.c (vm_search_superclass): removed because it is too
      simple to write code directly.
    * vm_insnhelper.c (vm_defined): don't use vm_search_superclass().
      This fix avoid searching current callable `me' twice.
    * vm_insnhelper.c (vm_search_super_method): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/vm_core.h
    trunk/vm_insnhelper.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51199)
+++ ChangeLog	(revision 51200)
@@ -1,3 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jul  9 11:07:06 2015  Koichi Sasada  <ko1@a...>
+
+	* vm_core.h: remove rb_call_info_t::klass because
+	  rb_callable_method_entry_t has information about defined class.
+
+	* vm_insnhelper.c (vm_search_method): don't set ci->klass because
+	  it is removed.
+
+	* vm_insnhelper.c (rb_equal_opt): ditto.
+
+	* vm_insnhelper.c (vm_search_superclass): removed because it is too
+	  simple to write code directly.
+
+	* vm_insnhelper.c (vm_defined): don't use vm_search_superclass().
+	  This fix avoid searching current callable `me' twice.
+
+	* vm_insnhelper.c (vm_search_super_method): ditto.
+
 Thu Jul  9 10:03:10 2015  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/net/http/responses.rb: Added 308 status to CODE_TO_OBJ list.
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 51199)
+++ vm_core.h	(revision 51200)
@@ -180,7 +180,6 @@ typedef struct rb_call_info_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L180
     /* inline cache: keys */
     rb_serial_t method_state;
     rb_serial_t class_serial;
-    VALUE klass;
 
     /* inline cache: values */
     const rb_callable_method_entry_t *me;
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 51199)
+++ vm_insnhelper.c	(revision 51200)
@@ -1055,7 +1055,6 @@ vm_search_method(rb_call_info_t *ci, VAL https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1055
 
     ci->me = rb_callable_method_entry(klass, ci->mid);
     VM_ASSERT(callable_method_entry_p(ci->me));
-    ci->klass = klass;
     ci->call = vm_call_general;
 #if OPT_INLINE_METHOD_CACHE
     ci->method_state = GET_GLOBAL_METHOD_STATE();
@@ -1125,7 +1124,6 @@ rb_equal_opt(VALUE obj1, VALUE obj2) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1124
 {
     rb_call_info_t ci;
     ci.mid = idEq;
-    ci.klass = 0;
     ci.method_state = 0;
     ci.me = NULL;
     ci.class_serial = 0;
@@ -2170,29 +2168,10 @@ vm_super_outside(void) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2168
     rb_raise(rb_eNoMethodError, "super called outside of method");
 }
 
-static int
-vm_search_superclass(rb_control_frame_t *reg_cfp, rb_iseq_t *iseq, VALUE sigval, rb_call_info_t *ci)
-{
-    const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(reg_cfp);
-
-    if (me == NULL) {
-	return -1;
-    }
-    else if (me->def->type == VM_METHOD_TYPE_BMETHOD && !sigval) {
-	return -2;
-    }
-    else {
-	ci->mid = me->def->original_id;
-	ci->klass = vm_search_normal_superclass(me->defined_class);
-	return 0;
-    }
-}
-
 static void
 vm_search_super_method(rb_thread_t *th, rb_control_frame_t *reg_cfp, rb_call_info_t *ci)
 {
-    VALUE current_defined_class;
-    rb_iseq_t *iseq = GET_ISEQ();
+    VALUE current_defined_class, klass;
     VALUE sigval = TOPN(ci->argc);
     const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(reg_cfp);
 
@@ -2219,25 +2198,26 @@ vm_search_super_method(rb_thread_t *th, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2198
 		 rb_obj_class(ci->recv), m);
     }
 
-    switch (vm_search_superclass(GET_CFP(), iseq, sigval, ci)) {
-      case -1:
-	vm_super_outside();
-      case -2:
+    if (me->def->type == VM_METHOD_TYPE_BMETHOD && !sigval) {
 	rb_raise(rb_eRuntimeError,
 		 "implicit argument passing of super from method defined"
 		 " by define_method() is not supported."
 		 " Specify all arguments explicitly.");
     }
-    if (!ci->klass) {
+
+    ci->mid = me->def->original_id;
+    klass = vm_search_normal_superclass(me->defined_class);
+
+    if (!klass) {
 	/* bound instance method of module */
 	ci->aux.method_missing_reason = MISSING_SUPER;
 	CI_SET_FASTPATH(ci, vm_call_method_missing, 1);
-	return;
     }
-
-    /* TODO: use inline cache */
-    ci->me = rb_callable_method_entry(ci->klass, ci->mid);
-    ci->call = vm_call_super_method;
+    else {
+	/* TODO: use inline cache */
+	ci->me = rb_callable_method_entry(klass, ci->mid);
+	ci->call = vm_call_super_method;
+    }
 }
 
 /* yield */
@@ -2500,17 +2480,20 @@ vm_defined(rb_thread_t *th, rb_control_f https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2480
 	    expr_type = DEFINED_YIELD;
 	}
 	break;
-      case DEFINED_ZSUPER:{
-	rb_call_info_t cit;
-	if (vm_search_superclass(GET_CFP(), GET_ISEQ(), Qnil, &cit) == 0) {
-	    VALUE klass = cit.klass;
-	    ID id = cit.mid;
-	    if (rb_method_boundp(klass, id, 0)) {
-		expr_type = DEFINED_ZSUPER;
+      case DEFINED_ZSUPER:
+	{
+	    const rb_callable_method_entry_t *me = rb_vm_frame_method_entry(GET_CFP());
+
+	    if (me) {
+		VALUE klass = vm_search_normal_superclass(me->defined_class);
+		ID id = me->def->original_id;
+
+		if (rb_method_boundp(klass, id, 0)) {
+		    expr_type = DEFINED_ZSUPER;
+		}
 	    }
 	}
 	break;
-      }
       case DEFINED_REF:{
 	if (vm_getspecial(th, GET_LEP(), Qfalse, FIX2INT(obj)) != Qnil) {
 	    expr_type = DEFINED_GVAR;

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

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