fix Ractor.make_shareable() with Class/Module

To check shareable-ness, rb_ractor_shareable_p() is needed
for Class/Module objects isntead of checking flags.
This commit is contained in:
Koichi Sasada 2020-12-21 01:13:39 +09:00
parent 8680ae9cbd
commit 730f314171
2 changed files with 9 additions and 2 deletions

View File

@ -1149,6 +1149,14 @@ assert_equal '[:ok, false, false]', %q{
[(Ractor.make_shareable(x) rescue :ok), Ractor.shareable?(x), Ractor.shareable?(y)]
}
# Ractor.make_shareable with Class/Module
assert_equal '[C, M]', %q{
class C; end
module M; end
Ractor.make_shareable(ary = [C, M])
}
# define_method() can invoke different Ractor's proc if the proc is shareable.
assert_equal '1', %q{
class C
@ -1191,7 +1199,6 @@ assert_equal '[false, false, true, true]', %q{
r
}
# Ractor deep copies frozen objects (ary)
assert_equal '[true, false]', %q{
Ractor.new([[]].freeze) { |ary|

View File

@ -2396,7 +2396,7 @@ make_shareable_check_shareable(VALUE obj)
VM_ASSERT(!SPECIAL_CONST_P(obj));
bool made_shareable = false;
if (RB_OBJ_SHAREABLE_P(obj)) {
if (rb_ractor_shareable_p(obj)) {
return traverse_skip;
}
else if (!frozen_shareable_p(obj, &made_shareable)) {