From 595e3a94fd11a435eccd3356492ee775b622ce2b Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 19 Oct 2020 11:42:05 -0400 Subject: [PATCH] Fix MicroJIT logic in MJIT exec --- mjit.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mjit.h b/mjit.h index b9cbf37a19..fc99da04a7 100644 --- a/mjit.h +++ b/mjit.h @@ -143,21 +143,25 @@ mjit_exec(rb_execution_context_t *ec) const rb_iseq_t *iseq; struct rb_iseq_constant_body *body; - if (!mjit_call_p && !rb_ujit_enabled_p()) - return Qundef; - RB_DEBUG_COUNTER_INC(mjit_exec); - - iseq = ec->cfp->iseq; - body = iseq->body; - body->total_calls++; + if (mjit_call_p || rb_ujit_enabled_p()) { + iseq = ec->cfp->iseq; + body = iseq->body; + body->total_calls++; + } #ifndef MJIT_HEADER const int ujit_call_threashold = 10; - if (body->total_calls == ujit_call_threashold && !mjit_call_p) { + if (rb_ujit_enabled_p() && !mjit_call_p && body->total_calls == ujit_call_threashold) { rb_ujit_compile_iseq(iseq); + return Qundef; } #endif + if (!mjit_call_p) + return Qundef; + + RB_DEBUG_COUNTER_INC(mjit_exec); + mjit_func_t func = body->jit_func; if (UNLIKELY((uintptr_t)func <= LAST_JIT_ISEQ_FUNC)) { # ifdef MJIT_HEADER