From e1fee7f949cb6719122672fa1081c60984a5339f Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 13 Jan 2021 22:36:45 -0800 Subject: Rename RubyVM::MJIT to RubyVM::JIT because the name "MJIT" is an internal code name, it's inconsistent with --jit while they are related to each other, and I want to discourage future JIT implementation-specific (e.g. MJIT-specific) APIs by this rename. [Feature #17490] --- test/ruby/test_fiber.rb | 2 +- test/ruby/test_io.rb | 6 +-- test/ruby/test_jit.rb | 2 +- test/ruby/test_optimization.rb | 2 +- test/ruby/test_process.rb | 2 +- test/ruby/test_rubyoptions.rb | 8 ++-- test/ruby/test_rubyvm_jit.rb | 91 ++++++++++++++++++++++++++++++++++++++++++ test/ruby/test_rubyvm_mjit.rb | 91 ------------------------------------------ test/ruby/test_settracefunc.rb | 2 +- test/ruby/test_thread.rb | 4 +- 10 files changed, 105 insertions(+), 105 deletions(-) create mode 100644 test/ruby/test_rubyvm_jit.rb delete mode 100644 test/ruby/test_rubyvm_mjit.rb (limited to 'test/ruby') diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index ff4658a20b..a5e35c0fd6 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -34,7 +34,7 @@ class TestFiber < Test::Unit::TestCase end def test_many_fibers - skip 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + skip 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? max = 10_000 assert_equal(max, max.times{ Fiber.new{} diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 9f9318eaf7..42149ac32a 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -607,7 +607,7 @@ class TestIO < Test::Unit::TestCase if have_nonblock? def test_copy_stream_no_busy_wait - skip "MJIT has busy wait on GC. This sometimes fails with --jit." if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + skip "MJIT has busy wait on GC. This sometimes fails with --jit." if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? skip "multiple threads already active" if Thread.list.size > 1 msg = 'r58534 [ruby-core:80969] [Backport #13533]' @@ -1562,7 +1562,7 @@ class TestIO < Test::Unit::TestCase end if have_nonblock? def test_read_nonblock_no_exceptions - skip '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # TODO: consider acquiring GVL from MJIT worker. + skip '[ruby-core:90895] MJIT worker may leave fd open in a forked child' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # TODO: consider acquiring GVL from MJIT worker. with_pipe {|r, w| assert_equal :wait_readable, r.read_nonblock(4096, exception: false) w.puts "HI!" @@ -2210,7 +2210,7 @@ class TestIO < Test::Unit::TestCase def test_autoclose_true_closed_by_finalizer # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1465760 # http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1469765 - skip 'this randomly fails with MJIT' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + skip 'this randomly fails with MJIT' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? feature2250 = '[ruby-core:26222]' pre = 'ft2250' diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 3bc4a871a1..54f9698afa 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -1085,7 +1085,7 @@ class TestJIT < Test::Unit::TestCase def test_mjit_pause_wait assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '', success_count: 0, min_calls: 1) begin; - RubyVM::MJIT.pause + RubyVM::JIT.pause proc {}.call end; end diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index d0790c7463..b0090d654a 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -452,7 +452,7 @@ class TestRubyOptimization < Test::Unit::TestCase end def test_tailcall_not_to_grow_stack - skip 'currently JIT-ed code always creates a new stack frame' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + skip 'currently JIT-ed code always creates a new stack frame' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? bug16161 = '[ruby-core:94881]' tailcall("#{<<-"begin;"}\n#{<<~"end;"}") diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index d1b9d8a478..33144aa62f 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1706,7 +1706,7 @@ class TestProcess < Test::Unit::TestCase Process.wait pid assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable' end - if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD. + if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD. assert_equal [true], signal_received.uniq, "[ruby-core:19744]" else assert_equal [true], signal_received, "[ruby-core:19744]" diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index b7831948f0..d860bf4a15 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -8,7 +8,7 @@ require_relative '../lib/jit_support' class TestRubyOptions < Test::Unit::TestCase NO_JIT_DESCRIPTION = - if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE RUBY_DESCRIPTION.sub(/\+JIT /, '') else RUBY_DESCRIPTION @@ -128,7 +128,7 @@ class TestRubyOptions < Test::Unit::TestCase def test_verbose assert_in_out_err(["-vve", ""]) do |r, e| assert_match(VERSION_PATTERN, r[0]) - if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE assert_equal(NO_JIT_DESCRIPTION, r[0]) else assert_equal(RUBY_DESCRIPTION, r[0]) @@ -191,7 +191,7 @@ class TestRubyOptions < Test::Unit::TestCase def test_version assert_in_out_err(%w(--version)) do |r, e| assert_match(VERSION_PATTERN, r[0]) - if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0]) else assert_equal(RUBY_DESCRIPTION, r[0]) @@ -221,7 +221,7 @@ class TestRubyOptions < Test::Unit::TestCase ].each do |args| assert_in_out_err(args) do |r, e| assert_match(VERSION_PATTERN_WITH_JIT, r[0]) - if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE assert_equal(RUBY_DESCRIPTION, r[0]) else assert_equal(EnvUtil.invoke_ruby(['--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0]) diff --git a/test/ruby/test_rubyvm_jit.rb b/test/ruby/test_rubyvm_jit.rb new file mode 100644 index 0000000000..2104ce3d18 --- /dev/null +++ b/test/ruby/test_rubyvm_jit.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true +require 'test/unit' +require_relative '../lib/jit_support' + +return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no' + +class TestRubyVMJIT < Test::Unit::TestCase + include JITSupport + + def setup + unless JITSupport.supported? + skip 'JIT seems not supported on this platform' + end + end + + def test_pause + out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) + i = 0 + while i < 5 + eval("def mjit#{i}; end; mjit#{i}") + i += 1 + end + print RubyVM::JIT.pause + print RubyVM::JIT.pause + while i < 10 + eval("def mjit#{i}; end; mjit#{i}") + i += 1 + end + print RubyVM::JIT.pause # no JIT here + EOS + assert_equal('truefalsefalse', out) + assert_equal( + 5, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, + "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", + ) + end + + def test_pause_waits_until_compaction + out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) + def a() end; a + def b() end; b + RubyVM::JIT.pause + EOS + assert_equal( + 2, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, + "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", + ) + assert_equal( + 1, err.scan(/#{JITSupport::JIT_COMPACTION_PREFIX}/).size, + "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", + ) unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet + end + + def test_pause_does_not_hang_on_full_units + out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false) + i = 0 + while i < 11 + eval("def mjit#{i}; end; mjit#{i}") + i += 1 + end + print RubyVM::JIT.pause + EOS + assert_equal('true', out) + end + + def test_pause_wait_false + out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) + i = 0 + while i < 10 + eval("def mjit#{i}; end; mjit#{i}") + i += 1 + end + print RubyVM::JIT.pause(wait: false) + print RubyVM::JIT.pause(wait: false) + EOS + assert_equal('truefalse', out) + assert_equal(true, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size < 10) + end + + def test_resume + out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) + print RubyVM::JIT.resume + print RubyVM::JIT.pause + print RubyVM::JIT.resume + print RubyVM::JIT.resume + print RubyVM::JIT.pause + EOS + assert_equal('falsetruetruefalsetrue', out) + assert_equal(0, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size) + end +end diff --git a/test/ruby/test_rubyvm_mjit.rb b/test/ruby/test_rubyvm_mjit.rb deleted file mode 100644 index ef7475670c..0000000000 --- a/test/ruby/test_rubyvm_mjit.rb +++ /dev/null @@ -1,91 +0,0 @@ -# frozen_string_literal: true -require 'test/unit' -require_relative '../lib/jit_support' - -return if RbConfig::CONFIG["MJIT_SUPPORT"] == 'no' - -class TestRubyVMMJIT < Test::Unit::TestCase - include JITSupport - - def setup - unless JITSupport.supported? - skip 'JIT seems not supported on this platform' - end - end - - def test_pause - out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) - i = 0 - while i < 5 - eval("def mjit#{i}; end; mjit#{i}") - i += 1 - end - print RubyVM::MJIT.pause - print RubyVM::MJIT.pause - while i < 10 - eval("def mjit#{i}; end; mjit#{i}") - i += 1 - end - print RubyVM::MJIT.pause # no JIT here - EOS - assert_equal('truefalsefalse', out) - assert_equal( - 5, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, - "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", - ) - end - - def test_pause_waits_until_compaction - out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) - def a() end; a - def b() end; b - RubyVM::MJIT.pause - EOS - assert_equal( - 2, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, - "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", - ) - assert_equal( - 1, err.scan(/#{JITSupport::JIT_COMPACTION_PREFIX}/).size, - "unexpected stdout:\n```\n#{out}```\n\nstderr:\n```\n#{err}```", - ) unless RUBY_PLATFORM.match?(/mswin|mingw/) # compaction is not supported on Windows yet - end - - def test_pause_does_not_hang_on_full_units - out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false) - i = 0 - while i < 11 - eval("def mjit#{i}; end; mjit#{i}") - i += 1 - end - print RubyVM::MJIT.pause - EOS - assert_equal('true', out) - end - - def test_pause_wait_false - out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) - i = 0 - while i < 10 - eval("def mjit#{i}; end; mjit#{i}") - i += 1 - end - print RubyVM::MJIT.pause(wait: false) - print RubyVM::MJIT.pause(wait: false) - EOS - assert_equal('truefalse', out) - assert_equal(true, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size < 10) - end - - def test_resume - out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) - print RubyVM::MJIT.resume - print RubyVM::MJIT.pause - print RubyVM::MJIT.resume - print RubyVM::MJIT.resume - print RubyVM::MJIT.pause - EOS - assert_equal('falsetruetruefalsetrue', out) - assert_equal(0, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size) - end -end diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 7821a221dc..1d16b2e154 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -1963,7 +1963,7 @@ class TestSetTraceFunc < Test::Unit::TestCase Thread.pass until t.status == 'sleep' # When MJIT thread exists, t.status becomes 'sleep' even if it does not reach m2t_q.pop. # This sleep forces it to reach m2t_q.pop for --jit-wait. - sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + sleep 1 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? t.add_trace_func proc{|ev, file, line, *args| if file == __FILE__ diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 3852cb7020..6005e5b001 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -309,7 +309,7 @@ class TestThread < Test::Unit::TestCase s += 1 end Thread.pass until t.stop? - sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # t.stop? behaves unexpectedly with --jit-wait + sleep 1 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # t.stop? behaves unexpectedly with --jit-wait assert_equal(1, s) t.wakeup Thread.pass while t.alive? @@ -1338,7 +1338,7 @@ q.pop opts = { timeout: 5, timeout_error: nil } # prevent SIGABRT from slow shutdown with MJIT - opts[:reprieve] = 3 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + opts[:reprieve] = 3 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? assert_normal_exit(<<-_end, '[Bug #8996]', **opts) Thread.report_on_exception = false -- cgit v1.2.3