[Pcre-svn] [1143] code/trunk: Follow the partial matching ch…

Inizio della pagina
Delete this message
Autore: Subversion repository
Data:  
To: pcre-svn
Oggetto: [Pcre-svn] [1143] code/trunk: Follow the partial matching changes in JIT.
Revision: 1143
          http://www.exim.org/viewvc/pcre2?view=rev&revision=1143
Author:   zherczeg
Date:     2019-07-23 13:34:58 +0100 (Tue, 23 Jul 2019)
Log Message:
-----------
Follow the partial matching changes in JIT.


Modified Paths:
--------------
    code/trunk/src/pcre2_jit_compile.c
    code/trunk/src/sljit/sljitConfigInternal.h
    code/trunk/src/sljit/sljitNativeX86_64.c
    code/trunk/testdata/testinput2
    code/trunk/testdata/testoutput2


Modified: code/trunk/src/pcre2_jit_compile.c
===================================================================
--- code/trunk/src/pcre2_jit_compile.c    2019-07-22 16:30:44 UTC (rev 1142)
+++ code/trunk/src/pcre2_jit_compile.c    2019-07-23 12:34:58 UTC (rev 1143)
@@ -413,6 +413,8 @@
   sljit_sw lcc;
   /* Mode can be PCRE2_JIT_COMPLETE and others. */
   int mode;
+  /* TRUE, when empty match is accepted for partial matching. */
+  BOOL allow_empty_partial;
   /* TRUE, when minlength is greater than 0. */
   BOOL might_be_empty;
   /* \K is found in the pattern. */
@@ -3303,7 +3305,7 @@
 if (common->mode == PCRE2_JIT_COMPLETE)
   return;


-if (!force)
+if (!force && !common->allow_empty_partial)
jump = CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
else if (common->mode == PCRE2_JIT_PARTIAL_SOFT)
jump = CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1);
@@ -3365,7 +3367,11 @@

 /* Partial matching mode. */
 jump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
-add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));
+if (!common->allow_empty_partial)
+  add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));
+else if (common->mode == PCRE2_JIT_PARTIAL_SOFT)
+  add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1));
+
 if (common->mode == PCRE2_JIT_PARTIAL_SOFT)
   {
   OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
@@ -8332,12 +8338,14 @@
     JUMPHERE(jump[3]);
     }
   JUMPHERE(jump[0]);
-  check_partial(common, FALSE);
+  if (common->mode != PCRE2_JIT_COMPLETE)
+    check_partial(common, TRUE);
   return cc;


   case OP_EOD:
   add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0));
-  check_partial(common, FALSE);
+  if (common->mode != PCRE2_JIT_COMPLETE)
+    check_partial(common, TRUE);
   return cc;


case OP_DOLL:
@@ -12642,7 +12650,7 @@
struct sljit_jump *cond = NULL;
struct sljit_label *rmin_label = NULL;
struct sljit_label *exact_label = NULL;
-struct sljit_put_label *put_label;
+struct sljit_put_label *put_label = NULL;

