aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-10-19 17:18:59 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2022-10-19 17:20:48 -0700
commitd9d9005a3a31d0df0b5432eba5d6f2b9bd647cb1 (patch)
treefac1ad347a511fa970a2bf5d0f8eff1122baacbb /eval.c
parent0d360ee7ff962ef66667a75a912c3980c4f5b217 (diff)
downloadruby-d9d9005a3a31d0df0b5432eba5d6f2b9bd647cb1.tar.gz
MJIT: Stop using the VM barrier for jit_cont
This solves multiple problems. First, RB_VM_LOCK_ENTER/LEAVE is a barrier. We could at least use the _NO_BARRIER variant. Second, this doesn't need to interfere with GC or other GVL users when multiple Ractors are used. This needs to be used in very few places, so the benefit of fine-grained locking would outweigh its small maintenance cost. Third, it fixes a crash for YJIT. Because YJIT is never disabled until a process exits unlike MJIT that finishes earlier, we could call jit_cont_free when EC no longer exists, which crashes RB_VM_LOCK_ENTER.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index f5c9c0f087..826ae1456e 100644
--- a/eval.c
+++ b/eval.c
@@ -253,7 +253,6 @@ rb_ec_cleanup(rb_execution_context_t *ec, int ex0)
}
mjit_finish(true); // We still need ISeqs here, so it's before rb_ec_finalize().
- rb_jit_cont_finish();
rb_ec_finalize(ec);
@@ -264,6 +263,8 @@ rb_ec_cleanup(rb_execution_context_t *ec, int ex0)
th = th0;
rb_thread_stop_timer_thread();
ruby_vm_destruct(th->vm);
+ // For YJIT, call this after ruby_vm_destruct() frees jit_cont for the root fiber.
+ rb_jit_cont_finish();
if (state) ruby_default_signal(state);
return sysex;