[前][次][番号順一覧][スレッド一覧]

ruby-changes:74423

From: TSUYUSATO <ko1@a...>
Date: Wed, 9 Nov 2022 23:22:06 +0900 (JST)
Subject: [ruby-changes:74423] 3c79731981 (master): Fix to compile when USE_CACHE_MATCH_OPT is disabled

https://git.ruby-lang.org/ruby.git/commit/?id=3c79731981

From 3c797319810ca86f1f3b0e556f6ac04d56b39c76 Mon Sep 17 00:00:00 2001
From: TSUYUSATO Kitsune <make.just.on@g...>
Date: Wed, 19 Oct 2022 16:28:30 +0900
Subject: Fix to compile when USE_CACHE_MATCH_OPT is disabled

---
 regexec.c | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/regexec.c b/regexec.c
index 0b2840acdb..5555b5c726 100644
--- a/regexec.c
+++ b/regexec.c
@@ -787,6 +787,23 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) https://github.com/ruby/ruby/blob/trunk/regexec.c#L787
 #define STK_MASK_TO_VOID_TARGET    0x10ff
 #define STK_MASK_MEM_END_OR_MARK   0x8000  /* MEM_END or MEM_END_MARK */
 
+#ifdef USE_CACHE_MATCH_OPT
+#define MATCH_ARG_INIT_CACHE_MATCH_OPT(msa) do {\
+  (msa).enable_cache_match_opt = 0;\
+  (msa).num_fail = 0;\
+  (msa).num_cache_opcode = NUM_CACHE_OPCODE_UNINIT;\
+  (msa).cache_index_table = (UChar **)0;\
+  (msa).match_cache = (uint8_t *)0;\  
+} while(0)
+#define MATCH_ARG_FREE_CACHE_MATCH_OPT(msa) do {\
+  if ((msa).cache_index_table) xfree((msa).cache_index_table);\
+  if ((msa).match_cache) xfree((msa).match_cache);\
+} while(0)
+#else
+#define MATCH_ARG_INIT_CACHE_MATCH_OPT(msa)
+#define MATCH_ARG_FREE_CACHE_MATCH_OPT(msa)
+#endif
+
 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
 # define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
   (msa).stack_p  = (void* )0;\
@@ -797,11 +814,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) https://github.com/ruby/ruby/blob/trunk/regexec.c#L814
   (msa).best_len = ONIG_MISMATCH;\
   (msa).counter  = 0;\
   (msa).end_time = 0;\
-  (msa).enable_cache_match_opt = 0;\
-  (msa).num_fail = 0;\
-  (msa).num_cache_opcode = NUM_CACHE_OPCODE_UNINIT;\
-  (msa).cache_index_table = (UChar **)0;\
-  (msa).match_cache = (uint8_t *)0;\
+  MATCH_ARG_INIT_CACHE_MATCH_OPT(msa);\
 } while(0)
 #else
 # define MATCH_ARG_INIT(msa, arg_option, arg_region, arg_start, arg_gpos) do {\
@@ -812,6 +825,7 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) https://github.com/ruby/ruby/blob/trunk/regexec.c#L825
   (msa).gpos     = (arg_gpos);\
   (msa).counter  = 0;\
   (msa).end_time = 0;\
+  MATCH_ARG_INIT_CACHE_MATCH_OPT(msa);\
 } while(0)
 #endif
 
@@ -850,12 +864,12 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) https://github.com/ruby/ruby/blob/trunk/regexec.c#L864
   if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \
     if ((msa).state_check_buff) xfree((msa).state_check_buff);\
   }\
+  MATCH_ARG_FREE_CACHE_MATCH_OPT(msa);\
 } while(0)
 #else /* USE_COMBINATION_EXPLOSION_CHECK */
 # define MATCH_ARG_FREE(msa) do {\
   if ((msa).stack_p) xfree((msa).stack_p);\
-  if ((msa).cache_index_table) xfree((msa).cache_index_table);\
-  if ((msa).match_cache) xfree((msa).match_cache);\
+  MATCH_ARG_FREE_CACHE_MATCH_OPT(msa);\
 } while (0)
 #endif /* USE_COMBINATION_EXPLOSION_CHECK */
 
@@ -1072,6 +1086,8 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1086
 #define STACK_PUSH_LOOK_BEHIND_NOT(pat,s,sprev,keep) \
         STACK_PUSH(STK_LOOK_BEHIND_NOT,pat,s,sprev,keep)
 
+#ifdef USE_CACHE_MATCH_OPT
+
 #define DO_CACHE_MATCH_OPT(enable,p,num_cache_table,table,pos,match_cache) do {\
   if (enable) {\
     int cache_index = find_cache_index_table((table), (num_cache_table), (p));\
@@ -1091,6 +1107,10 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1107
   }\
 } while (0)
 
+#else
+#define DO_CACHE_MATCH_OPT(enable,p,num_cache_table,table,pos,match_cache)
+#endif /* USE_CACHE_MATCH_OPT */
+
 #define STACK_PUSH_REPEAT(id, pat) do {\
   STACK_ENSURE(1);\
   stk->type = STK_REPEAT;\
@@ -3310,7 +3330,9 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, https://github.com/ruby/ruby/blob/trunk/regexec.c#L3330
       STACK_POP_ONE;
       /* We need to increment num_fail here, for invoking a cache optimization correctly, */
       /* because Onigmo makes a loop, which is pairwise disjoint to the following set, as atomic. */
+#ifdef USE_CACHE_MATCH_OPT
       msa->num_fail++;
+#endif
       MOP_OUT;
       JUMP;
 
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]