diff options
author | Aaron Patterson <[email protected]> | 2023-10-30 09:50:56 -0700 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-10-31 12:07:54 -0400 |
commit | 6f5e378057a02dadbb0173072f69c8a3f30f5649 (patch) | |
tree | e42c9b35637d13aa12ca329ef58fb375a21dd473 /test/ruby/test_shapes.rb | |
parent | ac7f913ca3af970225c9cc93b92eb5c403894180 (diff) |
Fix "too complex" iv sets on generic ivar objects
We weren't taking in to account that objects with generic IV tables
could go "too complex" in the IV set code. This commit takes that in to
account and also ensures FL_EXIVAR is set when a geniv object
transitions to "too complex"
Co-Authored-By: Jean Boussier <[email protected]>
Diffstat (limited to 'test/ruby/test_shapes.rb')
-rw-r--r-- | test/ruby/test_shapes.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index b9ac1cafe1..a098edf409 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -184,6 +184,32 @@ class TestShapes < Test::Unit::TestCase assert_empty obj.instance_variables end + def test_too_complex_geniv + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class TooComplex < Hash + attr_reader :very_unique + end + + obj = Object.new + i = 0 + while RubyVM::Shape.shapes_available > 0 + obj.instance_variable_set(:"@a#{i}", 1) + i += 1 + end + + (RubyVM::Shape::SHAPE_MAX_VARIATIONS * 2).times do + TooComplex.new.instance_variable_set(:"@unique_#{_1}", 1) + end + + tc = TooComplex.new + tc.instance_variable_set(:@very_unique, 3) + tc.instance_variable_set(:@very_unique2, 4) + assert_equal 3, tc.instance_variable_get(:@very_unique) + assert_equal 4, tc.instance_variable_get(:@very_unique2) + end; + end + def test_use_all_shapes_then_freeze assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; |