From b03c11a337c53c219a840eed4569e411289f0ddd Mon Sep 17 00:00:00 2001 From: k0kubun Date: Fri, 29 Mar 2019 13:54:29 +0000 Subject: [PATCH] Add debug counters for MJIT cancel git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- debug_counter.c | 2 ++ debug_counter.h | 9 ++++++++- mjit_compile.c | 1 + tool/ruby_vm/views/_mjit_compile_insn.erb | 1 + tool/ruby_vm/views/_mjit_compile_insn_body.erb | 1 + tool/ruby_vm/views/_mjit_compile_ivar.erb | 1 + tool/ruby_vm/views/_mjit_compile_send.erb | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/debug_counter.c b/debug_counter.c index 8c4004af41..b5a0606454 100644 --- a/debug_counter.c +++ b/debug_counter.c @@ -21,7 +21,9 @@ static const char *const debug_counter_names[] = { #undef RB_DEBUG_COUNTER }; +MJIT_SYMBOL_EXPORT_BEGIN size_t rb_debug_counter[numberof(debug_counter_names)]; +MJIT_SYMBOL_EXPORT_END void rb_debug_counter_show_results(const char *msg) diff --git a/debug_counter.h b/debug_counter.h index daa46fdcbf..82eab936d1 100644 --- a/debug_counter.h +++ b/debug_counter.h @@ -257,11 +257,18 @@ RB_DEBUG_COUNTER(theap_evacuate) /* mjit_exec() counts */ RB_DEBUG_COUNTER(mjit_exec) -RB_DEBUG_COUNTER(mjit_exec_call_func) RB_DEBUG_COUNTER(mjit_exec_not_added) RB_DEBUG_COUNTER(mjit_exec_not_added_add_iseq) RB_DEBUG_COUNTER(mjit_exec_not_ready) RB_DEBUG_COUNTER(mjit_exec_not_compiled) +RB_DEBUG_COUNTER(mjit_exec_call_func) + +/* MJIT cancel counters */ +RB_DEBUG_COUNTER(mjit_cancel) +RB_DEBUG_COUNTER(mjit_cancel_ivar) +RB_DEBUG_COUNTER(mjit_cancel_send_inline) +RB_DEBUG_COUNTER(mjit_cancel_opt_insn) /* CALL_SIMPLE_METHOD */ +RB_DEBUG_COUNTER(mjit_cancel_trace) /* rb_mjit_unit_list length */ RB_DEBUG_COUNTER(mjit_length_unit_queue) diff --git a/mjit_compile.c b/mjit_compile.c index f0ba9018ce..8a3b6b3437 100644 --- a/mjit_compile.c +++ b/mjit_compile.c @@ -189,6 +189,7 @@ compile_cancel_handler(FILE *f, const struct rb_iseq_constant_body *body, struct { unsigned int i; fprintf(f, "\ncancel:\n"); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel);\n"); if (status->local_stack_p) { for (i = 0; i < body->stack_max; i++) { fprintf(f, " *(vm_base_ptr(reg_cfp) + %d) = stack[%d];\n", i, i); diff --git a/tool/ruby_vm/views/_mjit_compile_insn.erb b/tool/ruby_vm/views/_mjit_compile_insn.erb index 5bd1abbbae..f9acd81ed5 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn.erb @@ -66,6 +66,7 @@ if (!pc_moved_p) { fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); } + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_trace);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, " }\n"); % end diff --git a/tool/ruby_vm/views/_mjit_compile_insn_body.erb b/tool/ruby_vm/views/_mjit_compile_insn_body.erb index ff33d413e7..7035779221 100644 --- a/tool/ruby_vm/views/_mjit_compile_insn_body.erb +++ b/tool/ruby_vm/views/_mjit_compile_insn_body.erb @@ -79,6 +79,7 @@ fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); } fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_opt_insn);\n"); fprintf(f, " goto cancel;\n"); % else % if insn.handles_sp? diff --git a/tool/ruby_vm/views/_mjit_compile_ivar.erb b/tool/ruby_vm/views/_mjit_compile_ivar.erb index 077c5138d1..7275e86338 100644 --- a/tool/ruby_vm/views/_mjit_compile_ivar.erb +++ b/tool/ruby_vm/views/_mjit_compile_ivar.erb @@ -42,6 +42,7 @@ fprintf(f, " else {\n"); fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_ivar);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, " }\n"); diff --git a/tool/ruby_vm/views/_mjit_compile_send.erb b/tool/ruby_vm/views/_mjit_compile_send.erb index a8b70cc67a..b1bf3ee874 100644 --- a/tool/ruby_vm/views/_mjit_compile_send.erb +++ b/tool/ruby_vm/views/_mjit_compile_send.erb @@ -38,6 +38,7 @@ fprintf(f, " RCLASS_SERIAL(CLASS_OF(stack[%d])) != %"PRI_SERIALT_PREFIX"u)) {\n", b->stack_size - 1 - argc, cc_copy->class_serial); fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", pos); fprintf(f, " reg_cfp->sp = vm_base_ptr(reg_cfp) + %d;\n", b->stack_size); + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_send_inline);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, " }\n"); @@ -81,6 +82,7 @@ if (!pc_moved_p) { fprintf(f, " reg_cfp->pc = original_body_iseq + %d;\n", next_pos); } + fprintf(f, " RB_DEBUG_COUNTER_INC(mjit_cancel_trace);\n"); fprintf(f, " goto cancel;\n"); fprintf(f, " }\n");