From 5220145ea289d9eb955b373f31773fab2d4f0271 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 25 Dec 2019 01:32:37 +0900 Subject: [PATCH] add debug_counter access functions. These functions are enabled only on USE_DEBUG_COUNTER=1. --- debug_counter.c | 82 ++++++++++++++++++++++++++++++++++++++++--------- debug_counter.h | 10 ++++-- 2 files changed, 75 insertions(+), 17 deletions(-) diff --git a/debug_counter.c b/debug_counter.c index 1e395f306b..11ec57a961 100644 --- a/debug_counter.c +++ b/debug_counter.c @@ -8,8 +8,8 @@ **********************************************************************/ -#include "debug_counter.h" #include "internal.h" +#include "debug_counter.h" #include #include @@ -25,6 +25,52 @@ MJIT_SYMBOL_EXPORT_BEGIN size_t rb_debug_counter[numberof(debug_counter_names)]; MJIT_SYMBOL_EXPORT_END +int debug_counter_disable_show_at_exit = 0; + +// note that this operation is not atomic. +void +ruby_debug_counter_reset(void) +{ + for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) { + switch (i) { + case RB_DEBUG_COUNTER_mjit_length_unit_queue: + case RB_DEBUG_COUNTER_mjit_length_active_units: + case RB_DEBUG_COUNTER_mjit_length_compact_units: + case RB_DEBUG_COUNTER_mjit_length_stale_units: + // These counters may be decreased and should not be reset. + break; + default: + rb_debug_counter[i] = 0; + break; + } + } +} + +// note that this operation is not atomic. +size_t +ruby_debug_counter_get(const char **names_ptr, size_t *counters_ptr) +{ + int i; + if (names_ptr != NULL) { + for (i=0; i