From f45eb3dcb9c7d849064cb802953f37e1cf9f3996 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 15 Oct 2024 12:55:05 -0400 Subject: [PATCH] Use GC.respond_to?(:compact) in bootstraptest/test_yjit.rb defined?(GC.compact) will always return true even when compaction is not supported. We should use GC.respond_to?(:compact) instead. --- bootstraptest/test_yjit.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index f0192c04142ae0..545243a0e4c6b4 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -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) @@ -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} }") @@ -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 @@ -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