Ruby  2.5.0dev(2017-10-22revision60238)
debug_counter.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  debug_counter.h -
4 
5  created at: Tue Feb 21 16:51:18 2017
6 
7  Copyright (C) 2017 Koichi Sasada
8 
9 **********************************************************************/
10 
11 #ifndef USE_DEBUG_COUNTER
12 #define USE_DEBUG_COUNTER 0
13 #endif
14 
15 #ifdef RB_DEBUG_COUNTER
16 
17 /* method search */
18 RB_DEBUG_COUNTER(mc_inline_hit)
19 RB_DEBUG_COUNTER(mc_inline_miss)
20 RB_DEBUG_COUNTER(mc_global_hit)
21 RB_DEBUG_COUNTER(mc_global_miss)
22 RB_DEBUG_COUNTER(mc_global_state_miss)
23 RB_DEBUG_COUNTER(mc_class_serial_miss)
24 RB_DEBUG_COUNTER(mc_cme_complement)
25 RB_DEBUG_COUNTER(mc_cme_complement_hit)
26 RB_DEBUG_COUNTER(mc_search_super)
27 
28 /* ivar access */
29 RB_DEBUG_COUNTER(ivar_get_ic_hit)
30 RB_DEBUG_COUNTER(ivar_get_ic_miss)
31 RB_DEBUG_COUNTER(ivar_get_ic_miss_serial)
32 RB_DEBUG_COUNTER(ivar_get_ic_miss_unset)
33 RB_DEBUG_COUNTER(ivar_get_ic_miss_noobject)
34 RB_DEBUG_COUNTER(ivar_set_ic_hit)
35 RB_DEBUG_COUNTER(ivar_set_ic_miss)
36 RB_DEBUG_COUNTER(ivar_set_ic_miss_serial)
37 RB_DEBUG_COUNTER(ivar_set_ic_miss_unset)
38 RB_DEBUG_COUNTER(ivar_set_ic_miss_oorange)
39 RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject)
40 RB_DEBUG_COUNTER(ivar_get_base)
41 RB_DEBUG_COUNTER(ivar_set_base)
42 
43 /* lvar access */
44 RB_DEBUG_COUNTER(lvar_get)
45 RB_DEBUG_COUNTER(lvar_get_dynamic)
46 RB_DEBUG_COUNTER(lvar_set)
47 RB_DEBUG_COUNTER(lvar_set_dynamic)
48 RB_DEBUG_COUNTER(lvar_set_slowpath)
49 
50 /* object counts */
51 RB_DEBUG_COUNTER(obj_free)
52 
53 RB_DEBUG_COUNTER(obj_str_ptr)
54 RB_DEBUG_COUNTER(obj_str_embed)
55 RB_DEBUG_COUNTER(obj_str_shared)
56 RB_DEBUG_COUNTER(obj_str_nofree)
57 RB_DEBUG_COUNTER(obj_str_fstr)
58 
59 RB_DEBUG_COUNTER(obj_ary_ptr)
60 RB_DEBUG_COUNTER(obj_ary_embed)
61 
62 RB_DEBUG_COUNTER(obj_obj_ptr)
63 RB_DEBUG_COUNTER(obj_obj_embed)
64 
65 /* load */
66 RB_DEBUG_COUNTER(load_files)
67 RB_DEBUG_COUNTER(load_path_is_not_realpath)
68 
69 #endif
70 
71 #ifndef RUBY_DEBUG_COUNTER_H
72 #define RUBY_DEBUG_COUNTER_H 1
73 
74 #if !defined(__GNUC__) && USE_DEBUG_COUNTER
75 #error "USE_DEBUG_COUNTER is not supported by other than __GNUC__"
76 #endif
77 
79 #define RB_DEBUG_COUNTER(name) RB_DEBUG_COUNTER_##name,
80 #include "debug_counter.h"
82 #undef RB_DEBUG_COUNTER
83 };
84 
85 #if USE_DEBUG_COUNTER
86 #include "ruby/ruby.h"
87 
88 extern size_t rb_debug_counter[];
89 
90 inline static int
91 rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond)
92 {
93  if (cond) {
94  rb_debug_counter[(int)type] += add;
95  }
96  return cond;
97 }
98 
99 #define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1)
100 #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))
101 #define RB_DEBUG_COUNTER_INC_IF(type, cond) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, (cond))
102 
103 #else
104 #define RB_DEBUG_COUNTER_INC(type) ((void)0)
105 #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (cond)
106 #define RB_DEBUG_COUNTER_INC_IF(type, cond) (cond)
107 #endif
108 
109 #endif /* RUBY_DEBUG_COUNTER_H */
#define cond(node, column)
Definition: ripper.c:653
#define add(x, y)
Definition: date_strftime.c:23
rb_debug_counter_type
Definition: debug_counter.h:78
#define RB_DEBUG_COUNTER(name)
Definition: debug_counter.h:79