1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/debug_counter.h
nobu b80c265fa4 debug_counter.c: debug_counter_names [ci skip]
* debug_counter.c (debug_counter_names): stringize debug counter
  names by preprocessor.

* debug_counter.h (RB_DEBUG_COUNTER): define counter names outside
  the include guard, to expand multiple times.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-03-10 07:18:03 +00:00

71 lines
1.9 KiB
C

/**********************************************************************
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
#ifdef RB_DEBUG_COUNTER
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)
RB_DEBUG_COUNTER(ivar_get_hit)
RB_DEBUG_COUNTER(ivar_get_miss)
RB_DEBUG_COUNTER(ivar_set_hit)
RB_DEBUG_COUNTER(ivar_set_miss)
RB_DEBUG_COUNTER(ivar_get)
RB_DEBUG_COUNTER(ivar_set)
#endif
#ifndef RUBY_DEBUG_COUNTER_H
#define RUBY_DEBUG_COUNTER_H 1
#if !defined(__GNUC__) && USE_DEBUG_COUNTER
#error "USE_DEBUG_COUNTER is not supported by other than __GNUC__"
#endif
enum rb_debug_counter_type {
#define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
#include "debug_counter.h"
RB_DEBUG_COUNTER_MAX
#undef RB_DEBUG_COUNTER
};
#if USE_DEBUG_COUNTER
#include "ruby/ruby.h"
extern size_t rb_debug_counter[];
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 */