diff options
author | Takashi Kokubun <[email protected]> | 2021-01-03 00:05:00 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2021-01-03 00:05:38 -0800 |
commit | 4724bf856f30e8cc56795c0dc23b96e7ae68e874 (patch) | |
tree | 501baee61f328889e4d6010feb3308472424f55f | |
parent | 09ec8d686654462e55b2c60e2860754d1fa3435f (diff) |
Avoid hanging on --jit-wait after MJIT.pause
When a worker is stopped, nobody will JIT a method for you.
-rw-r--r-- | mjit.c | 3 | ||||
-rw-r--r-- | mjit_worker.c | 2 | ||||
-rw-r--r-- | test/ruby/test_jit.rb | 8 |
3 files changed, 12 insertions, 1 deletions
@@ -328,6 +328,9 @@ mjit_wait(struct rb_iseq_constant_body *body) 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 ea6b896889..8939c9b927 100644 --- a/mjit_worker.c +++ b/mjit_worker.c @@ -236,7 +236,7 @@ static int total_unloads = 0; // 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 3a38b1a998..61485c7479 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -1070,6 +1070,14 @@ class TestJIT < Test::Unit::TestCase 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; |