ruby-changes:71912
From: Takashi <ko1@a...>
Date: Sat, 21 May 2022 13:33:54 +0900 (JST)
Subject: [ruby-changes:71912] ead96e7b44 (master): Rename test_jit to test_mjit
https://git.ruby-lang.org/ruby.git/commit/?id=ead96e7b44 From ead96e7b44b98bef4896d836239345012821f1d2 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Fri, 20 May 2022 21:31:00 -0700 Subject: Rename test_jit to test_mjit to avoid confusion with YJIT --- .github/workflows/compilers.yml | 4 +- test/ruby/test_jit.rb | 1273 --------------------------------------- test/ruby/test_jit_debug.rb | 17 - test/ruby/test_mjit.rb | 1273 +++++++++++++++++++++++++++++++++++++++ test/ruby/test_mjit_debug.rb | 17 + test/ruby/test_rubyoptions.rb | 2 +- test/ruby/test_rubyvm_jit.rb | 91 --- test/ruby/test_rubyvm_mjit.rb | 91 +++ test/ruby/test_yjit.rb | 2 +- tool/lib/test/unit.rb | 12 +- 10 files changed, 1391 insertions(+), 1391 deletions(-) delete mode 100644 test/ruby/test_jit.rb delete mode 100644 test/ruby/test_jit_debug.rb create mode 100644 test/ruby/test_mjit.rb create mode 100644 test/ruby/test_mjit_debug.rb delete mode 100644 test/ruby/test_rubyvm_jit.rb create mode 100644 test/ruby/test_rubyvm_mjit.rb diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml index 886cbd3cd1..ee7f9293d1 100644 --- a/.github/workflows/compilers.yml +++ b/.github/workflows/compilers.yml @@ -251,8 +251,8 @@ jobs: https://github.com/ruby/ruby/blob/trunk/.github/workflows/compilers.yml#L251 # FIXME: Skip MJIT tests failing in the annocheck case. # https://bugs.ruby-lang.org/issues/18781 - run: | - rm test/ruby/test_jit.rb - rm test/ruby/test_rubyvm_jit.rb + rm test/ruby/test_mjit.rb + rm test/ruby/test_rubyvm_mjit.rb if: ${{ endsWith(matrix.entry.name, 'annocheck') }} working-directory: src - run: make test-all TESTS='-- ruby -ext-' diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb deleted file mode 100644 index 3e3da24641..0000000000 --- a/test/ruby/test_jit.rb +++ /dev/null @@ -1,1273 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/.github/workflows/compilers.yml#L0 -# frozen_string_literal: true -require 'test/unit' -require 'tmpdir' -require_relative '../lib/jit_support' - -# Test for --jit option -class TestJIT < Test::Unit::TestCase - include JITSupport - - IGNORABLE_PATTERNS = [ - /\AJIT recompile: .+\n\z/, - /\AJIT inline: .+\n\z/, - /\AJIT cancel: .+\n\z/, - /\ASuccessful MJIT finish\n\z/, - ] - MAX_CACHE_PATTERNS = [ - /\AJIT compaction \([^)]+\): .+\n\z/, - /\AToo many JIT code, but skipped unloading units for JIT compaction\n\z/, - /\ANo units can be unloaded -- .+\n\z/, - ] - - # trace_* insns are not compiled for now... - TEST_PENDING_INSNS = RubyVM::INSTRUCTION_NAMES.select { |n| n.start_with?('trace_') }.map(&:to_sym) + [ - # not supported yet - :defineclass, - - # to be tested - :invokebuiltin, - - # never used - :opt_invokebuiltin_delegate, - ].each do |insn| - if !RubyVM::INSTRUCTION_NAMES.include?(insn.to_s) - warn "instruction #{insn.inspect} is not defined but included in TestJIT::TEST_PENDING_INSNS" - end - end - - def self.untested_insns - @untested_insns ||= (RubyVM::INSTRUCTION_NAMES.map(&:to_sym) - TEST_PENDING_INSNS) - end - - def self.setup - return if defined?(@setup_hooked) - @setup_hooked = true - - # ci.rvm.jp caches its build environment. Clean up temporary files left by SEGV. - if ENV['RUBY_DEBUG']&.include?('ci') - Dir.glob("#{ENV.fetch('TMPDIR', '/tmp')}/_ruby_mjit_p*u*.*").each do |file| - puts "test/ruby/test_jit.rb: removing #{file}" - File.unlink(file) - end - end - - # ruby -w -Itest/lib test/ruby/test_jit.rb - if $VERBOSE - pid = $$ - at_exit do - if pid == $$ && !TestJIT.untested_insns.empty? - warn "you may want to add tests for following insns, when you have a chance: #{TestJIT.untested_insns.join(' ')}" - end - end - end - end - - def setup - unless JITSupport.supported? - omit 'JIT seems not supported on this platform' - end - self.class.setup - end - - def test_compile_insn_nop - assert_compile_once('nil rescue true', result_inspect: 'nil', insns: %i[nop]) - end - - def test_compile_insn_local - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[setlocal_WC_0 getlocal_WC_0]) - begin; - foo = 1 - foo - end; - - insns = %i[setlocal getlocal setlocal_WC_0 getlocal_WC_0 setlocal_WC_1 getlocal_WC_1] - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", success_count: 3, stdout: '168', insns: insns) - begin; - def foo - a = 0 - [1, 2].each do |i| - a += i - [3, 4].each do |j| - a *= j - end - end - a - end - - print foo - end; - end - - def test_compile_insn_blockparam - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2, insns: %i[getblockparam setblockparam]) - begin; - def foo(&b) - a = b - b = 2 - a.call + 2 - end - - print foo { 1 } - end; - end - - def test_compile_insn_getblockparamproxy - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '4', success_count: 3, insns: %i[getblockparamproxy]) - begin; - def bar(&b) - b.call - end - - def foo(&b) - bar(&b) * bar(&b) - end - - print foo { 2 } - end; - end - - def test_compile_insn_getspecial - assert_compile_once('$1', result_inspect: 'nil', insns: %i[getspecial]) - end - - def test_compile_insn_setspecial - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: 'true', insns: %i[setspecial]) - begin; - true if nil.nil?..nil.nil? - end; - end - - def test_compile_insn_instancevariable - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getinstancevariable setinstancevariable]) - begin; - @foo = 1 - @foo - end; - - # optimized getinstancevariable call - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '33', success_count: 1, min_calls: 2) - begin; - class A - def initialize - @a = 1 - @b = 2 - end - - def three - @a + @b - end - end - - a = A.new - print(a.three) # set ic - print(a.three) # inlined ic - end; - end - - def test_compile_insn_classvariable - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '1', success_count: 1, insns: %i[getclassvariable setclassvariable]) - begin; - class Foo - def self.foo - @@foo = 1 - @@foo - end - end - - print Foo.foo - end; - end - - def test_compile_insn_constant - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getconstant setconstant]) - begin; - FOO = 1 - FOO - end; - end - - def test_compile_insn_global - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '1', insns: %i[getglobal setglobal]) - begin; - $foo = 1 - $foo - end; - end - - def test_compile_insn_putnil - assert_compile_once('nil', result_inspect: 'nil', insns: %i[putnil]) - end - - def test_compile_insn_putself - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 1, insns: %i[putself]) - begin; - proc { print "hello" }.call - end; - end - - def test_compile_insn_putobject - assert_compile_once('0', result_inspect: '0', insns: %i[putobject_INT2FIX_0_]) - assert_compile_once('1', result_inspect: '1', insns: %i[putobject_INT2FIX_1_]) - assert_compile_once('2', result_inspect: '2', insns: %i[putobject]) - end - - def test_compile_insn_definemethod_definesmethod - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'helloworld', success_count: 3, insns: %i[definemethod definesmethod]) - begin; - print 1.times.map { - def method_definition - 'hello' - end - - def self.smethod_definition - 'world' - end - - method_definition + smethod_definition - }.join - end; - end - - def test_compile_insn_putspecialobject - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'a', success_count: 2, insns: %i[putspecialobject]) - begin; - print 1.times.map { - def a - 'a' - end - - alias :b :a - - b - }.join - end; - end - - def test_compile_insn_putstring_concatstrings_objtostring - assert_compile_once('"a#{}b" + "c"', result_inspect: '"abc"', insns: %i[putstring concatstrings objtostring]) - end - - def test_compile_insn_toregexp - assert_compile_once('/#{true}/ =~ "true"', result_inspect: '0', insns: %i[toregexp]) - end - - def test_compile_insn_newarray - assert_compile_once("#{<<~"begin;"}\n#{<<~"end;"}", result_inspect: '[1, 2, 3]', insns: %i[newarray]) - begin; - a, b, c = 1, 2, 3 - [a, b, c] - end; - end - - def test_compile_insn_newarraykwsplat - assert_compile_once('[**{ x: 1 }]', result_inspect: '[{:x=>1}]', insns: %i[newarraykwsplat]) - end - - def test_compile_insn_intern_duparray - assert_compile_once('[:"#{0}"] + [1,2,3]', result_inspect: '[:"0", 1, 2, 3]', insns: %i[intern duparray]) - end - - def test_compile_insn_expandarray - assert_compile_once('y = [ true, false, nil ]; x, = y; x', result_inspect: 'true', insns: %i[expandarray]) - end - - def test_compile_insn_concatarray - assert_compile_once('["t", "r", *x = "u", "e"].join', result_inspect: '"true"', insns: %i[concatarray]) - end - - def test_compile_insn_splatarray - assert_compile_once('[*(1..2)]', result_inspect: '[1, 2]', insns: %i[splatarray]) - end - - def test_compile_insn_newhash - assert_compile_once('a = 1; { a: a }', result_inspect: '{:a=>1}', insns: %i[newhash]) - end - - def test_compile_insn_duphash - assert_compile_once('{ a: 1 (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/