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

ruby-changes:64717

From: Takashi <ko1@a...>
Date: Sun, 3 Jan 2021 17:06:18 +0900 (JST)
Subject: [ruby-changes:64717] 4724bf856f (master): Avoid hanging on --jit-wait after MJIT.pause

https://git.ruby-lang.org/ruby.git/commit/?id=4724bf856f

From 4724bf856f30e8cc56795c0dc23b96e7ae68e874 Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Sun, 3 Jan 2021 00:05:00 -0800
Subject: Avoid hanging on --jit-wait after MJIT.pause

When a worker is stopped, nobody will JIT a method for you.

diff --git a/mjit.c b/mjit.c
index b98f742..4dad746 100644
--- a/mjit.c
+++ b/mjit.c
@@ -328,6 +328,9 @@ mjit_wait(struct rb_iseq_constant_body *body) https://github.com/ruby/ruby/blob/trunk/mjit.c#L328
 VALUE
 rb_mjit_wait_call(rb_execution_context_t *ec, struct rb_iseq_constant_body *body)
 {
+    if (worker_stopped)
+        return Qundef;
+
     mjit_wait(body);
     if ((uintptr_t)body->jit_func <= (uintptr_t)LAST_JIT_ISEQ_FUNC) {
         return Qundef;
diff --git a/mjit_worker.c b/mjit_worker.c
index ea6b896..8939c9b 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -236,7 +236,7 @@ static int total_unloads = 0; https://github.com/ruby/ruby/blob/trunk/mjit_worker.c#L236
 // Set to true to stop worker.
 static bool stop_worker_p;
 // Set to true if worker is stopped.
-static bool worker_stopped;
+static bool worker_stopped = true;
 
 // Path of "/tmp", which can be changed to $TMP in MinGW.
 static char *tmp_dir;
diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb
index 3a38b1a..61485c7 100644
--- a/test/ruby/test_jit.rb
+++ b/test/ruby/test_jit.rb
@@ -1070,6 +1070,14 @@ class TestJIT < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_jit.rb#L1070
     end;
   end
 
+  def test_mjit_pause_wait
+    assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: '', success_count: 0, min_calls: 1)
+    begin;
+      RubyVM::MJIT.pause
+      proc {}.call
+    end;
+  end
+
   def test_caller_locations_without_catch_table
     out, _ = eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", min_calls: 1)
     begin;
-- 
cgit v0.10.2


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

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