From 5199f2aaf9527c97e6ec371e19748d0c2ac7a70e Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Wed, 19 Apr 2023 15:59:25 -0400 Subject: Implement Hash AR tables on VWA --- test/ruby/test_gc_compact.rb | 20 ++++++++++++++++++++ test/ruby/test_shapes.rb | 6 ++++-- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index bef2ba9605..b1b964589a 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -417,6 +417,26 @@ class TestGCCompact < Test::Unit::TestCase end; end + def test_moving_hashes_down_size_pools + omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 + + assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) + begin; + HASH_COUNT = 500 + + GC.verify_compaction_references(expand_heap: true, toward: :empty) + + base_hash = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8 } + ary = HASH_COUNT.times.map { base_hash.dup } + ary.each { |h| h[:i] = 9 } + + stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) + + assert_operator(stats[:moved_down][:T_HASH], :>=, HASH_COUNT) + assert_include(ObjectSpace.dump(ary[0]), '"slot_size":' + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE].to_s) + end; + end + def test_moving_objects_between_size_pools_keeps_shape_frozen_status # [Bug #19536] assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}") diff --git a/test/ruby/test_shapes.rb b/test/ruby/test_shapes.rb index 1d9159bac0..d9cce4a337 100644 --- a/test/ruby/test_shapes.rb +++ b/test/ruby/test_shapes.rb @@ -372,8 +372,10 @@ class TestShapes < Test::Unit::TestCase assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of([])) end - def test_hash_has_root_shape - assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of({})) + def test_hash_has_correct_pool_shape + # All hashes are now allocated their own ar_table, so start in a + # larger pool, and have already transitioned once. + assert_shape_equal(RubyVM::Shape.root_shape, RubyVM::Shape.of({}).parent) end def test_true_has_special_const_shape_id -- cgit v1.2.1