aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-04-12 23:10:22 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2020-04-12 23:10:28 -0700
commita3f6f67967644f34226b4424227d2eec52fedd45 (patch)
tree0f037bc7ec6ef58c23d6e7b2bd0d320f4c13d12f /mjit.c
parent82fdffc5ec0ecffc2e49128775d7c09ed43ba59d (diff)
downloadruby-a3f6f67967644f34226b4424227d2eec52fedd45.tar.gz
Add MJIT_COUNTER macro to dump total_calls
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/mjit.c b/mjit.c
index 551f7466a3..c394cd5ddb 100644
--- a/mjit.c
+++ b/mjit.c
@@ -923,6 +923,22 @@ mjit_child_after_fork(void)
start_worker();
}
+// Edit 0 to 1 to enable this feature for investigating hot methods
+#define MJIT_COUNTER 0
+#if MJIT_COUNTER
+static void
+mjit_dump_total_calls(void)
+{
+ struct rb_mjit_unit *unit;
+ fprintf(stderr, "[MJIT_COUNTER] total_calls of active_units:\n");
+ list_for_each(&active_units.head, unit, unode) {
+ const rb_iseq_t *iseq = unit->iseq;
+ fprintf(stderr, "%8ld: %s@%s:%d\n", iseq->body->total_calls, RSTRING_PTR(iseq->body->location.label),
+ RSTRING_PTR(rb_iseq_path(iseq)), FIX2INT(iseq->body->location.first_lineno));
+ }
+}
+#endif
+
// Finish the threads processing units and creating PCH, finalize
// and free MJIT data. It should be called last during MJIT
// life.
@@ -958,6 +974,10 @@ mjit_finish(bool close_handle_p)
rb_native_cond_destroy(&mjit_worker_wakeup);
rb_native_cond_destroy(&mjit_gc_wakeup);
+#if MJIT_COUNTER
+ mjit_dump_total_calls();
+#endif
+
#ifndef _MSC_VER // mswin has prebuilt precompiled header
if (!mjit_opts.save_temps && getpid() == pch_owner_pid)
remove_file(pch_file);