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

ruby-changes:40482

From: ko1 <ko1@a...>
Date: Sat, 14 Nov 2015 03:02:15 +0900 (JST)
Subject: [ruby-changes:40482] ko1:r52563 (trunk): * vm.c (vm_define_method): refactoring.

ko1	2015-11-14 03:01:59 +0900 (Sat, 14 Nov 2015)

  New Revision: 52563

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

  Log:
    * vm.c (vm_define_method): refactoring.
      * get CREF in this function.
      * cbase is no longer needed (CREF_CLASS(cref) is enough).
    
    * compile.c: RubyVM::FrozenCore.define_method only accept 2 args.

  Modified files:
    trunk/ChangeLog
    trunk/compile.c
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52562)
+++ ChangeLog	(revision 52563)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Nov 14 02:58:03 2015  Koichi Sasada  <ko1@a...>
+
+	* vm.c (vm_define_method): refactoring.
+	  * get CREF in this function.
+	  * cbase is no longer needed (CREF_CLASS(cref) is enough).
+
+	* compile.c: RubyVM::FrozenCore.define_method only accept 2 args.
+
 Sat Nov 14 02:34:43 2015  Koichi Sasada  <ko1@a...>
 
 	* vm.c (vm_define_method): do not use current CREF immediately,
Index: compile.c
===================================================================
--- compile.c	(revision 52562)
+++ compile.c	(revision 52563)
@@ -5258,10 +5258,9 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ https://github.com/ruby/ruby/blob/trunk/compile.c#L5258
 	debugp_param("defn/iseq", (VALUE)method_iseq);
 
 	ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
-	ADD_INSN1(ret, line, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
 	ADD_INSN1(ret, line, putobject, ID2SYM(node->nd_mid));
 	ADD_INSN1(ret, line, putiseq, method_iseq);
-	ADD_SEND (ret, line, id_core_define_method, INT2FIX(3));
+	ADD_SEND (ret, line, id_core_define_method, INT2FIX(2));
 
 	if (poped) {
 	    ADD_INSN(ret, line, pop);
Index: vm.c
===================================================================
--- vm.c	(revision 52562)
+++ vm.c	(revision 52563)
@@ -2337,14 +2337,14 @@ rb_thread_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/vm.c#L2337
 }
 
 static void
-vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
-		 rb_num_t is_singleton, rb_cref_t *cref)
+vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, int is_singleton)
 {
     VALUE klass;
     rb_method_visibility_t visi;
+    rb_cref_t *cref = rb_vm_cref();
 
     if (!is_singleton) {
-	klass = obj;
+	klass = CREF_CLASS(cref);
 	visi = rb_scope_visibility_get();
     }
     else { /* singleton */
@@ -2374,10 +2374,10 @@ vm_define_method(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2374
 } while (0)
 
 static VALUE
-m_core_define_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
+m_core_define_method(VALUE self, VALUE sym, VALUE iseqval)
 {
     REWIND_CFP({
-	vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 0, rb_vm_cref());
+	vm_define_method(GET_THREAD(), Qnil, SYM2ID(sym), iseqval, FALSE);
     });
     return sym;
 }
@@ -2386,7 +2386,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2386
 m_core_define_singleton_method(VALUE self, VALUE cbase, VALUE sym, VALUE iseqval)
 {
     REWIND_CFP({
-	vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 1, rb_vm_cref());
+	vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, TRUE);
     });
     return sym;
 }
@@ -2586,7 +2586,7 @@ Init_VM(void) https://github.com/ruby/ruby/blob/trunk/vm.c#L2586
     rb_define_method_id(klass, id_core_set_method_alias, m_core_set_method_alias, 3);
     rb_define_method_id(klass, id_core_set_variable_alias, m_core_set_variable_alias, 2);
     rb_define_method_id(klass, id_core_undef_method, m_core_undef_method, 2);
-    rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3);
+    rb_define_method_id(klass, id_core_define_method, m_core_define_method, 2);
     rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3);
     rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 0);
     rb_define_method_id(klass, id_core_hash_from_ary, m_core_hash_from_ary, 1);

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

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