From 51f948727d8e76418fc1d1f31a3f5b9d324eb979 Mon Sep 17 00:00:00 2001 From: k0kubun Date: Fri, 27 Jul 2018 05:52:01 +0000 Subject: test_jit.rb: test unload_units git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/lib/jit_support.rb | 7 +++++-- test/ruby/test_jit.rb | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index b3fe3efbcb..2ee1329e31 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -28,8 +28,11 @@ module JITSupport 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 diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 60768812ff..92a7bd56d8 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -529,6 +529,29 @@ class TestJIT < Test::Unit::TestCase 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
@-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; -- cgit v1.2.3