Skip to content

Commit e3ba84e

Browse files
committed
WIP
1 parent 55f738b commit e3ba84e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

bootstraptest/test_ractor.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,3 +2315,33 @@ def Warning.warn(msg)
23152315
raise unless $msg.all?{/Ractor#take/ =~ it}
23162316
$msg.size
23172317
}
2318+
2319+
# Cause lots of inline CC misses.
2320+
assert_equal ':ok', <<~'RUBY'
2321+
class A; def test; 1 + 1; end; end
2322+
class B; def test; 1 + 1; end; end
2323+
class C; def test; 1 + 1; end; end
2324+
class D; def test; 1 + 1; end; end
2325+
class E; def test; 1 + 1; end; end
2326+
class F; def test; 1 + 1; end; end
2327+
class G; def test; 1 + 1; end; end
2328+
2329+
objs = [A.new, B.new, C.new, D.new, E.new, F.new, G.new].freeze
2330+
2331+
def call_test(obj)
2332+
obj.test
2333+
end
2334+
2335+
ractors = 7.times.map do
2336+
Ractor.new(objs) do |objs|
2337+
objs = objs.shuffle
2338+
100_000.times do
2339+
objs.each do |o|
2340+
call_test(o)
2341+
end
2342+
end
2343+
end
2344+
end
2345+
ractors.each(&:join)
2346+
:ok
2347+
RUBY

vm_insnhelper.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ vm_lookup_cc(const VALUE klass, const struct rb_callinfo * const ci, ID mid)
21652165
VALUE cc_tbl;
21662166
struct rb_class_cc_entries *ccs;
21672167
retry:
2168-
cc_tbl = RCLASS_WRITABLE_CC_TBL(klass);
2168+
cc_tbl = RUBY_ATOMIC_VALUE_LOAD(RCLASS_WRITABLE_CC_TBL(klass));
21692169
ccs = NULL;
21702170

21712171
if (cc_tbl) {
@@ -2210,6 +2210,8 @@ vm_lookup_cc(const VALUE klass, const struct rb_callinfo * const ci, ID mid)
22102210
}
22112211
}
22122212
}
2213+
2214+
RB_GC_GUARD(cc_tbl);
22132215
return NULL;
22142216
}
22152217

0 commit comments

Comments
 (0)