From 1a63468831524f68e73cbb068071652c6486cfc6 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 13 Dec 2021 23:07:46 -0800 Subject: [PATCH] Prepare for removing RubyVM::JIT (#5262) --- NEWS.md | 2 -- benchmark/lib/benchmark_driver/runner/mjit.rb | 8 +++---- .../lib/benchmark_driver/runner/mjit_exec.rb | 6 ++--- bootstraptest/runner.rb | 2 +- spec/ruby/core/io/flush_spec.rb | 2 +- spec/ruby/core/io/shared/write.rb | 2 +- template/fake.rb.in | 2 +- test/-ext-/bug_reporter/test_bug_reporter.rb | 2 +- test/csv/parse/test_general.rb | 2 +- test/drb/drbtest.rb | 2 +- test/lib/jit_support.rb | 2 +- test/net/http/test_httpresponse.rb | 2 +- test/reline/test_within_pipe.rb | 2 +- test/rinda/test_rinda.rb | 4 ++-- 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 | 24 +++++++++---------- test/ruby/test_settracefunc.rb | 2 +- test/ruby/test_thread.rb | 4 ++-- test/rubygems/test_gem_stream_ui.rb | 2 +- test/socket/test_socket.rb | 2 +- tool/lib/core_assertions.rb | 2 +- tool/lib/test/unit.rb | 2 +- tool/test/testunit/test_hideskip.rb | 2 +- tool/test/testunit/test_parallel.rb | 2 +- tool/test/webrick/test_httpserver.rb | 2 +- tool/test/webrick/test_server.rb | 2 +- vm.c | 23 +++++++++--------- 32 files changed, 64 insertions(+), 67 deletions(-) diff --git a/NEWS.md b/NEWS.md index c031add926..7da190b215 100644 --- a/NEWS.md +++ b/NEWS.md @@ -437,8 +437,6 @@ Excluding feature bug fixes. * `--mjit-verbose` and `--mjit-warning` output "JIT cancel" when JIT-ed code is disabled because TracePoint or GC.compact is used. -* `RubyVM::MJIT` is renamed to `RubyVM::JIT`. [[Feature #17490]] - ### YJIT: New experimental in-process JIT compiler New JIT compiler available as an experimental feature. [[Feature #18229]] diff --git a/benchmark/lib/benchmark_driver/runner/mjit.rb b/benchmark/lib/benchmark_driver/runner/mjit.rb index abefa463b3..1d4693e8be 100644 --- a/benchmark/lib/benchmark_driver/runner/mjit.rb +++ b/benchmark/lib/benchmark_driver/runner/mjit.rb @@ -14,17 +14,17 @@ class BenchmarkDriver::Runner::Mjit < BenchmarkDriver::Runner::Ips jobs.map do |job| job = job.dup job.prelude = "#{job.prelude}\n#{<<~EOS}" - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? __bmdv_ruby_i = 0 while __bmdv_ruby_i < 10000 # jit_min_calls #{job.script} __bmdv_ruby_i += 1 end - RubyVM::JIT.pause # compile + RubyVM::MJIT.pause # compile #{job.script} - RubyVM::JIT.resume; RubyVM::JIT.pause # recompile + RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile #{job.script} - RubyVM::JIT.resume; RubyVM::JIT.pause # recompile 2 + RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile 2 end EOS job diff --git a/benchmark/lib/benchmark_driver/runner/mjit_exec.rb b/benchmark/lib/benchmark_driver/runner/mjit_exec.rb index 46e662bc7c..eac3dfba84 100644 --- a/benchmark/lib/benchmark_driver/runner/mjit_exec.rb +++ b/benchmark/lib/benchmark_driver/runner/mjit_exec.rb @@ -135,7 +135,7 @@ class BenchmarkDriver::Runner::MjitExec nil end % end - RubyVM::JIT.pause if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + RubyVM::MJIT.pause if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? def vm t = Process.clock_gettime(Process::CLOCK_MONOTONIC) @@ -172,7 +172,7 @@ class BenchmarkDriver::Runner::MjitExec a<%= i %> a<%= i %> # --jit-min-calls=2 % end - RubyVM::JIT.pause if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + RubyVM::MJIT.pause if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? def vm t = Process.clock_gettime(Process::CLOCK_MONOTONIC) @@ -228,7 +228,7 @@ class BenchmarkDriver::Runner::MjitExec jit jit - RubyVM::JIT.pause if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + RubyVM::MJIT.pause if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? File.write(<%= result.dump %>, jit) EOS end diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb index 11d5a6c17e..2cd91ffd07 100755 --- a/bootstraptest/runner.rb +++ b/bootstraptest/runner.rb @@ -383,7 +383,7 @@ def assert_normal_exit(testsrc, *rest, timeout: nil, **opt) end def assert_finish(timeout_seconds, testsrc, message = '') - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # for --jit-wait + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait timeout_seconds *= 3 end newtest diff --git a/spec/ruby/core/io/flush_spec.rb b/spec/ruby/core/io/flush_spec.rb index 8de373a0bd..34cf42c425 100644 --- a/spec/ruby/core/io/flush_spec.rb +++ b/spec/ruby/core/io/flush_spec.rb @@ -23,7 +23,7 @@ describe "IO#flush" do # For instance, MJIT creates a worker before @r.close with fork(), @r.close happens, # and the MJIT worker keeps the pipe open until the worker execve(). # TODO: consider acquiring GVL from MJIT worker. - guard_not -> { defined?(RubyVM::JIT) && RubyVM::JIT.enabled? } do + guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do it "raises Errno::EPIPE if sync=false and the read end is closed" do @w.sync = false @w.write "foo" diff --git a/spec/ruby/core/io/shared/write.rb b/spec/ruby/core/io/shared/write.rb index 5e53d981c5..270b84ac39 100644 --- a/spec/ruby/core/io/shared/write.rb +++ b/spec/ruby/core/io/shared/write.rb @@ -99,7 +99,7 @@ describe :io_write, shared: true do # For instance, MJIT creates a worker before @r.close with fork(), @r.close happens, # and the MJIT worker keeps the pipe open until the worker execve(). # TODO: consider acquiring GVL from MJIT worker. - guard_not -> { defined?(RubyVM::JIT) && RubyVM::JIT.enabled? } do + guard_not -> { defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? } do it "raises Errno::EPIPE if the read end is closed and does not die from SIGPIPE" do @r.close -> { @w.send(@method, "foo") }.should raise_error(Errno::EPIPE, /Broken pipe/) diff --git a/template/fake.rb.in b/template/fake.rb.in index 63ddad3e98..2280a4d8e7 100644 --- a/template/fake.rb.in +++ b/template/fake.rb.in @@ -32,7 +32,7 @@ class Object CROSS_COMPILING = RUBY_PLATFORM constants.grep(/^RUBY_/) {|n| remove_const n} % arg['versions'].each {|n, v| - <%=n%> = <%if n=='RUBY_DESCRIPTION' %>RubyVM.const_defined?(:JIT) && RubyVM::JIT.enabled? ? + <%=n%> = <%if n=='RUBY_DESCRIPTION' %>RubyVM.const_defined?(:JIT) && RubyVM::MJIT.enabled? ? <%=arg['RUBY_DESCRIPTION_WITH_JIT'].inspect%> : <%end%><%=v.inspect%> % } diff --git a/test/-ext-/bug_reporter/test_bug_reporter.rb b/test/-ext-/bug_reporter/test_bug_reporter.rb index 6aa294bc5e..569172d42c 100644 --- a/test/-ext-/bug_reporter/test_bug_reporter.rb +++ b/test/-ext-/bug_reporter/test_bug_reporter.rb @@ -7,7 +7,7 @@ class TestBugReporter < Test::Unit::TestCase skip if ENV['RUBY_ON_BUG'] description = RUBY_DESCRIPTION - description = description.sub(/\+MJIT /, '') if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + description = description.sub(/\+MJIT /, '') if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? description = description.sub(/\+YJIT /, '') if defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? expected_stderr = [ :*, diff --git a/test/csv/parse/test_general.rb b/test/csv/parse/test_general.rb index 14903d462c..52b0cab000 100644 --- a/test/csv/parse/test_general.rb +++ b/test/csv/parse/test_general.rb @@ -247,7 +247,7 @@ line,5,jkl def assert_parse_errors_out(data, **options) assert_raise(CSV::MalformedCSVError) do timeout = 0.2 - if defined?(RubyVM::JIT.enabled?) and RubyVM::JIT.enabled? + if defined?(RubyVM::MJIT.enabled?) and RubyVM::MJIT.enabled? timeout = 5 # for --jit-wait end Timeout.timeout(timeout) do diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb index f3d20201bc..3c33aedb6f 100644 --- a/test/drb/drbtest.rb +++ b/test/drb/drbtest.rb @@ -216,7 +216,7 @@ module DRbCore def test_06_timeout omit if RUBY_PLATFORM.include?("armv7l-linux") omit if RUBY_PLATFORM.include?("sparc-solaris2.10") - omit if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # expecting a certain delay is difficult for --jit-wait CI + omit if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # expecting a certain delay is difficult for --jit-wait CI Timeout.timeout(60) do ten = Onecky.new(10) assert_raise(Timeout::Error) do diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index b66987fe92..6ad68f75be 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -75,7 +75,7 @@ module JITSupport end def remove_mjit_logs(stderr) - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # utility for -DFORCE_MJIT_ENABLE + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # utility for -DFORCE_MJIT_ENABLE stderr.gsub(/^MJIT warning: Skipped to compile unsupported instruction: \w+\n/m, '') else stderr diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb index 00b0072e70..1a78907284 100644 --- a/test/net/http/test_httpresponse.rb +++ b/test/net/http/test_httpresponse.rb @@ -78,7 +78,7 @@ EOS def test_read_body_block_mod # http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/3019353 - if defined?(RubyVM::JIT) ? RubyVM::JIT.enabled? : defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + if defined?(RubyVM::MJIT) ? RubyVM::MJIT.enabled? : defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? omit 'too unstable with --jit-wait, and extending read_timeout did not help it' end IO.pipe do |r, w| diff --git a/test/reline/test_within_pipe.rb b/test/reline/test_within_pipe.rb index ff2d68bb82..43a66f45f4 100644 --- a/test/reline/test_within_pipe.rb +++ b/test/reline/test_within_pipe.rb @@ -9,7 +9,7 @@ class Reline::WithinPipeTest < Reline::TestCase @reader, @output_writer = IO.pipe(@encoding) @output = Reline.output = @output_writer @config = Reline.send(:core).config - @config.keyseq_timeout *= 600 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # for --jit-wait CI + @config.keyseq_timeout *= 600 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait CI @line_editor = Reline.send(:core).line_editor end diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index f155e88de1..00e1ba7877 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -402,7 +402,7 @@ module TupleSpaceTestModule end def test_cancel_02 - skip 'this test is unstable with --jit-wait' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + skip 'this test is unstable with --jit-wait' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? entry = @ts.write([:removeme, 1]) assert_equal([[:removeme, 1]], @ts.read_all([nil, nil])) entry.cancel @@ -662,7 +662,7 @@ class TestRingServer < Test::Unit::TestCase end def test_do_reply_local - skip 'timeout-based test becomes unstable with --jit-wait' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + skip 'timeout-based test becomes unstable with --jit-wait' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? with_timeout(30) {_test_do_reply_local} end diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index a0fd4a7491..3aad5dd09c 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::JIT) && RubyVM::JIT.enabled? + skip 'This is unstable on GitHub Actions --jit-wait. TODO: debug it' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? max = 1000 assert_equal(max, max.times{ Fiber.new{} diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 71a8911fbd..b46777df5f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -655,7 +655,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::JIT) && RubyVM::JIT.enabled? + skip "MJIT has busy wait on GC. This sometimes fails with --jit." if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? skip "multiple threads already active" if Thread.list.size > 1 msg = 'r58534 [ruby-core:80969] [Backport #13533]' @@ -1610,7 +1610,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::JIT) && RubyVM::JIT.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::MJIT) && RubyVM::MJIT.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!" @@ -2258,7 +2258,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::JIT) && RubyVM::JIT.enabled? + skip 'this randomly fails with MJIT' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? feature2250 = '[ruby-core:26222]' pre = 'ft2250' diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 50ef1195d5..07ac76210d 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -1108,7 +1108,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::JIT.pause + RubyVM::MJIT.pause proc {}.call end; end diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index a834996788..43795d150c 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -510,7 +510,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::JIT) && RubyVM::JIT.enabled? + skip 'currently JIT-ed code always creates a new stack frame' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? bug16161 = '[ruby-core:94881]' tailcall("#{<<-"begin;"}\n#{<<~"end;"}") diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 636871f822..bd2413b74c 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1718,7 +1718,7 @@ class TestProcess < Test::Unit::TestCase Process.wait pid assert_send [sig_r, :wait_readable, 5], 'self-pipe not readable' end - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE. It may trigger extra SIGCHLD. + if defined?(RubyVM::MJIT) && RubyVM::MJIT.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 f6c8b4f859..5018a38152 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -10,7 +10,7 @@ class TestRubyOptions < Test::Unit::TestCase def self.yjit_enabled? = defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? NO_JIT_DESCRIPTION = - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE RUBY_DESCRIPTION.sub(/\+MJIT /, '') elsif yjit_enabled? # checking -DYJIT_FORCE_ENABLE RUBY_DESCRIPTION.sub(/\+YJIT /, '') @@ -146,7 +146,7 @@ class TestRubyOptions < Test::Unit::TestCase def test_verbose assert_in_out_err([{'RUBY_YJIT_ENABLE' => nil}, "-vve", ""]) do |r, e| assert_match(VERSION_PATTERN, r[0]) - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? && !mjit_force_enabled? # checking -DMJIT_FORCE_ENABLE assert_equal(NO_JIT_DESCRIPTION, r[0]) elsif self.class.yjit_enabled? && !yjit_force_enabled? # checking -DYJIT_FORCE_ENABLE assert_equal(NO_JIT_DESCRIPTION, r[0]) @@ -214,7 +214,7 @@ class TestRubyOptions < Test::Unit::TestCase assert_match(VERSION_PATTERN, r[0]) if ENV['RUBY_YJIT_ENABLE'] == '1' assert_equal(NO_JIT_DESCRIPTION, r[0]) - elsif defined?(RubyVM::JIT) && RubyVM::JIT.enabled? || self.class.yjit_enabled? # checking -D(M|Y)JIT_FORCE_ENABLE + elsif defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? || self.class.yjit_enabled? # checking -D(M|Y)JIT_FORCE_ENABLE assert_equal(EnvUtil.invoke_ruby(['-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0]) else assert_equal(RUBY_DESCRIPTION, r[0]) @@ -255,7 +255,7 @@ class TestRubyOptions < Test::Unit::TestCase ].each do |args| assert_in_out_err([env] + args) do |r, e| assert_match(VERSION_PATTERN_WITH_JIT, r[0]) - if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE + if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # checking -DMJIT_FORCE_ENABLE assert_equal(RUBY_DESCRIPTION, r[0]) else assert_equal(EnvUtil.invoke_ruby([env, '--mjit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0]) diff --git a/test/ruby/test_rubyvm_jit.rb b/test/ruby/test_rubyvm_jit.rb index 2104ce3d18..a3558d791c 100644 --- a/test/ruby/test_rubyvm_jit.rb +++ b/test/ruby/test_rubyvm_jit.rb @@ -20,13 +20,13 @@ class TestRubyVMJIT < Test::Unit::TestCase eval("def mjit#{i}; end; mjit#{i}") i += 1 end - print RubyVM::JIT.pause - print RubyVM::JIT.pause + print RubyVM::MJIT.pause + print RubyVM::MJIT.pause while i < 10 eval("def mjit#{i}; end; mjit#{i}") i += 1 end - print RubyVM::JIT.pause # no JIT here + print RubyVM::MJIT.pause # no JIT here EOS assert_equal('truefalsefalse', out) assert_equal( @@ -39,7 +39,7 @@ class TestRubyVMJIT < Test::Unit::TestCase out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false) def a() end; a def b() end; b - RubyVM::JIT.pause + RubyVM::MJIT.pause EOS assert_equal( 2, err.scan(/#{JITSupport::JIT_SUCCESS_PREFIX}/).size, @@ -58,7 +58,7 @@ class TestRubyVMJIT < Test::Unit::TestCase eval("def mjit#{i}; end; mjit#{i}") i += 1 end - print RubyVM::JIT.pause + print RubyVM::MJIT.pause EOS assert_equal('true', out) end @@ -70,8 +70,8 @@ class TestRubyVMJIT < Test::Unit::TestCase eval("def mjit#{i}; end; mjit#{i}") i += 1 end - print RubyVM::JIT.pause(wait: false) - print RubyVM::JIT.pause(wait: false) + 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) @@ -79,11 +79,11 @@ class TestRubyVMJIT < Test::Unit::TestCase 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 + 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) diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index f623d87506..c25debb38e 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2106,7 +2106,7 @@ CODE 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::JIT) && RubyVM::JIT.enabled? + sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.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 7b37aeb202..ddfeb8b7a8 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -317,7 +317,7 @@ class TestThread < Test::Unit::TestCase s += 1 end Thread.pass until t.stop? - sleep 1 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # t.stop? behaves unexpectedly with --jit-wait + sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # t.stop? behaves unexpectedly with --jit-wait assert_equal(1, s) t.wakeup Thread.pass while t.alive? @@ -1369,7 +1369,7 @@ q.pop opts = { timeout: 5, timeout_error: nil } # prevent SIGABRT from slow shutdown with MJIT - opts[:reprieve] = 3 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + opts[:reprieve] = 3 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? assert_normal_exit(<<-_end, '[Bug #8996]', **opts) Thread.report_on_exception = false diff --git a/test/rubygems/test_gem_stream_ui.rb b/test/rubygems/test_gem_stream_ui.rb index dc245c342a..2071526dfa 100644 --- a/test/rubygems/test_gem_stream_ui.rb +++ b/test/rubygems/test_gem_stream_ui.rb @@ -5,7 +5,7 @@ require 'timeout' class TestGemStreamUI < Gem::TestCase # increase timeout with MJIT for --jit-wait testing - mjit_enabled = defined?(RubyVM::JIT) ? RubyVM::JIT.enabled? : defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? + mjit_enabled = defined?(RubyVM::MJIT) ? RubyVM::MJIT.enabled? : defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? SHORT_TIMEOUT = (RUBY_ENGINE == "ruby" && !mjit_enabled) ? 0.1 : 1.0 module IsTty diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index 16c359eca1..7e596f0299 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -486,7 +486,7 @@ class TestSocket < Test::Unit::TestCase end while IO.select([r], nil, nil, 0.1).nil? n end - timeout = (defined?(RubyVM::JIT) && RubyVM::JIT.enabled? ? 120 : 30) # for --jit-wait + timeout = (defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? ? 120 : 30) # for --jit-wait assert_equal([[s1],[],[]], IO.select([s1], nil, nil, timeout)) msg, _, _, stamp = s1.recvmsg assert_equal("a", msg) diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb index 3cc1ea11b5..9adc936ad8 100644 --- a/tool/lib/core_assertions.rb +++ b/tool/lib/core_assertions.rb @@ -108,7 +108,7 @@ module Test def assert_no_memory_leak(args, prepare, code, message=nil, limit: 2.0, rss: false, **opt) # TODO: consider choosing some appropriate limit for MJIT and stop skipping this once it does not randomly fail - pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + pend 'assert_no_memory_leak may consider MJIT memory usage as leak' if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? require_relative 'memory_status' raise Test::Unit::PendedError, "unsupported platform" unless defined?(Memory::Status) diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb index 80851eed16..3bb2692b43 100644 --- a/tool/lib/test/unit.rb +++ b/tool/lib/test/unit.rb @@ -1533,7 +1533,7 @@ module Test puts if @verbose $stdout.flush - unless defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # compiler process is wrongly considered as leak + unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # compiler process is wrongly considered as leak leakchecker.check("#{inst.class}\##{inst.__name__}") end diff --git a/tool/test/testunit/test_hideskip.rb b/tool/test/testunit/test_hideskip.rb index e90be5da32..13d887189e 100644 --- a/tool/test/testunit/test_hideskip.rb +++ b/tool/test/testunit/test_hideskip.rb @@ -6,7 +6,7 @@ class TestHideSkip < Test::Unit::TestCase assert_not_match(/^ *1\) Skipped/, hideskip) assert_match(/^ *1\) Skipped/, hideskip("--show-skip")) output = hideskip("--hide-skip") - output.gsub!(/Successful MJIT finish\n/, '') if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? + output.gsub!(/Successful MJIT finish\n/, '') if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? assert_match(/assertions\/s.\n+1 tests, 0 assertions, 0 failures, 0 errors, 1 skips/, output) end diff --git a/tool/test/testunit/test_parallel.rb b/tool/test/testunit/test_parallel.rb index 56ebb7df90..006354aee2 100644 --- a/tool/test/testunit/test_parallel.rb +++ b/tool/test/testunit/test_parallel.rb @@ -6,7 +6,7 @@ module TestParallel PARALLEL_RB = "#{__dir__}/../../lib/test/unit/parallel.rb" TESTS = "#{__dir__}/tests_for_parallel" # use large timeout for --jit-wait - TIMEOUT = EnvUtil.apply_timeout_scale(defined?(RubyVM::JIT) && RubyVM::JIT.enabled? ? 100 : 30) + TIMEOUT = EnvUtil.apply_timeout_scale(defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? ? 100 : 30) class TestParallelWorker < Test::Unit::TestCase def setup diff --git a/tool/test/webrick/test_httpserver.rb b/tool/test/webrick/test_httpserver.rb index f905ff04e8..4133be85ad 100644 --- a/tool/test/webrick/test_httpserver.rb +++ b/tool/test/webrick/test_httpserver.rb @@ -253,7 +253,7 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase server.virtual_host(WEBrick::HTTPServer.new(vhost_config)) Thread.pass while server.status != :Running - sleep 1 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # server.status behaves unexpectedly with --jit-wait + sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # server.status behaves unexpectedly with --jit-wait assert_equal(1, started, log.call) assert_equal(0, stopped, log.call) assert_equal(0, accepted, log.call) diff --git a/tool/test/webrick/test_server.rb b/tool/test/webrick/test_server.rb index 0fd3f3b63b..815cc3ce39 100644 --- a/tool/test/webrick/test_server.rb +++ b/tool/test/webrick/test_server.rb @@ -65,7 +65,7 @@ class TestWEBrickServer < Test::Unit::TestCase } TestWEBrick.start_server(Echo, config){|server, addr, port, log| true while server.status != :Running - sleep 1 if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # server.status behaves unexpectedly with --jit-wait + sleep 1 if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # server.status behaves unexpectedly with --jit-wait assert_equal(1, started, log.call) assert_equal(0, stopped, log.call) assert_equal(0, accepted, log.call) diff --git a/vm.c b/vm.c index 73d6cd9d5d..44b87c3d54 100644 --- a/vm.c +++ b/vm.c @@ -3261,13 +3261,13 @@ core_hash_merge_kwd(VALUE hash, VALUE kw) /* Returns true if JIT is enabled */ static VALUE -jit_enabled_p(VALUE _) +mjit_enabled_p(VALUE _) { return RBOOL(mjit_enabled); } static VALUE -jit_pause_m(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self)) +mjit_pause_m(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self)) { VALUE options = Qnil; VALUE wait = Qtrue; @@ -3284,7 +3284,7 @@ jit_pause_m(int argc, VALUE *argv, RB_UNUSED_VAR(VALUE self)) } static VALUE -jit_resume_m(VALUE _) +mjit_resume_m(VALUE _) { return mjit_resume(); } @@ -3421,7 +3421,6 @@ Init_VM(void) VALUE opts; VALUE klass; VALUE fcore; - VALUE jit; /* * Document-class: RubyVM @@ -3470,17 +3469,17 @@ Init_VM(void) rb_gc_register_mark_object(fcore); rb_mRubyVMFrozenCore = fcore; - /* ::RubyVM::JIT + /* ::RubyVM::MJIT * Provides access to the Method JIT compiler of MRI. * Of course, this module is MRI specific. */ - jit = rb_define_module_under(rb_cRubyVM, "JIT"); - rb_define_singleton_method(jit, "enabled?", jit_enabled_p, 0); - rb_define_singleton_method(jit, "pause", jit_pause_m, -1); - rb_define_singleton_method(jit, "resume", jit_resume_m, 0); - /* RubyVM::MJIT for short-term backward compatibility */ - rb_const_set(rb_cRubyVM, rb_intern("MJIT"), jit); - rb_deprecate_constant(rb_cRubyVM, "MJIT"); + VALUE mjit = rb_define_module_under(rb_cRubyVM, "MJIT"); + rb_define_singleton_method(mjit, "enabled?", mjit_enabled_p, 0); + rb_define_singleton_method(mjit, "pause", mjit_pause_m, -1); + rb_define_singleton_method(mjit, "resume", mjit_resume_m, 0); + /* RubyVM::JIT for short-term backward compatibility */ + rb_const_set(rb_cRubyVM, rb_intern("JIT"), mjit); + rb_deprecate_constant(rb_cRubyVM, "JIT"); /* * Document-class: Thread