diff options
-rw-r--r-- | benchmark/match_gt4.rb | 1 | ||||
-rw-r--r-- | benchmark/match_small.rb | 1 | ||||
-rw-r--r-- | debug_counter.h | 6 | ||||
-rw-r--r-- | gc.c | 11 | ||||
-rw-r--r-- | include/ruby/onigmo.h | 2 |
5 files changed, 20 insertions, 1 deletions
diff --git a/benchmark/match_gt4.rb b/benchmark/match_gt4.rb new file mode 100644 index 0000000000..ffda109912 --- /dev/null +++ b/benchmark/match_gt4.rb @@ -0,0 +1 @@ +1000000.times { /(.)(.)(\d+)(\d)/.match("THX1138.") } diff --git a/benchmark/match_small.rb b/benchmark/match_small.rb new file mode 100644 index 0000000000..3b743d484a --- /dev/null +++ b/benchmark/match_small.rb @@ -0,0 +1 @@ +1000000.times { 'haystack'.match(/hay/) } diff --git a/debug_counter.h b/debug_counter.h index 83ae701524..f0444d7190 100644 --- a/debug_counter.h +++ b/debug_counter.h @@ -177,6 +177,9 @@ RB_DEBUG_COUNTER(gc_isptr_maybe) * * hash_under4: has under 4 entries * * hash_ge4: has n entries (4<=n<8) * * hash_ge8: has n entries (8<=n) + * * match_under4: has under 4 oniguruma regions allocated + * * match_ge4: has n regions allocated (4<=n<8) + * * match_ge8: has n regions allocated (8<=n) * * data_empty: T_DATA but no memory free. * * data_xfree: free'ed by xfree(). * * data_imm_free: free'ed immediately. @@ -225,6 +228,9 @@ RB_DEBUG_COUNTER(obj_data_xfree) RB_DEBUG_COUNTER(obj_data_imm_free) RB_DEBUG_COUNTER(obj_data_zombie) +RB_DEBUG_COUNTER(obj_match_under4) +RB_DEBUG_COUNTER(obj_match_ge4) +RB_DEBUG_COUNTER(obj_match_ge8) RB_DEBUG_COUNTER(obj_match_ptr) RB_DEBUG_COUNTER(obj_file_ptr) RB_DEBUG_COUNTER(obj_bignum_ptr) @@ -2436,6 +2436,17 @@ obj_free(rb_objspace_t *objspace, VALUE obj) case T_MATCH: if (RANY(obj)->as.match.rmatch) { struct rmatch *rm = RANY(obj)->as.match.rmatch; +#if USE_DEBUG_COUNTER + if (rm->regs.num_regs >= 8) { + RB_DEBUG_COUNTER_INC(obj_match_ge8); + } + else if (rm->regs.num_regs >= 4) { + RB_DEBUG_COUNTER_INC(obj_match_ge4); + } + else if (rm->regs.num_regs >= 1) { + RB_DEBUG_COUNTER_INC(obj_match_under4); + } +#endif onig_region_free(&rm->regs, 0); if (rm->char_offset) xfree(rm->char_offset); diff --git a/include/ruby/onigmo.h b/include/ruby/onigmo.h index 34b8268d59..6187b37dc3 100644 --- a/include/ruby/onigmo.h +++ b/include/ruby/onigmo.h @@ -434,7 +434,7 @@ int onigenc_str_bytelen_null(OnigEncoding enc, const OnigUChar* p); /* PART: regular expression */ /* config parameters */ -#define ONIG_NREGION 10 +#define ONIG_NREGION 4 #define ONIG_MAX_CAPTURE_GROUP_NUM 32767 #define ONIG_MAX_BACKREF_NUM 1000 #define ONIG_MAX_REPEAT_NUM 100000 |