From 6341fc21b2e15dca82253da41047ce37409508fc Mon Sep 17 00:00:00 2001 From: Maxime Chevalier-Boisvert Date: Mon, 8 Feb 2021 15:40:36 -0500 Subject: [PATCH] Don't increment instr/exit counters if stats not requested --- ujit_codegen.c | 20 +++++++++++--------- version.c | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ujit_codegen.c b/ujit_codegen.c index bb5c336d6d..b9d2a0a7cb 100644 --- a/ujit_codegen.c +++ b/ujit_codegen.c @@ -69,10 +69,11 @@ ujit_gen_exit(jitstate_t* jit, ctx_t* ctx, codeblock_t* cb, VALUE* exit_pc) mov(cb, RAX, const_ptr_opnd(exit_pc)); mov(cb, member_opnd(REG_CFP, rb_control_frame_t, pc), RAX); -#if RUBY_DEBUG - mov(cb, RDI, const_ptr_opnd(exit_pc)); - call_ptr(cb, RSI, (void *)&rb_ujit_count_side_exit_op); -#endif + // Accumulate stats about interpreter exits + if (rb_ujit_opts.gen_stats) { + mov(cb, RDI, const_ptr_opnd(exit_pc)); + call_ptr(cb, RSI, (void *)&rb_ujit_count_side_exit_op); + } // Write the post call bytes cb_write_post_call_bytes(cb); @@ -187,11 +188,12 @@ ujit_gen_block(ctx_t* ctx, block_t* block) break; } -#if RUBY_DEBUG - // Count instructions executed by the JIT - mov(cb, REG0, const_ptr_opnd((void *)&rb_ujit_exec_insns_count)); - add(cb, mem_opnd(64, REG0, 0), imm_opnd(1)); -#endif + // Accumulate stats about instructions executed + if (rb_ujit_opts.gen_stats) { + // Count instructions executed by the JIT + mov(cb, REG0, const_ptr_opnd((void *)&rb_ujit_exec_insns_count)); + add(cb, mem_opnd(64, REG0, 0), imm_opnd(1)); + } //fprintf(stderr, "compiling %d: %s\n", insn_idx, insn_name(opcode)); //print_str(cb, insn_name(opcode)); diff --git a/version.c b/version.c index bc13bc23dd..e416b84548 100644 --- a/version.c +++ b/version.c @@ -126,7 +126,7 @@ ruby_show_version(void) } if (rb_ujit_enabled_p()) { - fputs("ujit is enabled\n", stdout); + fputs("uJIT is enabled\n", stdout); } #ifdef RUBY_LAST_COMMIT_TITLE fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);