From d8cb827f39d4c72d2a79e40371ba2a4fb3e95b28 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 24 Oct 2023 12:43:22 -0700 Subject: Remove SHAPE_MAX_NUM_IVS There is no longer a limit on the number of IVs you can store. SHAPE_MAX_NUM_IVS was used to work around the IV10K problem (the well known problem where setting 10k instance variables in a row would be too slow). The redblack tree works well at any shape depth, even depths greater than 80, and solves the IV10K problem. --- test/ruby/test_shapes.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 591fdbe4a3..7849ca546b 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -5,6 +5,8 @@ require 'json' # These test the functionality of object shapes class TestShapes < Test::Unit::TestCase + MANY_IVS = 80 + class IVOrder def expected_ivs %w{ @a @b @c @d @e @f @g @h @i @j @k } @@ -149,7 +151,7 @@ class TestShapes < Test::Unit::TestCase def test_too_many_ivs_on_class obj = Class.new - (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 1).times do + (MANY_IVS + 1).times do obj.instance_variable_set(:"@a#{_1}", 1) end @@ -159,10 +161,10 @@ class TestShapes < Test::Unit::TestCase def test_removing_when_too_many_ivs_on_class obj = Class.new - (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + (MANY_IVS + 2).times do obj.instance_variable_set(:"@a#{_1}", 1) end - (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + (MANY_IVS + 2).times do obj.remove_instance_variable(:"@a#{_1}") end @@ -172,10 +174,10 @@ class TestShapes < Test::Unit::TestCase def test_removing_when_too_many_ivs_on_module obj = Module.new - (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + (MANY_IVS + 2).times do obj.instance_variable_set(:"@a#{_1}", 1) end - (RubyVM::Shape::SHAPE_MAX_NUM_IVS + 2).times do + (MANY_IVS + 2).times do obj.remove_instance_variable(:"@a#{_1}") end -- cgit v1.2.3