Ractor: revert to moving object bytes, but size pool aware

Using `rb_obj_clone` introduce other problems, such as `initialize_*`
callbacks invocation in the context of the parent ractor.

So we can revert back to copy the content of the object slots,
but in a way that is aware of size pools.
This commit is contained in:
Jean Boussier 2025-04-04 13:28:51 +02:00
parent eb765913c1
commit 085cc6e434
Notes: git 2025-04-04 14:26:46 +00:00
5 changed files with 73 additions and 11 deletions

View file

@ -2101,3 +2101,24 @@ assert_equal 'ok', %q{
:fail
end
}
# move objects inside frozen containers
assert_equal 'ok', %q{
ractor = Ractor.new { Ractor.receive }
obj = Array.new(10, 42)
original = obj.dup
ractor.send([obj].freeze, move: true)
roundtripped_obj = ractor.take[0]
roundtripped_obj == original ? :ok : roundtripped_obj
}
# move object with generic ivar
assert_equal 'ok', %q{
ractor = Ractor.new { Ractor.receive }
obj = Array.new(10, 42)
obj.instance_variable_set(:@array, [1])
ractor.send(obj, move: true)
roundtripped_obj = ractor.take
roundtripped_obj.instance_variable_get(:@array) == [1] ? :ok : roundtripped_obj
}