ruby-changes:30455
From: ko1 <ko1@a...>
Date: Mon, 12 Aug 2013 15:19:23 +0900 (JST)
Subject: [ruby-changes:30455] ko1:r42534 (trunk): * class.c (rb_prepend_module): make T_ICLASS object shady because
ko1 2013-08-12 15:19:15 +0900 (Mon, 12 Aug 2013) New Revision: 42534 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42534 Log: * class.c (rb_prepend_module): make T_ICLASS object shady because this T_ICLASS object seems to share method table with other class objects. It was causes WB miss. TODO: need to know the data structure. * test/ruby/test_module.rb: add a test for WB miss. Modified files: trunk/ChangeLog trunk/class.c trunk/test/ruby/test_module.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42533) +++ ChangeLog (revision 42534) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Aug 12 15:16:58 2013 Koichi Sasada <ko1@a...> + + * class.c (rb_prepend_module): make T_ICLASS object shady because + this T_ICLASS object seems to share method table with other class + objects. It was causes WB miss. + TODO: need to know the data structure. + + * test/ruby/test_module.rb: add a test for WB miss. + Mon Aug 12 13:47:54 2013 Zachary Scott <e@z...> * process.c: [DOC] RDoc formatting of Process.clock_gettime Index: class.c =================================================================== --- class.c (revision 42533) +++ class.c (revision 42534) @@ -826,6 +826,7 @@ rb_prepend_module(VALUE klass, VALUE mod https://github.com/ruby/ruby/blob/trunk/class.c#L826 origin = RCLASS_ORIGIN(klass); if (origin == klass) { origin = class_alloc(T_ICLASS, klass); + OBJ_WB_UNPROTECT(origin); /* TODO: conservertive shading. Need more survery. */ RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass)); RCLASS_SET_SUPER(klass, origin); RCLASS_ORIGIN(klass) = origin; Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 42533) +++ test/ruby/test_module.rb (revision 42534) @@ -1760,4 +1760,20 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1760 self.#{method} INPUT end + + def test_prepend_gc + assert_separately [], %{ + module Foo + end + class Object + prepend Foo + end + GC.start # make created T_ICLASS old (or remembered shady) + class Object # add methods into T_ICLASS (need WB if it is old) + def foo; end + attr_reader :bar + end + 1_000_000.times{''} # cause GC + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/