summaryrefslogtreecommitdiff
path: root/mjit_worker.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-09-26 03:53:41 (GMT)
committerTakashi Kokubun <takashikkbn@gmail.com>2019-09-26 07:28:34 (GMT)
commit5d8f112505fbc3f9b008ce4ec40fc74f9f623c4a (patch)
tree03ce4f788de6b9f6589890e3ded08a2d12cbc8d6 /mjit_worker.c
parent47a234954a119c6957e947f5769c55d0b40c6004 (diff)
RubyVM::MJIT.pause(wait: true) should wait
for all compilations and compaction. Prior to this commit, the last-compiled code has not been used because MJIT worker is stopped before setting the code, and compaction has also been skipped. But it was not intentional and `wait: true` pause should wait until those two things by its feature.
Diffstat (limited to 'mjit_worker.c')
-rw-r--r--mjit_worker.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mjit_worker.c b/mjit_worker.c
index 516dd87..cc19e27 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -210,6 +210,8 @@ static bool in_jit;
static bool stop_worker_p;
// Set to true if worker is stopped.
static bool worker_stopped;
+// Set to true only when worker is being stopped for `RubyVM::MJIT.pause(wait: true)`.
+static bool mjit_pause_wait_p;
// Path of "/tmp", which can be changed to $TMP in MinGW.
static char *tmp_dir;
@@ -1225,9 +1227,10 @@ mjit_worker(void)
mjit_func_t func = convert_unit_to_func(unit);
(void)RB_DEBUG_COUNTER_INC_IF(mjit_compile_failures, func == (mjit_func_t)NOT_COMPILED_JIT_ISEQ_FUNC);
- // `mjit_copy_cache_from_main_thread` in `mjit_compile` may wait for a long time
- // and worker may be stopped during the compilation.
- if (stop_worker_p)
+ // Checking `stop_worker_p` here because `mjit_copy_cache_from_main_thread` in `mjit_compile` may wait
+ // for a long time and worker may be stopped during the compilation.
+ // However, we do not want to stop here when the `stop_worker()` is from `MJIT.pause(wait: true)`.
+ if (stop_worker_p && !mjit_pause_wait_p)
break;
CRITICAL_SECTION_START(3, "in jit func replace");