diff options
author | Peter Zhu <peter@peterzhu.ca> | 2022-07-11 10:09:39 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2022-07-15 09:21:07 -0400 |
commit | 7424ea184f9d67c1c7f3ee97494ed3bd1aa60833 (patch) | |
tree | 822838e39d81cd2785c970cb45a86854823af6fe /test/ruby | |
parent | 7fda741f6e67b809b08423f0d4e903c078da2eed (diff) |
Implement Objects on VWA
This commit implements Objects on Variable Width Allocation. This allows
Objects with more ivars to be embedded (i.e. contents directly follow the
object header) which improves performance through better cache locality.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6117
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_gc_compact.rb | 24 | ||||
-rw-r--r-- | test/ruby/test_mjit.rb | 5 |
2 files changed, 27 insertions, 2 deletions
diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index 7d72f3573b..92a2be1174 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -249,6 +249,30 @@ class TestGCCompact < Test::Unit::TestCase end; end + def test_moving_objects_between_size_pools + assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) + begin; + class Foo + def add_ivars + 10.times do |i| + instance_variable_set("@foo" + i.to_s, 0) + end + end + end + + OBJ_COUNT = 500 + + GC.verify_compaction_references(expand_heap: true, toward: :empty) + + ary = OBJ_COUNT.times.map { Foo.new } + ary.each(&:add_ivars) + + stats = GC.verify_compaction_references(expand_heap: true, toward: :empty) + + assert_operator(stats[:moved_up][:T_OBJECT], :>=, OBJ_COUNT) + end; + end + def test_moving_strings_up_size_pools omit if !GC.using_rvargc? assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}", timeout: 10, signal: :SEGV) diff --git a/test/ruby/test_mjit.rb b/test/ruby/test_mjit.rb index fd7a4e270a..02be88aa32 100644 --- a/test/ruby/test_mjit.rb +++ b/test/ruby/test_mjit.rb @@ -969,23 +969,24 @@ class TestMJIT < Test::Unit::TestCase end def test_heap_promotion_of_ivar_in_the_middle_of_jit + omit if GC.using_rvargc? + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "true\ntrue\n", success_count: 2, min_calls: 2) begin; class A def initialize @iv0 = nil @iv1 = [] - @iv2 = nil end def test(add) @iv0.nil? - @iv2.nil? add_ivar if add @iv1.empty? end def add_ivar + @iv2 = nil @iv3 = nil end end |