aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-30 21:07:18 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-30 21:07:18 +0000
commitb49075cdf15a733cf7a9b1f9ce9d06c40828db3d (patch)
treeffe20a1e7d680301a086083bd3ee77b081eba29d
parentc7548028a20c555b692c07c37b3ffd2d416bb434 (diff)
downloadruby-b49075cdf15a733cf7a9b1f9ce9d06c40828db3d.tar.gz
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--class.c1
-rw-r--r--iseq.c2
-rw-r--r--struct.c2
-rw-r--r--vm.c2
-rw-r--r--vm_method.c1
6 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ee2a8cf204..2fec8ddb72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Jul 1 05:57:03 2015 Eric Wong <e@80x24.org>
+
+ * 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@80x24.org>
* struct.c (AREF_HASH_THRESHOLD): new macro
diff --git a/class.c b/class.c
index 6ee1e084d3..6207fb7c5a 100644
--- a/class.c
+++ b/class.c
@@ -249,7 +249,6 @@ clone_method(VALUE old_klass, VALUE new_klass, ID mid, const rb_method_entry_t *
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));
diff --git a/iseq.c b/iseq.c
index 037df44d2c..48de119a32 100644
--- a/iseq.c
+++ b/iseq.c
@@ -1968,6 +1968,8 @@ rb_iseq_clone(VALUE iseqval, VALUE newcbase)
RB_OBJ_WRITTEN(iseq1->self, Qundef, iseq1->klass);
}
+ RB_GC_GUARD(iseqval); /* seems necessary iff RGenGC is disabled */
+
return newiseq;
}
diff --git a/struct.c b/struct.c
index eda56733e2..b68f2a8a44 100644
--- a/struct.c
+++ b/struct.c
@@ -288,7 +288,6 @@ define_aref_method(VALUE nstr, VALUE name, VALUE off)
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 name, VALUE off)
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
diff --git a/vm.c b/vm.c
index 69b594f950..ad0d8505f7 100644
--- a/vm.c
+++ b/vm.c
@@ -2288,7 +2288,7 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
GetISeqPtr(iseqval, miseq);
if (miseq->klass) {
- RB_GC_GUARD(iseqval) = rb_iseq_clone(iseqval, 0);
+ iseqval = rb_iseq_clone(iseqval, 0);
GetISeqPtr(iseqval, miseq);
}
diff --git a/vm_method.c b/vm_method.c
index 43b5d2aafc..5a8439649a 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -562,6 +562,7 @@ rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_metho
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 *