diff options
author | Jemma Issroff <[email protected]> | 2022-11-08 15:35:31 -0500 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2022-11-10 10:11:34 -0500 |
commit | 5246f4027ec574e77809845e1b1f7822cc2a5cef (patch) | |
tree | a29c972df6a589c7ab8c2541ea2eea1f7caf5f70 /test/ruby/test_shapes.rb | |
parent | 9986697b621e5345177a1c395489dcc9fab8602b (diff) |
Transition shape when object's capacity changes
This commit adds a `capacity` field to shapes, and adds shape
transitions whenever an object's capacity changes. Objects which are
allocated out of a bigger size pool will also make a transition from the
root shape to the shape with the correct capacity for their size pool
when they are allocated.
This commit will allow us to remove numiv from objects completely, and
will also mean we can guarantee that if two objects share shapes, their
IVs are in the same positions (an embedded and extended object cannot
share shapes). This will enable us to implement ivar sets in YJIT using
object shapes.
Co-Authored-By: Aaron Patterson <[email protected]>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6699
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 23696acc70..326ff3a453 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -86,15 +86,10 @@ class TestShapes < Test::Unit::TestCase assert_equal(2, bar_shape.next_iv_index) end - def test_new_obj_has_root_shape - assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of(Object.new)) - end + class TestObject; end - def test_frozen_new_obj_has_frozen_root_shape - assert_shape_equal( - RubyVM::Shape.frozen_root_shape, - RubyVM::Shape.of(Object.new.freeze) - ) + def test_new_obj_has_root_shape + assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of(TestObject.new)) end def test_str_has_root_shape @@ -109,12 +104,12 @@ class TestShapes < Test::Unit::TestCase assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of({})) end - def test_true_has_frozen_root_shape - assert_shape_equal(RubyVM::Shape.frozen_root_shape, RubyVM::Shape.of(true)) + def test_true_has_special_const_shape_id + assert_equal(RubyVM::Shape::SPECIAL_CONST_SHAPE_ID, RubyVM::Shape.of(true).id) end - def test_nil_has_frozen_root_shape - assert_shape_equal(RubyVM::Shape.frozen_root_shape, RubyVM::Shape.of(nil)) + def test_nil_has_special_const_shape_id + assert_equal(RubyVM::Shape::SPECIAL_CONST_SHAPE_ID, RubyVM::Shape.of(nil).id) end def test_basic_shape_transition |