ruby-changes:51858
From: k0kubun <ko1@a...>
Date: Fri, 27 Jul 2018 14:52:07 +0900 (JST)
Subject: [ruby-changes:51858] k0kubun:r64072 (trunk): test_jit.rb: test unload_units
k0kubun 2018-07-27 14:52:01 +0900 (Fri, 27 Jul 2018) New Revision: 64072 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64072 Log: test_jit.rb: test unload_units Modified files: trunk/test/lib/jit_support.rb trunk/test/ruby/test_jit.rb Index: test/ruby/test_jit.rb =================================================================== --- test/ruby/test_jit.rb (revision 64071) +++ test/ruby/test_jit.rb (revision 64072) @@ -529,6 +529,29 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L529 assert_match(/^Successful MJIT finish$/, err) end + def test_unload_units + # MIN_CACHE_SIZE is 10 + out, err = eval_with_jit("#{<<~"begin;"}\n#{<<~'end;'}", verbose: 1, min_calls: 1, max_cache: 10) + begin; + 10.times do |i| + eval(<<-EOS) + def mjit#{i} + print #{i} + end + mjit#{i} + EOS + end + end; + assert_equal('0123456789', out) + errs = err.lines + assert_match(/\A#{JIT_SUCCESS_PREFIX}: block in <main>@-e:/, errs[0]) + 9.times do |i| + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit#{i}@\(eval\):/, errs[i + 1]) + end + assert_equal("Too many JIT code -- 1 units unloaded\n", errs[10]) + assert_match(/\A#{JIT_SUCCESS_PREFIX}: mjit9@\(eval\):/, errs[11]) + end + def test_local_stack_on_exception assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '3', success_count: 2) begin; Index: test/lib/jit_support.rb =================================================================== --- test/lib/jit_support.rb (revision 64071) +++ test/lib/jit_support.rb (revision 64072) @@ -28,8 +28,11 @@ module JITSupport https://github.com/ruby/ruby/blob/trunk/test/lib/jit_support.rb#L28 end module_function - def eval_with_jit(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, timeout: JIT_TIMEOUT) - args = ['--disable-gems', '--jit-wait', "--jit-verbose=#{verbose}", "--jit-min-calls=#{min_calls}"] + def eval_with_jit(env = nil, script, verbose: 0, min_calls: 5, save_temps: false, max_cache: 1000, timeout: JIT_TIMEOUT) + args = [ + '--disable-gems', '--jit-wait', "--jit-verbose=#{verbose}", + "--jit-min-calls=#{min_calls}", "--jit-max-cache=#{max_cache}", + ] args << '--jit-save-temps' if save_temps args << '-e' << script args.unshift(env) if env -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/