From 78b27ce62a7d6f28c73d6fb4f97b0948859be8e0 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 21 Dec 2023 14:30:55 -0800 Subject: [PATCH] RJIT: Streamline RJIT enablement check in bootstrap tests so that `make btest-bruby` skips the right tests. --- bootstraptest/runner.rb | 5 +++++ bootstraptest/test_gc.rb | 2 +- bootstraptest/test_thread.rb | 5 ++--- bootstraptest/test_yjit.rb | 16 ++++++++-------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index 6b5851e67a465d..a34527d2fa0963 100755 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -789,4 +789,9 @@ def check_coredump end end +def rjit_enabled? + # Don't check `RubyVM::RJIT.enabled?`. On btest-bruby, target Ruby != runner Ruby. + ENV.fetch('RUN_OPTS', '').include?('rjit') +end + exit main diff --git a/bootstraptest/test_gc.rb b/bootstraptest/test_gc.rb index 9f17e1481405c8..17bc49782237b0 100644 --- a/bootstraptest/test_gc.rb +++ b/bootstraptest/test_gc.rb @@ -14,7 +14,7 @@ o.send(meth) end end -}, '[ruby-dev:39453]' unless ENV.fetch('RUN_OPTS', '').include?('rjit') # speed up RJIT CI +}, '[ruby-dev:39453]' unless rjit_enabled? # speed up RJIT CI assert_normal_exit %q{ a = [] diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index 18b4fcd2e99263..a4d46e2f1018e7 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -293,7 +293,6 @@ exec "/" } -rjit_enabled = RUBY_DESCRIPTION.include?('+RJIT') assert_normal_exit %q{ (0..10).map { Thread.new { @@ -304,7 +303,7 @@ }.each {|t| t.join } -} unless rjit_enabled # flaky +} unless rjit_enabled? # flaky assert_equal 'ok', %q{ def m @@ -498,7 +497,7 @@ def m [th1, th2].each {|t| t.join } GC.start f.call.source -} unless rjit_enabled # flaky +} unless rjit_enabled? # flaky assert_normal_exit %q{ class C def inspect diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index b9c332b37aed1a..379591641c8db2 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -22,7 +22,7 @@ def test(args) end [test(Array.new 5), test([])] -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # Not yet working on RJIT +} unless rjit_enabled? # Not yet working on RJIT # regression test for arity check with splat and send assert_equal '[:ae, :ae]', %q{ @@ -81,7 +81,7 @@ def foo = yield GC.compact end :ok -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # Not yet working on RJIT +} unless rjit_enabled? # Not yet working on RJIT # regression test for overly generous guard elision assert_equal '[0, :sum, 0, :sum]', %q{ @@ -209,7 +209,7 @@ def extender # Used to crash due to GC run in rb_ensure_iv_list_size() # not marking the newly allocated [:ok]. RegressionTest.new.extender.itself -} unless RUBY_DESCRIPTION.include?('+RJIT') # Skip on RJIT since this uncovers a crash +} unless rjit_enabled? # Skip on RJIT since this uncovers a crash assert_equal 'true', %q{ # regression test for tracking type of locals for too long @@ -1960,7 +1960,7 @@ def getbyte(s, i) getbyte("a", 0) [getbyte("a", 0), getbyte("a", 1), getbyte("a", -1), getbyte("a", -2), getbyte("a", "a")] -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # Not yet working on RJIT +} unless rjit_enabled? # Not yet working on RJIT # Test << operator on string subclass assert_equal 'abab', %q{ @@ -2604,7 +2604,7 @@ def events.compiled(obj) events.compiled(events) events -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods +} unless rjit_enabled? # RJIT calls extra Ruby methods # test enabling a TracePoint that targets a particular line in a C method call assert_equal '[true]', %q{ @@ -2686,7 +2686,7 @@ def shouldnt_compile tp.enable { shouldnt_compile } events -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods +} unless rjit_enabled? # RJIT calls extra Ruby methods # test enabling c_return tracing before compiling assert_equal '[[:c_return, :itself, main]]', %q{ @@ -2701,7 +2701,7 @@ def shouldnt_compile tp.enable { shouldnt_compile } events -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # RJIT calls extra Ruby methods +} unless rjit_enabled? # RJIT calls extra Ruby methods # test c_call invalidation assert_equal '[[:c_call, :itself]]', %q{ @@ -4223,7 +4223,7 @@ def calling_func rescue ArgumentError true end -} unless defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # Not yet working on RJIT +} unless rjit_enabled? # Not yet working on RJIT # Regresssion test: register allocator on expandarray assert_equal '[]', %q{