diff --git a/vm.c b/vm.c index 106155b50f..ad1520b55c 100644 --- a/vm.c +++ b/vm.c @@ -381,19 +381,16 @@ static VALUE vm_invoke_proc(rb_execution_context_t *ec, rb_proc_t *proc, VALUE s static inline rb_jit_func_t jit_compile(rb_execution_context_t *ec) { - // Increment the ISEQ's call counter const rb_iseq_t *iseq = ec->cfp->iseq; struct rb_iseq_constant_body *body = ISEQ_BODY(iseq); bool yjit_enabled = rb_yjit_compile_new_iseqs(); - if (yjit_enabled || rb_rjit_call_p) { - body->jit_entry_calls++; - } - else { + if (!(yjit_enabled || rb_rjit_call_p)) { return NULL; } - // Trigger JIT compilation if not compiled + // Increment the ISEQ's call counter and trigger JIT compilation if not compiled if (body->jit_entry == NULL) { + body->jit_entry_calls++; if (yjit_enabled) { if (rb_yjit_threshold_hit(iseq, body->jit_entry_calls)) { rb_yjit_compile_iseq(iseq, ec, false); @@ -436,19 +433,18 @@ jit_exec(rb_execution_context_t *ec) static inline rb_jit_func_t jit_compile_exception(rb_execution_context_t *ec) { - // Increment the ISEQ's call counter const rb_iseq_t *iseq = ec->cfp->iseq; struct rb_iseq_constant_body *body = ISEQ_BODY(iseq); - if (rb_yjit_compile_new_iseqs()) { - body->jit_exception_calls++; - } - else { + if (!rb_yjit_compile_new_iseqs()) { return NULL; } - // Trigger JIT compilation if not compiled - if (body->jit_exception == NULL && rb_yjit_threshold_hit(iseq, body->jit_exception_calls)) { - rb_yjit_compile_iseq(iseq, ec, true); + // Increment the ISEQ's call counter and trigger JIT compilation if not compiled + if (body->jit_exception == NULL) { + body->jit_exception_calls++; + if (rb_yjit_threshold_hit(iseq, body->jit_exception_calls)) { + rb_yjit_compile_iseq(iseq, ec, true); + } } return body->jit_exception; }