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

ruby-changes:38998

From: normal <ko1@a...>
Date: Wed, 1 Jul 2015 06:07:34 +0900 (JST)
Subject: [ruby-changes:38998] normal:r51079 (trunk): move RB_GC_GUARD responsibility to rb_add_method_iseq

normal	2015-07-01 06:07:18 +0900 (Wed, 01 Jul 2015)

  New Revision: 51079

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

  Log:
    move RB_GC_GUARD responsibility to rb_add_method_iseq
    
    This simplifies all the callers and makes code easier to use
    and review.  I was confused about the need for RB_GC_GUARD
    in define_{aset,aref}_method of struct.c without reading
    rb_add_method_iseq.
    
    Likewise, do the same for rb_iseq_clone, where the GC guard
    only seems neccesary iff RGenGC is disabled.
    
    * vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
    * class.c (clone_method): remove RB_GC_GUARD
    * struct.c (define_aref_method): ditto
      (define_aset_method): ditto
    * vm.c (vm_define_method):
    * iseq.c (rb_iseq_clone): add RB_GC_GUARD

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/iseq.c
    trunk/struct.c
    trunk/vm.c
    trunk/vm_method.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51078)
+++ ChangeLog	(revision 51079)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jul  1 05:57:03 2015  Eric Wong  <e@8...>
+
+	* vm_method.c (rb_add_method_iseq): add RB_GC_GUARD
+	* class.c (clone_method): remove RB_GC_GUARD
+	* struct.c (define_aref_method): ditto
+	  (define_aset_method): ditto
+	* vm.c (vm_define_method):
+	* iseq.c (rb_iseq_clone): add RB_GC_GUARD
+
 Wed Jul  1 05:43:58 2015  Eric Wong  <e@8...>
 
 	* struct.c (AREF_HASH_THRESHOLD): new macro
Index: iseq.c
===================================================================
--- iseq.c	(revision 51078)
+++ iseq.c	(revision 51079)
@@ -1968,6 +1968,8 @@ rb_iseq_clone(VALUE iseqval, VALUE newcb https://github.com/ruby/ruby/blob/trunk/iseq.c#L1968
 	RB_OBJ_WRITTEN(iseq1->self, Qundef, iseq1->klass);
     }
 
+    RB_GC_GUARD(iseqval); /* seems necessary iff RGenGC is disabled */
+
     return newiseq;
 }
 
Index: vm_method.c
===================================================================
--- vm_method.c	(revision 51078)
+++ vm_method.c	(revision 51079)
@@ -562,6 +562,7 @@ rb_add_method_iseq(VALUE klass, ID mid, https://github.com/ruby/ruby/blob/trunk/vm_method.c#L562
     iseq_body.iseqptr = iseq;
     iseq_body.cref = cref;
     rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, &iseq_body, visi);
+    RB_GC_GUARD(iseqval);
 }
 
 static rb_method_entry_t *
Index: struct.c
===================================================================
--- struct.c	(revision 51078)
+++ struct.c	(revision 51079)
@@ -288,7 +288,6 @@ define_aref_method(VALUE nstr, VALUE nam https://github.com/ruby/ruby/blob/trunk/struct.c#L288
     VALUE iseqval = rb_method_for_self_aref(name, off, rb_vm_opt_struct_aref);
 
     rb_add_method_iseq(nstr, SYM2ID(name), iseqval, NULL, METHOD_VISI_PUBLIC);
-    RB_GC_GUARD(iseqval);
 }
 
 static void
@@ -298,7 +297,6 @@ define_aset_method(VALUE nstr, VALUE nam https://github.com/ruby/ruby/blob/trunk/struct.c#L297
     VALUE iseqval = rb_method_for_self_aset(name, off, rb_vm_opt_struct_aset);
 
     rb_add_method_iseq(nstr, SYM2ID(name), iseqval, NULL, METHOD_VISI_PUBLIC);
-    RB_GC_GUARD(iseqval);
 }
 
 static VALUE
Index: class.c
===================================================================
--- class.c	(revision 51078)
+++ class.c	(revision 51079)
@@ -249,7 +249,6 @@ clone_method(VALUE old_klass, VALUE new_ https://github.com/ruby/ruby/blob/trunk/class.c#L249
 	newiseqval = rb_iseq_clone(me->def->body.iseq.iseqptr->self, new_klass);
 	rb_vm_rewrite_cref(me->def->body.iseq.cref, old_klass, new_klass, &new_cref);
 	rb_add_method_iseq(new_klass, mid, newiseqval, new_cref, METHOD_ENTRY_VISI(me));
-	RB_GC_GUARD(newiseqval);
     }
     else {
 	rb_method_entry_set(new_klass, mid, me, METHOD_ENTRY_VISI(me));
Index: vm.c
===================================================================
--- vm.c	(revision 51078)
+++ vm.c	(revision 51079)
@@ -2288,7 +2288,7 @@ vm_define_method(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L2288
     GetISeqPtr(iseqval, miseq);
 
     if (miseq->klass) {
-	RB_GC_GUARD(iseqval) = rb_iseq_clone(iseqval, 0);
+	iseqval = rb_iseq_clone(iseqval, 0);
 	GetISeqPtr(iseqval, miseq);
     }
 

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

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