diff options
author | Peter Zhu <peter@peterzhu.ca> | 2022-02-01 09:25:12 -0500 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2022-02-02 09:52:04 -0500 |
commit | 7b77d46671685c837adc33b39ae0210e04cd8b24 (patch) | |
tree | 426dd92de0af81c4d6cbc3f0af732cc7fe80ede8 /test/ruby | |
parent | af107710457b4bd148c6e5ee7a336ed4961f5423 (diff) | |
download | ruby-7b77d46671685c837adc33b39ae0210e04cd8b24.tar.gz |
Decouple GC slot sizes from RVALUE
Add a new macro BASE_SLOT_SIZE that determines the slot size.
For Variable Width Allocation (compiled with USE_RVARGC=1), all slot
sizes are powers-of-2 multiples of BASE_SLOT_SIZE.
For USE_RVARGC=0, BASE_SLOT_SIZE is set to sizeof(RVALUE).
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_gc.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_time.rb | 20 |
3 files changed, 14 insertions, 12 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 2b274862c0..9ca991373e 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -872,9 +872,9 @@ class TestFileExhaustive < Test::Unit::TestCase bug9934 = '[ruby-core:63114] [Bug #9934]' require "objspace" path = File.expand_path("/foo") - assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], bug9934) + assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE], bug9934) path = File.expand_path("/a"*25) - assert_equal(path.bytesize+1 + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], ObjectSpace.memsize_of(path), bug9934) + assert_equal(path.bytesize + 1 + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE], ObjectSpace.memsize_of(path), bug9934) end def test_expand_path_encoding diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 788f2974b5..fc49659c27 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -152,7 +152,7 @@ class TestGc < Test::Unit::TestCase GC.stat_heap(i, stat_heap) GC.stat(stat) - assert_equal GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] * (2**i), stat_heap[:slot_size] + assert_equal GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] * (2**i), stat_heap[:slot_size] assert_operator stat_heap[:heap_allocatable_pages], :<=, stat[:heap_allocatable_pages] assert_operator stat_heap[:heap_eden_pages], :<=, stat[:heap_eden_pages] assert_operator stat_heap[:heap_eden_slots], :>=, 0 diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 445518ab57..8300681fe5 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -1312,15 +1312,17 @@ class TestTime < Test::Unit::TestCase omit "GC is in debug" if GC::INTERNAL_CONSTANTS[:DEBUG] require 'objspace' t = Time.at(0) - size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] - case size - when 20 then expect = 50 - when 24 then expect = 54 - when 40 then expect = 86 - when 48 then expect = 94 - else - flunk "Unsupported RVALUE_SIZE=#{size}, update test_memsize" - end + sizeof_timew = + if RbConfig::SIZEOF.key?("uint64_t") && RbConfig::SIZEOF["long"] * 2 <= RbConfig::SIZEOF["uint64_t"] + RbConfig::SIZEOF["uint64_t"] + else + RbConfig::SIZEOF["void*"] # Same size as VALUE + end + expect = + GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] + + sizeof_timew + + RbConfig::SIZEOF["void*"] * 4 + 5 + # vtm + 1 # tzmode, tm_got assert_equal expect, ObjectSpace.memsize_of(t) rescue LoadError => e omit "failed to load objspace: #{e.message}" |