Support end anchored in JIT.

This commit is contained in:
Zoltán Herczeg 2017-04-13 11:52:36 +00:00
parent bd511d381f
commit 1379a48d94
3 changed files with 10 additions and 10 deletions

View File

@ -9554,6 +9554,9 @@ if (*cc == OP_FAIL)
return cc + 1; return cc + 1;
} }
if (*cc == OP_ACCEPT && common->currententry == NULL && (common->re->overall_options & PCRE2_ENDANCHORED) != 0)
add_jump(compiler, &common->reset_match, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, STR_END, 0));
if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL || !common->might_be_empty) if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL || !common->might_be_empty)
{ {
/* No need to check notempty conditions. */ /* No need to check notempty conditions. */
@ -11295,6 +11298,7 @@ struct sljit_jump *jump;
struct sljit_jump *minlength_check_failed = NULL; struct sljit_jump *minlength_check_failed = NULL;
struct sljit_jump *reqbyte_notfound = NULL; struct sljit_jump *reqbyte_notfound = NULL;
struct sljit_jump *empty_match = NULL; struct sljit_jump *empty_match = NULL;
struct sljit_jump *end_anchor_failed = NULL;
SLJIT_ASSERT(tables); SLJIT_ASSERT(tables);
@ -11577,6 +11581,9 @@ if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
return PCRE2_ERROR_NOMEMORY; return PCRE2_ERROR_NOMEMORY;
} }
if ((re->overall_options & PCRE2_ENDANCHORED) != 0)
end_anchor_failed = CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, STR_END, 0);
if (common->might_be_empty) if (common->might_be_empty)
{ {
empty_match = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0)); empty_match = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
@ -11598,6 +11605,9 @@ if (minlength_check_failed != NULL)
SET_LABEL(minlength_check_failed, common->forced_quit_label); SET_LABEL(minlength_check_failed, common->forced_quit_label);
sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0); sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
if ((re->overall_options & PCRE2_ENDANCHORED) != 0)
JUMPHERE(end_anchor_failed);
if (mode != PCRE2_JIT_COMPLETE) if (mode != PCRE2_JIT_COMPLETE)
{ {
common->partialmatchlabel = LABEL(); common->partialmatchlabel = LABEL();

5
testdata/testinput2 vendored
View File

@ -5011,9 +5011,6 @@ a)"xI
/(a(*MARK:m)(*ACCEPT)){0}(?1)/mark /(a(*MARK:m)(*ACCEPT)){0}(?1)/mark
abc abc
# Temporary, until JIT is updated.
#subject no_jit
/abc/endanchored /abc/endanchored
xyzabc xyzabc
\= Expect no match \= Expect no match
@ -5041,8 +5038,6 @@ a)"xI
/a(*ACCEPT)x|aa/endanchored /a(*ACCEPT)x|aa/endanchored
aaa aaa
#subject -no_jit
# Check auto-anchoring when there is a group that is never obeyed at # Check auto-anchoring when there is a group that is never obeyed at
# the start of a branch. # the start of a branch.

View File

@ -15537,9 +15537,6 @@ No match
0: a 0: a
MK: m MK: m
# Temporary, until JIT is updated.
#subject no_jit
/abc/endanchored /abc/endanchored
xyzabc xyzabc
0: abc 0: abc
@ -15578,8 +15575,6 @@ No match
aaa aaa
0: a 0: a
#subject -no_jit
# Check auto-anchoring when there is a group that is never obeyed at # Check auto-anchoring when there is a group that is never obeyed at
# the start of a branch. # the start of a branch.