2017-02-21 03:18:15 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
debug_counter.h -
|
|
|
|
|
|
|
|
created at: Tue Feb 21 16:51:18 2017
|
|
|
|
|
|
|
|
Copyright (C) 2017 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef USE_DEBUG_COUNTER
|
|
|
|
#define USE_DEBUG_COUNTER 0
|
|
|
|
#endif
|
|
|
|
|
2017-03-10 02:18:03 -05:00
|
|
|
#ifdef RB_DEBUG_COUNTER
|
2017-05-31 02:46:57 -04:00
|
|
|
|
|
|
|
/* method search */
|
2017-03-10 02:18:03 -05:00
|
|
|
RB_DEBUG_COUNTER(mc_inline_hit)
|
|
|
|
RB_DEBUG_COUNTER(mc_inline_miss)
|
|
|
|
RB_DEBUG_COUNTER(mc_global_hit)
|
|
|
|
RB_DEBUG_COUNTER(mc_global_miss)
|
|
|
|
RB_DEBUG_COUNTER(mc_global_state_miss)
|
|
|
|
RB_DEBUG_COUNTER(mc_class_serial_miss)
|
|
|
|
RB_DEBUG_COUNTER(mc_cme_complement)
|
|
|
|
RB_DEBUG_COUNTER(mc_cme_complement_hit)
|
|
|
|
RB_DEBUG_COUNTER(mc_search_super)
|
2017-05-24 02:46:44 -04:00
|
|
|
|
2017-05-31 02:46:57 -04:00
|
|
|
/* ivar access */
|
2017-03-15 04:25:58 -04:00
|
|
|
RB_DEBUG_COUNTER(ivar_get_ic_hit)
|
|
|
|
RB_DEBUG_COUNTER(ivar_get_ic_miss)
|
|
|
|
RB_DEBUG_COUNTER(ivar_get_ic_miss_serial)
|
|
|
|
RB_DEBUG_COUNTER(ivar_get_ic_miss_unset)
|
|
|
|
RB_DEBUG_COUNTER(ivar_get_ic_miss_noobject)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_hit)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_miss)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_miss_serial)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_miss_unset)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_miss_oorange)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject)
|
|
|
|
RB_DEBUG_COUNTER(ivar_get_base)
|
|
|
|
RB_DEBUG_COUNTER(ivar_set_base)
|
2017-05-24 02:46:44 -04:00
|
|
|
|
2017-05-31 02:46:57 -04:00
|
|
|
/* lvar access */
|
|
|
|
RB_DEBUG_COUNTER(lvar_get)
|
|
|
|
RB_DEBUG_COUNTER(lvar_get_dynamic)
|
|
|
|
RB_DEBUG_COUNTER(lvar_set)
|
|
|
|
RB_DEBUG_COUNTER(lvar_set_dynamic)
|
|
|
|
RB_DEBUG_COUNTER(lvar_set_slowpath)
|
|
|
|
|
2017-05-24 02:46:44 -04:00
|
|
|
/* object counts */
|
|
|
|
RB_DEBUG_COUNTER(obj_free)
|
|
|
|
|
|
|
|
RB_DEBUG_COUNTER(obj_str_ptr)
|
|
|
|
RB_DEBUG_COUNTER(obj_str_embed)
|
|
|
|
RB_DEBUG_COUNTER(obj_str_shared)
|
|
|
|
RB_DEBUG_COUNTER(obj_str_nofree)
|
|
|
|
RB_DEBUG_COUNTER(obj_str_fstr)
|
|
|
|
|
|
|
|
RB_DEBUG_COUNTER(obj_ary_ptr)
|
|
|
|
RB_DEBUG_COUNTER(obj_ary_embed)
|
|
|
|
|
|
|
|
RB_DEBUG_COUNTER(obj_obj_ptr)
|
|
|
|
RB_DEBUG_COUNTER(obj_obj_embed)
|
2017-05-31 20:05:33 -04:00
|
|
|
|
|
|
|
/* load */
|
|
|
|
RB_DEBUG_COUNTER(load_files)
|
|
|
|
RB_DEBUG_COUNTER(load_path_is_not_realpath)
|
|
|
|
|
2017-03-10 02:18:03 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RUBY_DEBUG_COUNTER_H
|
|
|
|
#define RUBY_DEBUG_COUNTER_H 1
|
|
|
|
|
2017-02-21 03:18:15 -05:00
|
|
|
#if !defined(__GNUC__) && USE_DEBUG_COUNTER
|
|
|
|
#error "USE_DEBUG_COUNTER is not supported by other than __GNUC__"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum rb_debug_counter_type {
|
2017-03-10 02:18:03 -05:00
|
|
|
#define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
|
2018-02-08 22:15:21 -05:00
|
|
|
#include __FILE__
|
2017-02-21 03:18:15 -05:00
|
|
|
RB_DEBUG_COUNTER_MAX
|
2017-03-10 02:18:03 -05:00
|
|
|
#undef RB_DEBUG_COUNTER
|
2017-02-21 03:18:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#if USE_DEBUG_COUNTER
|
|
|
|
#include "ruby/ruby.h"
|
|
|
|
|
2017-03-10 02:18:03 -05:00
|
|
|
extern size_t rb_debug_counter[];
|
2017-02-21 03:18:15 -05:00
|
|
|
|
|
|
|
inline static int
|
|
|
|
rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)
|
|
|
|
{
|
|
|
|
if (cond) {
|
|
|
|
rb_debug_counter[(int)type] += add;
|
|
|
|
}
|
|
|
|
return cond;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
|
|
|
|
#define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
|
|
|
|
#define RB_DEBUG_COUNTER_INC_IF(type, cond) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, (cond))
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define RB_DEBUG_COUNTER_INC(type) ((void)0)
|
|
|
|
#define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (cond)
|
|
|
|
#define RB_DEBUG_COUNTER_INC_IF(type, cond) (cond)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RUBY_DEBUG_COUNTER_H */
|