diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-24 06:46:44 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-24 06:46:44 +0000 |
commit | 9e1624cfe8880fc018e34327c77669f2f4e5b100 (patch) | |
tree | 1f1ec71af916b8b0472ab9193d6d87b5bd8f41ce /string.c | |
parent | 144e06700705a3f067582682567bc77b429c4fca (diff) | |
download | ruby-9e1624cfe8880fc018e34327c77669f2f4e5b100.tar.gz |
Add debug counters.
* debug_counter.h: add the following counters to measure object types.
obj_free: freed count
obj_str_ptr: freed count of Strings they have extra buff.
obj_str_embed: freed count of Strings they don't have extra buff.
obj_str_shared: freed count of Strings they have shared extra buff.
obj_str_nofree: freed count of Strings they are marked as nofree.
obj_str_fstr: freed count of Strings they are marked as fstr.
obj_ary_ptr: freed count of Arrays they have extra buff.
obj_ary_embed: freed count of Arrays they don't have extra buff.
obj_obj_ptr: freed count of Objects (T_OBJECT) they have extra buff.
obj_obj_embed: freed count of Objects they don't have extra buff.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -18,6 +18,7 @@ #include "gc.h" #include "ruby_assert.h" #include "id.h" +#include "debug_counter.h" #define BEG(no) (regs->beg[(no)]) #define END(no) (regs->end[(no)]) @@ -1310,9 +1311,18 @@ rb_str_free(VALUE str) if (FL_TEST(str, RSTRING_FSTR)) { st_data_t fstr = (st_data_t)str; st_delete(rb_vm_fstring_table(), &fstr, NULL); + RB_DEBUG_COUNTER_INC(obj_str_fstr); } - if (!STR_EMBED_P(str) && !FL_TEST(str, STR_SHARED|STR_NOFREE)) { + if (STR_EMBED_P(str)) { + RB_DEBUG_COUNTER_INC(obj_str_embed); + } + else if (FL_TEST(str, STR_SHARED | STR_NOFREE)) { + (void)RB_DEBUG_COUNTER_INC_IF(obj_str_shared, FL_TEST(str, STR_SHARED)); + (void)RB_DEBUG_COUNTER_INC_IF(obj_str_shared, FL_TEST(str, STR_NOFREE)); + } + else { + RB_DEBUG_COUNTER_INC(obj_str_ptr); ruby_sized_xfree(STR_HEAP_PTR(str), STR_HEAP_SIZE(str)); } } |