From c01e52eb715c1583f594a1c6e19de249f8e9b439 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 20 Mar 2020 06:12:36 +0000 Subject: merge revision(s) adcf0316d1ecedae2a9157ad941550e0c0fb510b: [Backport #16664] Prevent unloading methods used in root_fiber while calling another Fiber (#2939) Fixing SEGVs like: http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744905 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2744420 http://ci.rvm.jp/results/trunk-mjit-wait@silicon-docker/2741400 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_jit.rb | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index 0155d3fd86..37dc18f1bf 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -12,6 +12,10 @@ class TestJIT < Test::Unit::TestCase IGNORABLE_PATTERNS = [ /\ASuccessful MJIT finish\n\z/, ] + MAX_CACHE_PATTERNS = [ + /\AJIT 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) + [ @@ -568,11 +572,7 @@ class TestJIT < Test::Unit::TestCase end def test_nothing_to_unload_with_jit_wait - ignorable_patterns = [ - /\AJIT compaction \([^)]+\): .+\n\z/, - /\ANo units can be unloaded -- .+\n\z/, - ] - assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 11, max_cache: 10, ignorable_patterns: ignorable_patterns) + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 11, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS) begin; def a1() a2() end def a2() a3() end @@ -589,6 +589,28 @@ class TestJIT < Test::Unit::TestCase end; end + def test_unload_units_on_fiber + assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: 'hello', success_count: 12, max_cache: 10, ignorable_patterns: MAX_CACHE_PATTERNS) + begin; + def a1() a2(false); a2(true) end + def a2(a) a3(a) end + def a3(a) a4(a) end + def a4(a) a5(a) end + def a5(a) a6(a) end + def a6(a) a7(a) end + def a7(a) a8(a) end + def a8(a) a9(a) end + def a9(a) a10(a) end + def a10(a) + if a + Fiber.new { a11 }.resume + end + end + def a11() print('hello') end + a1 + end; + end + def test_unload_units_and_compaction Dir.mktmpdir("jit_test_unload_units_") do |dir| # MIN_CACHE_SIZE is 10 -- cgit v1.2.3