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

ruby-changes:52965

From: k0kubun <ko1@a...>
Date: Sat, 20 Oct 2018 00:09:02 +0900 (JST)
Subject: [ruby-changes:52965] k0kubun:r65179 (trunk): mjit.c: don't let MJIT.pause hang on full active units

k0kubun	2018-10-20 00:08:55 +0900 (Sat, 20 Oct 2018)

  New Revision: 65179

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65179

  Log:
    mjit.c: don't let MJIT.pause hang on full active units
    
    test/ruby/test_rubyvm_mjit.rb: add reproductive test
    
    [Bug #15071]

  Modified files:
    trunk/mjit.c
    trunk/test/ruby/test_rubyvm_mjit.rb
Index: test/ruby/test_rubyvm_mjit.rb
===================================================================
--- test/ruby/test_rubyvm_mjit.rb	(revision 65178)
+++ test/ruby/test_rubyvm_mjit.rb	(revision 65179)
@@ -33,6 +33,18 @@ class TestRubyVMMJIT < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyvm_mjit.rb#L33
     )
   end
 
+  def test_pause_does_not_hang_on_full_units
+    out, _ = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, max_cache: 10, wait: false)
+      i = 0
+      while i < 11
+        eval("def mjit#{i}; end; mjit#{i}")
+        i += 1
+      end
+      print RubyVM::MJIT.pause
+    EOS
+    assert_equal('true', out)
+  end
+
   def test_pause_wait_false
     out, err = eval_with_jit(<<~'EOS', verbose: 1, min_calls: 1, wait: false)
       i = 0
Index: mjit.c
===================================================================
--- mjit.c	(revision 65178)
+++ mjit.c	(revision 65179)
@@ -647,7 +647,7 @@ mjit_pause(int wait_p) https://github.com/ruby/ruby/blob/trunk/mjit.c#L647
         tv.tv_sec = 0;
         tv.tv_usec = 1000;
 
-        while (unit_queue.length > 0) {
+        while (unit_queue.length > 0 && active_units.length < mjit_opts.max_cache_size) { /* inverse of condition that waits for mjit_worker_wakeup */
             CRITICAL_SECTION_START(3, "in mjit_pause for a worker wakeup");
             rb_native_cond_broadcast(&mjit_worker_wakeup);
             CRITICAL_SECTION_FINISH(3, "in mjit_pause for a worker wakeup");

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

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