Revision: 439
http://www.exim.org/viewvc/pcre2?view=rev&revision=439
Author: zherczeg
Date: 2015-11-16 08:30:48 +0000 (Mon, 16 Nov 2015)
Log Message:
-----------
Fix two offset_limit bug in JIT.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_jit_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2015-11-15 18:55:20 UTC (rev 438)
+++ code/trunk/ChangeLog 2015-11-16 08:30:48 UTC (rev 439)
@@ -312,7 +312,9 @@
93. Re-arrange valgrind support code in pcre2test to avoid spurious reports
with JIT (possibly caused by SSE2?).
+94. Support offset_limit in JIT.
+
Version 10.20 30-June-2015
--------------------------
Modified: code/trunk/src/pcre2_jit_compile.c
===================================================================
--- code/trunk/src/pcre2_jit_compile.c 2015-11-15 18:55:20 UTC (rev 438)
+++ code/trunk/src/pcre2_jit_compile.c 2015-11-16 08:30:48 UTC (rev 439)
@@ -3318,6 +3318,8 @@
&& (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
newlinecheck = TRUE;
+SLJIT_ASSERT(common->forced_quit_label == NULL);
+
if ((overall_options & PCRE2_FIRSTLINE) != 0)
{
/* Search for the end of the first line. */
@@ -3357,23 +3359,25 @@
/* Check whether offset limit is set and valid. */
SLJIT_ASSERT(common->match_end_ptr != 0);
+ OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
+ OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, offset_limit));
+ OP1(SLJIT_MOV, TMP2, 0, STR_END, 0);
+ end = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, (sljit_sw) PCRE2_UNSET);
OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, offset_limit));
- OP1(SLJIT_MOV, TMP1, 0, STR_END, 0);
- end = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, (sljit_sw) PCRE2_UNSET);
#if PCRE2_CODE_UNIT_WIDTH == 16
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);
+ OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
#elif PCRE2_CODE_UNIT_WIDTH == 32
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
+ OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 2);
#endif
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
- end2 = CMP(SLJIT_LESS_EQUAL, TMP1, 0, STR_END, 0);
- OP1(SLJIT_MOV, TMP1, 0, STR_END, 0);
+ OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));
+ OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
+ end2 = CMP(SLJIT_LESS_EQUAL, TMP2, 0, STR_END, 0);
+ OP1(SLJIT_MOV, TMP2, 0, STR_END, 0);
JUMPHERE(end2);
+ OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE2_ERROR_NOMATCH);
+ add_jump(compiler, &common->forced_quit, CMP(SLJIT_LESS, TMP2, 0, STR_PTR, 0));
JUMPHERE(end);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, TMP1, 0);
+ OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->match_end_ptr, TMP2, 0);
}
start = JUMP(SLJIT_JUMP);
@@ -11200,7 +11204,15 @@
/* There cannot be more newlines if PCRE2_FIRSTLINE is set. */
if ((re->overall_options & PCRE2_FIRSTLINE) == 0)
{
- CMPTO(SLJIT_LESS, STR_PTR, 0, (common->match_end_ptr == 0) ? STR_END : TMP1, 0, common->ff_newline_shortcut);
+ if (common->match_end_ptr != 0)
+ {
+ OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
+ OP1(SLJIT_MOV, STR_END, 0, TMP1, 0);
+ CMPTO(SLJIT_LESS, STR_PTR, 0, TMP1, 0, common->ff_newline_shortcut);
+ OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
+ }
+ else
+ CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, common->ff_newline_shortcut);
}
}
else
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2015-11-15 18:55:20 UTC (rev 438)
+++ code/trunk/testdata/testinput2 2015-11-16 08:30:48 UTC (rev 439)
@@ -4534,6 +4534,10 @@
\= Expect error
1234abcde\=offset_limit=4
+/^\w/m,use_offset_limit
+ \n..\naa\=offset_limit=3
+ \n..\naa\=offset_limit=4
+
/abcd/null_context
abcd\=null_context
\= Expect error
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2015-11-15 18:55:20 UTC (rev 438)
+++ code/trunk/testdata/testoutput2 2015-11-16 08:30:48 UTC (rev 439)
@@ -14604,6 +14604,12 @@
1234abcde\=offset_limit=4
Failed: error -56: offset limit set without PCRE2_USE_OFFSET_LIMIT
+/^\w/m,use_offset_limit
+ \n..\naa\=offset_limit=3
+No match
+ \n..\naa\=offset_limit=4
+ 0: a
+
/abcd/null_context
abcd\=null_context
0: abcd