mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 21:14:23 +02:00
Make the value shareable deeply
This commit is contained in:
parent
070a990bcb
commit
11d9983bc3
Notes:
git
2020-12-14 19:19:46 +09:00
2 changed files with 7 additions and 3 deletions
|
@ -1181,20 +1181,24 @@ x = __ENCODING__
|
||||||
a = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
|
a = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
begin;
|
begin;
|
||||||
# shareable_constant_value: true
|
# shareable_constant_value: true
|
||||||
A = []
|
A = [[1]]
|
||||||
end;
|
end;
|
||||||
assert_predicate(a, :frozen?)
|
assert_predicate(a, :frozen?)
|
||||||
|
assert_equal([1], a[0])
|
||||||
|
assert_predicate(a[0], :frozen?)
|
||||||
a, b = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
|
a, b = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
|
||||||
begin;
|
begin;
|
||||||
# shareable_constant_value: false
|
# shareable_constant_value: false
|
||||||
class X # shareable_constant_value: true
|
class X # shareable_constant_value: true
|
||||||
A = []
|
A = [[1]]
|
||||||
end
|
end
|
||||||
B = []
|
B = []
|
||||||
[X::A, B]
|
[X::A, B]
|
||||||
end;
|
end;
|
||||||
assert_predicate(a, :frozen?)
|
assert_predicate(a, :frozen?)
|
||||||
assert_not_predicate(b, :frozen?)
|
assert_not_predicate(b, :frozen?)
|
||||||
|
assert_equal([1], a[0])
|
||||||
|
assert_predicate(a[0], :frozen?)
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
2
vm.c
2
vm.c
|
@ -3179,7 +3179,7 @@ m_core_hash_merge_kwd(VALUE recv, VALUE hash, VALUE kw)
|
||||||
static VALUE
|
static VALUE
|
||||||
m_core_make_shareable(VALUE recv, VALUE obj)
|
m_core_make_shareable(VALUE recv, VALUE obj)
|
||||||
{
|
{
|
||||||
return rb_obj_freeze(obj);
|
return rb_ractor_make_shareable(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue