diff options
author | Jean Boussier <[email protected]> | 2023-10-27 16:41:03 +0200 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2023-10-27 21:09:03 +0200 |
commit | 4aee6931c35a80af846f7100cb8aa1525618e580 (patch) | |
tree | 73a6039a530768d14cae595b2ccbd563257f2152 /test/ruby/test_shapes.rb | |
parent | d654d580f388a1ffc60e74d4b05f753c884ec543 (diff) |
Make get_next_shape_internal idempotent
Since the check for MAX_SHAPE_ID was done before even checking
if the transition we're looking for even exists, as soon as the
max shape is reached, get_next_shape_internal would always return
`TOO_COMPLEX` regardless of whether the transition we're looking
for already exist or not.
In addition to entirely de-optimize all newly created objects, it
also made an assertion fail in `vm_setivar`:
```
vm_setivar:rb_shape_get_next_iv_shape(rb_shape_get_shape_by_id(source_shape_id), id) == dest_shape
```
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index dbfbb937a8..af2af5c778 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -207,6 +207,25 @@ class TestShapes < Test::Unit::TestCase end; end + def test_run_out_of_shape + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class A + def initialize + @a = 1 + end + end + # Try to run out of shapes + o = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + o.instance_variable_set(:"@i#{i}", 1) + i += 1 + A.new + end + end; + end + def test_use_all_shapes_module assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |