diff options
| author | NARUSE, Yui <naruse@airemix.jp> | 2023-01-19 21:52:47 +0900 |
|---|---|---|
| committer | NARUSE, Yui <naruse@airemix.jp> | 2023-01-19 21:52:47 +0900 |
| commit | 6a8fcb50210f8414d76968298576e39b9fa82562 (patch) | |
| tree | 654944cb9e09b7876805aa6a4976752325bad1c8 /test/ruby | |
| parent | 98abe4a0be09e0571104f4ca1b5655e353910aa0 (diff) | |
merge revision(s) 3be2acfafd3b3c6168e2266c7c6561d143d7ae5c: [Backport #19327]
Fix re-embedding of strings during compaction
The reference updating code for strings is not re-embedding strings
because the code is incorrectly wrapped inside of a
`if (STR_SHARED_P(obj))` clause. Shared strings can't be re-embedded
so this ends up being a no-op. This means that strings can be moved to a
large size pool during compaction, but won't be re-embedded, which would
waste the space.
---
gc.c | 16 +++++++++-------
string.c | 12 ++++++++----
test/ruby/test_gc_compact.rb | 8 ++++----
3 files changed, 21 insertions(+), 15 deletions(-)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_gc_compact.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index d92c979cf0..4d7bb8f7ae 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -382,7 +382,7 @@ class TestGCCompact < Test::Unit::TestCase def test_moving_strings_up_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 - assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) + assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) begin; STR_COUNT = 500 @@ -394,14 +394,14 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats[:moved_up][:T_STRING], :>=, STR_COUNT) - assert(ary) # warning: assigned but unused variable - ary + assert_include(ObjectSpace.dump(ary[0]), '"embedded":true') end; end def test_moving_strings_down_size_pools omit if GC::INTERNAL_CONSTANTS[:SIZE_POOL_COUNT] == 1 - assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) + assert_separately(%w[-robjspace], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) begin; STR_COUNT = 500 @@ -412,7 +412,7 @@ class TestGCCompact < Test::Unit::TestCase stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) assert_operator(stats[:moved_down][:T_STRING], :>=, STR_COUNT) - assert(ary) # warning: assigned but unused variable - ary + assert_include(ObjectSpace.dump(ary[0]), '"embedded":true') end; end end |
