* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7f0a26e271
commit
9af743fe0e
@ -1,3 +1,12 @@
|
|||||||
|
Mon Aug 12 15:16:58 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* 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@zzak.io>
|
Mon Aug 12 13:47:54 2013 Zachary Scott <e@zzak.io>
|
||||||
|
|
||||||
* process.c: [DOC] RDoc formatting of Process.clock_gettime
|
* process.c: [DOC] RDoc formatting of Process.clock_gettime
|
||||||
|
1
class.c
1
class.c
@ -826,6 +826,7 @@ rb_prepend_module(VALUE klass, VALUE module)
|
|||||||
origin = RCLASS_ORIGIN(klass);
|
origin = RCLASS_ORIGIN(klass);
|
||||||
if (origin == klass) {
|
if (origin == klass) {
|
||||||
origin = class_alloc(T_ICLASS, 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(origin, RCLASS_SUPER(klass));
|
||||||
RCLASS_SET_SUPER(klass, origin);
|
RCLASS_SET_SUPER(klass, origin);
|
||||||
RCLASS_ORIGIN(klass) = origin;
|
RCLASS_ORIGIN(klass) = origin;
|
||||||
|
@ -1760,4 +1760,20 @@ class TestModule < Test::Unit::TestCase
|
|||||||
self.#{method}
|
self.#{method}
|
||||||
INPUT
|
INPUT
|
||||||
end
|
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
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user