Avoid hanging on --jit-wait after MJIT.pause

When a worker is stopped, nobody will JIT a method for you.
This commit is contained in:
Takashi Kokubun 2021-01-03 00:05:00 -08:00
parent 09ec8d6866
commit 4724bf856f
No known key found for this signature in database
GPG Key ID: 6FFC433B12EE23DD
3 changed files with 12 additions and 1 deletions

3
mjit.c
View File

@ -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;

View File

@ -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;

View File

@ -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;