Make the value shareable deeply

This commit is contained in:
Nobuyoshi Nakada 2020-10-21 14:11:18 +09:00
parent 070a990bcb
commit 11d9983bc3
Notes: git 2020-12-14 19:19:46 +09:00
2 changed files with 7 additions and 3 deletions

View File

@ -1181,20 +1181,24 @@ x = __ENCODING__
a = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
begin;
# shareable_constant_value: true
A = []
A = [[1]]
end;
assert_predicate(a, :frozen?)
assert_equal([1], a[0])
assert_predicate(a[0], :frozen?)
a, b = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
begin;
# shareable_constant_value: false
class X # shareable_constant_value: true
A = []
A = [[1]]
end
B = []
[X::A, B]
end;
assert_predicate(a, :frozen?)
assert_not_predicate(b, :frozen?)
assert_equal([1], a[0])
assert_predicate(a[0], :frozen?)
end
=begin

2
vm.c
View File

@ -3179,7 +3179,7 @@ m_core_hash_merge_kwd(VALUE recv, VALUE hash, VALUE kw)
static VALUE
m_core_make_shareable(VALUE recv, VALUE obj)
{
return rb_obj_freeze(obj);
return rb_ractor_make_shareable(obj);
}
static VALUE