summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-31 08:07:59 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-31 08:07:59 +0000
commit15e48288fdb528e7ae6564b3e2fee00471bdff12 (patch)
treef63444faf5c7728a65ab55bebc5a78c7330ab5aa
parentc16523e67b4d8873168f7cb21a1dd35484247d22 (diff)
* class.c (move_refined_method): should insert a write barrier
from an original class to a created (cloned) method entry. * test/ruby/test_refinement.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--class.c6
-rw-r--r--test/ruby/test_refinement.rb13
3 files changed, 24 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index d5d5541ae8..77779a550b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Aug 31 17:04:45 2015 Koichi Sasada <ko1@atdot.net>
+
+ * class.c (move_refined_method): should insert a write barrier
+ from an original class to a created (cloned) method entry.
+
+ * test/ruby/test_refinement.rb: add a test.
+
Sun Aug 30 02:42:22 2015 Aaron Patterson <tenderlove@ruby-lang.org>
* ext/openssl/ossl_ssl.c (ossl_ssl_method_tab): Only add SSLv3 support
diff --git a/class.c b/class.c
index bea0928f82..90b6c9dfa9 100644
--- a/class.c
+++ b/class.c
@@ -911,7 +911,8 @@ static enum rb_id_table_iterator_result
move_refined_method(ID key, VALUE value, void *data)
{
rb_method_entry_t *me = (rb_method_entry_t *) value;
- struct rb_id_table *tbl = (struct rb_id_table *) data;
+ VALUE klass = (VALUE)data;
+ struct rb_id_table *tbl = RCLASS_M_TBL(klass);
if (me->def->type == VM_METHOD_TYPE_REFINED) {
if (me->def->body.refined.orig_me) {
@@ -919,6 +920,7 @@ move_refined_method(ID key, VALUE value, void *data)
RB_OBJ_WRITE(me, &me->def->body.refined.orig_me, NULL);
new_me = rb_method_entry_clone(me);
rb_id_table_insert(tbl, key, (VALUE)new_me);
+ RB_OBJ_WRITTEN(klass, Qundef, new_me);
rb_method_entry_copy(me, orig_me);
return ID_TABLE_CONTINUE;
}
@@ -953,7 +955,7 @@ rb_prepend_module(VALUE klass, VALUE module)
RCLASS_SET_ORIGIN(klass, origin);
RCLASS_M_TBL(origin) = RCLASS_M_TBL(klass);
RCLASS_M_TBL_INIT(klass);
- rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)RCLASS_M_TBL(klass));
+ rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
}
changed = include_modules_at(klass, klass, module, FALSE);
if (changed < 0)
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index ecc7153649..bf88126973 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -744,6 +744,7 @@ class TestRefinement < Test::Unit::TestCase
PrependIntoRefinement::User.invoke_baz_on(x))
end
+ PrependAfterRefine_CODE = <<-EOC
module PrependAfterRefine
class C
def foo
@@ -777,6 +778,18 @@ class TestRefinement < Test::Unit::TestCase
prepend Mixin
end
end
+ EOC
+ eval PrependAfterRefine_CODE
+
+ def test_prepend_after_refine_wb_miss
+ assert_normal_exit %Q{
+ GC.stress = true
+ 10.times{
+ #{PrependAfterRefine_CODE}
+ undef PrependAfterRefine
+ }
+ }
+ end
def test_prepend_after_refine
x = eval_using(PrependAfterRefine::M,