if (*cc == OP_BRAZERO || *cc == OP_BRAMINZERO)
{
@@ -13696,6 +13704,7 @@
common->lcc = (sljit_sw)(tables + lcc_offset);
common->mode = mode;
common->might_be_empty = re->minlength == 0;
+common->allow_empty_partial = (re->max_lookbehind > 0) || (re->flags & PCRE2_MATCH_EMPTY) != 0;
common->nltype = NLTYPE_FIXED;
switch(re->newline_convention)
{

Modified: code/trunk/src/sljit/sljitConfigInternal.h
===================================================================
--- code/trunk/src/sljit/sljitConfigInternal.h    2019-07-22 16:30:44 UTC (rev 1142)
+++ code/trunk/src/sljit/sljitConfigInternal.h    2019-07-23 12:34:58 UTC (rev 1143)
@@ -214,6 +214,10 @@
 #define SLJIT_MEMCPY(dest, src, len) memcpy(dest, src, len)
 #endif


+#ifndef SLJIT_MEMMOVE
+#define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
+#endif
+
#ifndef SLJIT_ZEROMEM
#define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
#endif

Modified: code/trunk/src/sljit/sljitNativeX86_64.c
===================================================================
--- code/trunk/src/sljit/sljitNativeX86_64.c    2019-07-22 16:30:44 UTC (rev 1142)
+++ code/trunk/src/sljit/sljitNativeX86_64.c    2019-07-23 12:34:58 UTC (rev 1143)
@@ -103,7 +103,7 @@
     }


     code_ptr -= put_label->flags + (2 + sizeof(sljit_uw));
-    SLJIT_MEMCPY(code_ptr, code_ptr + (2 + sizeof(sljit_uw)), put_label->flags);
+    SLJIT_MEMMOVE(code_ptr, code_ptr + (2 + sizeof(sljit_uw)), put_label->flags);


     SLJIT_ASSERT((code_ptr[0] & 0xf8) == REX_W);



Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2    2019-07-22 16:30:44 UTC (rev 1142)
+++ code/trunk/testdata/testinput2    2019-07-23 12:34:58 UTC (rev 1143)
@@ -5694,35 +5694,35 @@
 /(\2)((?=(?<=\1)))/


 /c*+(?<=[bc])/
-    abc\=ph,no_jit
-    ab\=ph,no_jit
-    abc\=ps,no_jit
-    ab\=ps,no_jit
+    abc\=ph
+    ab\=ph
+    abc\=ps
+    ab\=ps


 /c++(?<=[bc])/
-    abc\=ph,no_jit
-    ab\=ph,no_jit
+    abc\=ph
+    ab\=ph


 /(?<=(?=.(?<=x)))/
     abx
-    ab\=ph,no_jit
+    ab\=ph
     bxyz 
     xyz


 /\z/
-   abc\=ph,no_jit 
+   abc\=ph
    abc\=ps 


 /\Z/
-   abc\=ph,no_jit 
+   abc\=ph
    abc\=ps 
-   abc\n\=ph,no_jit
+   abc\n\=ph
    abc\n\=ps


 /(?![ab]).*/
-    ab\=ph,no_jit
+    ab\=ph


 /c*+/
-    ab\=ph,offset=2,no_jit
+    ab\=ph,offset=2


# End of testinput2

Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2    2019-07-22 16:30:44 UTC (rev 1142)
+++ code/trunk/testdata/testoutput2    2019-07-23 12:34:58 UTC (rev 1143)
@@ -17190,25 +17190,25 @@
 Failed: error 125 at offset 8: lookbehind assertion is not fixed length


 /c*+(?<=[bc])/
-    abc\=ph,no_jit
+    abc\=ph
 Partial match: c
-    ab\=ph,no_jit
+    ab\=ph
 Partial match: 
-    abc\=ps,no_jit
+    abc\=ps
  0: c
-    ab\=ps,no_jit
+    ab\=ps
  0: 


 /c++(?<=[bc])/
-    abc\=ph,no_jit
+    abc\=ph
 Partial match: c
-    ab\=ph,no_jit
+    ab\=ph
 Partial match: 


 /(?<=(?=.(?<=x)))/
     abx
  0: 
-    ab\=ph,no_jit
+    ab\=ph
 Partial match: 
     bxyz 
  0: 
@@ -17216,27 +17216,27 @@
  0: 


 /\z/
-   abc\=ph,no_jit 
+   abc\=ph
 Partial match: 
    abc\=ps 
  0: 


 /\Z/
-   abc\=ph,no_jit 
+   abc\=ph
 Partial match: 
    abc\=ps 
  0: 
-   abc\n\=ph,no_jit
+   abc\n\=ph
 Partial match: \x0a
    abc\n\=ps
  0: 


 /(?![ab]).*/
-    ab\=ph,no_jit
+    ab\=ph
 Partial match: 


 /c*+/
-    ab\=ph,offset=2,no_jit
+    ab\=ph,offset=2
 Partial match: 


# End of testinput2