Rename --jit to --mjit (#5248)

* Rename --jit to --mjit

[Feature #18349]

* Fix a few more --jit references

* Fix MJIT Actions

* More s/jit/mjit/ and re-introduce --disable-jit

* Update NEWS.md

* Fix test_bug_reporter_add
This commit is contained in:
Takashi Kokubun 2021-12-13 16:08:01 -08:00 committed by GitHub
parent 94494a565d
commit 11b8aaa26a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-12-14 09:08:31 +09:00
Merged-By: k0kubun <takashikkbn@gmail.com>
16 changed files with 111 additions and 64 deletions

View file

@ -7,7 +7,7 @@ class TestBugReporter < Test::Unit::TestCase
skip if ENV['RUBY_ON_BUG']
description = RUBY_DESCRIPTION
description = description.sub(/\+JIT /, '') if defined?(RubyVM::JIT) && RubyVM::JIT.enabled?
description = description.sub(/\+MJIT /, '') if defined?(RubyVM::JIT) && RubyVM::JIT.enabled?
description = description.sub(/\+YJIT /, '') if defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled?
expected_stderr = [
:*,

View file

@ -21,7 +21,7 @@ module JITSupport
]
module_function
# Run Ruby script with --jit-wait (Synchronous JIT compilation).
# Run Ruby script with --mjit-wait (Synchronous JIT compilation).
# Returns [stdout, stderr]
def eval_with_jit(env = nil, script, **opts)
stdout, stderr = nil, nil
@ -36,13 +36,13 @@ module JITSupport
def eval_with_jit_without_retry(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, max_cache: 1000, wait: true, timeout: JIT_TIMEOUT)
args = [
'--disable-gems', "--jit-verbose=#{verbose}",
"--jit-min-calls=#{min_calls}", "--jit-max-cache=#{max_cache}",
'--disable-gems', "--mjit-verbose=#{verbose}",
"--mjit-min-calls=#{min_calls}", "--mjit-max-cache=#{max_cache}",
]
args << '--disable-yjit'
args << '--jit-wait' if wait
args << '--jit-save-temps' if save_temps
args << '--jit-debug' if defined?(@jit_debug) && @jit_debug
args << '--mjit-wait' if wait
args << '--mjit-save-temps' if save_temps
args << '--mjit-debug' if defined?(@mjit_debug) && @mjit_debug
args << '-e' << script
base_env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' } # workaround to skip requiring `make install` for `make test-all`
if preloadenv = RbConfig::CONFIG['PRELOADENV'] and !preloadenv.empty?

View file

@ -1194,8 +1194,8 @@ class TestJIT < Test::Unit::TestCase
out, err = eval_with_jit(script, verbose: 1, min_calls: min_calls, max_cache: max_cache)
success_actual = err.scan(/^#{JIT_SUCCESS_PREFIX}:/).size
recompile_actual = err.scan(/^#{JIT_RECOMPILE_PREFIX}:/).size
# Add --jit-verbose=2 logs for cl.exe because compiler's error message is suppressed
# for cl.exe with --jit-verbose=1. See `start_process` in mjit_worker.c.
# Add --mjit-verbose=2 logs for cl.exe because compiler's error message is suppressed
# for cl.exe with --mjit-verbose=1. See `start_process` in mjit_worker.c.
if RUBY_PLATFORM.match?(/mswin/) && success_count != success_actual
out2, err2 = eval_with_jit(script, verbose: 2, min_calls: min_calls, max_cache: max_cache)
end

View file

@ -11,7 +11,7 @@ class TestJITDebug < TestJIT
def setup
super
# let `#eval_with_jit` use --jit-debug
@jit_debug = true
# let `#eval_with_jit` use --mjit-debug
@mjit_debug = true
end
end

View file

@ -11,7 +11,7 @@ class TestRubyOptions < Test::Unit::TestCase
NO_JIT_DESCRIPTION =
if defined?(RubyVM::JIT) && RubyVM::JIT.enabled? # checking -DMJIT_FORCE_ENABLE
RUBY_DESCRIPTION.sub(/\+JIT /, '')
RUBY_DESCRIPTION.sub(/\+MJIT /, '')
elsif yjit_enabled? # checking -DYJIT_FORCE_ENABLE
RUBY_DESCRIPTION.sub(/\+YJIT /, '')
else
@ -137,7 +137,7 @@ class TestRubyOptions < Test::Unit::TestCase
VERSION_PATTERN_WITH_JIT =
case RUBY_ENGINE
when 'ruby'
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+JIT \[#{q[RUBY_PLATFORM]}\]$/
/^ruby #{q[RUBY_VERSION]}(?:[p ]|dev|rc).*? \+MJIT \[#{q[RUBY_PLATFORM]}\]$/
else
VERSION_PATTERN
end
@ -226,9 +226,14 @@ class TestRubyOptions < Test::Unit::TestCase
return if yjit_force_enabled?
[
%w(--version --jit --disable=jit),
%w(--version --enable=jit --disable=jit),
%w(--version --enable-jit --disable-jit),
%w(--version --mjit --disable=mjit),
%w(--version --enable=mjit --disable=mjit),
%w(--version --enable-mjit --disable-mjit),
*([
%w(--version --jit --disable=jit),
%w(--version --enable=jit --disable=jit),
%w(--version --enable-jit --disable-jit),
] unless RUBY_PLATFORM.start_with?('x86_64-') && RUBY_PLATFORM !~ /mswin|mingw|msys/),
].each do |args|
assert_in_out_err([env] + args) do |r, e|
assert_match(VERSION_PATTERN, r[0])
@ -239,16 +244,21 @@ class TestRubyOptions < Test::Unit::TestCase
if JITSupport.supported?
[
%w(--version --jit),
%w(--version --enable=jit),
%w(--version --enable-jit),
%w(--version --mjit),
%w(--version --enable=mjit),
%w(--version --enable-mjit),
*([
%w(--version --jit),
%w(--version --enable=jit),
%w(--version --enable-jit),
] unless RUBY_PLATFORM.start_with?('x86_64-') && RUBY_PLATFORM !~ /mswin|mingw|msys/),
].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
assert_equal(RUBY_DESCRIPTION, r[0])
else
assert_equal(EnvUtil.invoke_ruby([env, '--jit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
assert_equal(EnvUtil.invoke_ruby([env, '--mjit', '-e', 'print RUBY_DESCRIPTION'], '', true).first, r[0])
end
assert_equal([], e)
end
@ -1113,7 +1123,7 @@ class TestRubyOptions < Test::Unit::TestCase
# mswin uses prebuilt precompiled header. Thus it does not show a pch compilation log to check "-O0 -O1".
if JITSupport.supported? && !RUBY_PLATFORM.match?(/mswin/)
env = { 'MJIT_SEARCH_BUILD_DIR' => 'true' }
assert_in_out_err([env, "--disable-yjit", "--jit-debug=-O0 -O1", "--jit-verbose=2", "" ], "", [], /-O0 -O1/)
assert_in_out_err([env, "--disable-yjit", "--mjit-debug=-O0 -O1", "--mjit-verbose=2", "" ], "", [], /-O0 -O1/)
end
end

View file

@ -21,6 +21,15 @@ class TestYJIT < Test::Unit::TestCase
%w(--version --disable=yjit --yjit),
%w(--version --disable=yjit --enable-yjit),
%w(--version --disable=yjit --enable=yjit),
*([
%w(--version --jit),
%w(--version --disable-jit --jit),
%w(--version --disable-jit --enable-jit),
%w(--version --disable-jit --enable=jit),
%w(--version --disable=jit --yjit),
%w(--version --disable=jit --enable-jit),
%w(--version --disable=jit --enable=jit),
] if RUBY_PLATFORM.start_with?('x86_64-') && RUBY_PLATFORM !~ /mswin|mingw|msys/),
].each do |version_args|
assert_in_out_err(version_args) do |stdout, stderr|
assert_equal(RUBY_DESCRIPTION, stdout.first)