ruby-changes:46862
From: ko1 <ko1@a...>
Date: Wed, 31 May 2017 15:47:03 +0900 (JST)
Subject: [ruby-changes:46862] ko1:r58977 (trunk): add debug counters for local variable (lavr) access.
ko1 2017-05-31 15:46:57 +0900 (Wed, 31 May 2017) New Revision: 58977 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58977 Log: add debug counters for local variable (lavr) access. * debug_counter.h: add the following counters: * lvar_get: counter for lvar get. * lvar_get_dynamic: counter for lvar get from upper frames. * lvar_set: coutner for lvar set. * lvar_set_dynamic: coutner for lvar set from upper frames. * lvar_set_slowpath: counter for lavr set using slowpath. Modified files: trunk/debug_counter.h trunk/insns.def trunk/vm_insnhelper.c Index: debug_counter.h =================================================================== --- debug_counter.h (revision 58976) +++ debug_counter.h (revision 58977) @@ -13,6 +13,8 @@ https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L13 #endif #ifdef RB_DEBUG_COUNTER + +/* method search */ RB_DEBUG_COUNTER(mc_inline_hit) RB_DEBUG_COUNTER(mc_inline_miss) RB_DEBUG_COUNTER(mc_global_hit) @@ -23,6 +25,7 @@ RB_DEBUG_COUNTER(mc_cme_complement) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L25 RB_DEBUG_COUNTER(mc_cme_complement_hit) RB_DEBUG_COUNTER(mc_search_super) +/* ivar access */ RB_DEBUG_COUNTER(ivar_get_ic_hit) RB_DEBUG_COUNTER(ivar_get_ic_miss) RB_DEBUG_COUNTER(ivar_get_ic_miss_serial) @@ -37,6 +40,13 @@ RB_DEBUG_COUNTER(ivar_set_ic_miss_noobje https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L40 RB_DEBUG_COUNTER(ivar_get_base) RB_DEBUG_COUNTER(ivar_set_base) +/* 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) + /* object counts */ RB_DEBUG_COUNTER(obj_free) Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 58976) +++ vm_insnhelper.c (revision 58977) @@ -320,6 +320,7 @@ vm_env_write_slowpath(const VALUE *ep, i https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L320 rb_gc_writebarrier_remember(VM_ENV_ENVVAL(ep)); VM_FORCE_WRITE(&ep[index], v); VM_ENV_FLAGS_UNSET(ep, VM_ENV_FLAG_WB_REQUIRED); + RB_DEBUG_COUNTER_INC(lvar_set_slowpath); } static inline void Index: insns.def =================================================================== --- insns.def (revision 58976) +++ insns.def (revision 58977) @@ -58,6 +58,8 @@ getlocal https://github.com/ruby/ruby/blob/trunk/insns.def#L58 (VALUE val) { val = *(vm_get_ep(GET_EP(), level) - idx); + RB_DEBUG_COUNTER_INC(lvar_get); + (void)RB_DEBUG_COUNTER_INC_IF(lvar_get_dynamic, level > 0); } /** @@ -74,6 +76,8 @@ setlocal https://github.com/ruby/ruby/blob/trunk/insns.def#L76 () { vm_env_write(vm_get_ep(GET_EP(), level), -(int)idx, val); + RB_DEBUG_COUNTER_INC(lvar_set); + (void)RB_DEBUG_COUNTER_INC_IF(lvar_set_dynamic, level > 0); } /** -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/