[前][次][番号順一覧][スレッド一覧]

ruby-changes:60449

From: nagachika <ko1@a...>
Date: Fri, 20 Mar 2020 12:09:41 +0900 (JST)
Subject: [ruby-changes:60449] 1e4174b45c (ruby_2_6): merge revision(s) a8dcab723316997d9e01c89d6df969edce75bdca:

https://git.ruby-lang.org/ruby.git/commit/?id=1e4174b45c

From 1e4174b45c4b9c3d27ef68e532d58aae22457bbf Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Fri, 20 Mar 2020 03:09:27 +0000
Subject: merge revision(s) a8dcab723316997d9e01c89d6df969edce75bdca:

	Avoid infinite loop on --jit-wait


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

diff --git a/mjit.c b/mjit.c
index 0346d03..a0310ae 100644
--- a/mjit.c
+++ b/mjit.c
@@ -297,7 +297,14 @@ unload_units(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L297
         remove_from_list(worst, &active_units);
         free_unit(worst);
     }
-    verbose(1, "Too many JIT code -- %d units unloaded", units_num - active_units.length);
+
+    if (units_num == active_units.length && mjit_opts.wait) {
+        mjit_opts.max_cache_size++; // avoid infinite loop on `rb_mjit_wait_call`. Note that --jit-wait is just for testing.
+        verbose(1, "No units can be unloaded -- incremented max-cache-size to %d for --jit-wait", mjit_opts.max_cache_size);
+    }
+    else {
+        verbose(1, "Too many JIT code -- %d units unloaded", units_num - active_units.length);
+    }
 }
 
 /* Add ISEQ to be JITed in parallel with the current thread.
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index fd5ccc8..0155d3f 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -567,6 +567,28 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L567
     assert_match(/^Successful MJIT finish$/, err)
   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)
+    begin;
+      def a1() a2() end
+      def a2() a3() end
+      def a3() a4() end
+      def a4() a5() end
+      def a5() a6() end
+      def a6() a7() end
+      def a7() a8() end
+      def a8() a9() end
+      def a9() a10() end
+      def a10() a11() 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
@@ -937,13 +959,13 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L959
   end
 
   # Shorthand for normal test cases
-  def assert_eval_with_jit(script, stdout: nil, success_count:, min_calls: 1, insns: [], uplevel: 1)
-    out, err = eval_with_jit(script, verbose: 1, min_calls: min_calls)
+  def assert_eval_with_jit(script, stdout: nil, success_count:, min_calls: 1, max_cache: 1000, insns: [], uplevel: 1, ignorable_patterns: [])
+    out, err = eval_with_jit(script, verbose: 1, min_calls: min_calls, max_cache: max_cache)
     actual = err.scan(/^#{JIT_SUCCESS_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.
     if RUBY_PLATFORM.match?(/mswin/) && success_count != actual
-      out2, err2 = eval_with_jit(script, verbose: 2, min_calls: min_calls)
+      out2, err2 = eval_with_jit(script, verbose: 2, min_calls: min_calls, max_cache: max_cache)
     end
 
     # Make sure that the script has insns expected to be tested
@@ -967,7 +989,7 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L989
       assert_equal(stdout, out, "Expected stdout #{out.inspect} to match #{stdout.inspect} with script:\n#{code_block(script)}")
     end
     err_lines = err.lines.reject! do |l|
-      l.chomp.empty? || l.match?(/\A#{JIT_SUCCESS_PREFIX}/) || IGNORABLE_PATTERNS.any? { |pat| pat.match?(l) }
+      l.chomp.empty? || l.match?(/\A#{JIT_SUCCESS_PREFIX}/) || (IGNORABLE_PATTERNS + ignorable_patterns).any? { |pat| pat.match?(l) }
     end
     unless err_lines.empty?
       warn err_lines.join(''), uplevel: uplevel
diff --git a/version.h b/version.h
index 4b67252..83bdf8b 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.6"
 #define RUBY_RELEASE_DATE "2020-03-20"
-#define RUBY_PATCHLEVEL 136
+#define RUBY_PATCHLEVEL 137
 
 #define RUBY_RELEASE_YEAR 2020
 #define RUBY_RELEASE_MONTH 3
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]