Skip to content

Commit

Permalink
Use GC.respond_to?(:compact) in bootstraptest/test_yjit.rb
Browse files Browse the repository at this point in the history
defined?(GC.compact) will always return true even when compaction is not
supported. We should use GC.respond_to?(:compact) instead.
  • Loading branch information
peterzhu2118 committed Oct 15, 2024
1 parent 644153b commit f45eb3d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bootstraptest/test_yjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test(name, args)

# regression test for GC marking stubs in invalidated code
assert_normal_exit %q{
skip true unless defined?(GC.compact)
skip true unless GC.respond_to?(:compact)
garbage = Array.new(10_000) { [] } # create garbage to cause iseq movement
eval(<<~RUBY)
def foo(n, garbage)
Expand Down Expand Up @@ -158,7 +158,7 @@ def call_foo = foo(0, 1, 2, 3, &->{})

# regression test for invokeblock iseq guard
assert_equal 'ok', %q{
skip :ok unless defined?(GC.compact)
skip :ok unless GC.respond_to?(:compact)
def foo = yield
10.times do |i|
ret = eval("foo { #{i} }")
Expand Down Expand Up @@ -1230,7 +1230,7 @@ def special.[](idx)

# Test that object references in generated code get marked and moved
assert_equal "good", %q{
skip :good unless defined?(GC.compact)
skip :good unless GC.respond_to?(:compact)
def bar
"good"
end
Expand Down Expand Up @@ -2351,7 +2351,7 @@ def foo(obj)

# Test EP == BP invalidation with moving ISEQs
assert_equal 'ok', %q{
skip :ok unless defined?(GC.compact)
skip :ok unless GC.respond_to?(:compact)
def entry
ok = proc { :ok } # set #entry as an EP-escaping ISEQ
[nil].reverse_each do # avoid exiting the JIT frame on the constant
Expand Down

0 comments on commit f45eb3d

Please sign in to comment.