Fix issues in the early fail optimization.

This commit is contained in:
Zoltán Herczeg 2020-03-06 09:23:10 +00:00
parent 21c40e638b
commit 0d0d954bbd
1 changed files with 39 additions and 17 deletions

View File

@ -1285,13 +1285,19 @@ do
case OP_ANY: case OP_ANY:
case OP_ALLANY: case OP_ALLANY:
case OP_ANYBYTE: case OP_ANYBYTE:
case OP_ANYNL:
case OP_NOT_HSPACE: case OP_NOT_HSPACE:
case OP_HSPACE: case OP_HSPACE:
case OP_NOT_VSPACE: case OP_NOT_VSPACE:
case OP_VSPACE: case OP_VSPACE:
fast_forward_allowed = FALSE;
cc++;
continue;
case OP_ANYNL:
case OP_EXTUNI: case OP_EXTUNI:
fast_forward_allowed = FALSE; fast_forward_allowed = FALSE;
if (count == 0)
count = 1;
cc++; cc++;
continue; continue;
@ -1337,6 +1343,7 @@ do
case OP_TYPEEXACT: case OP_TYPEEXACT:
case OP_TYPEPOSUPTO: case OP_TYPEPOSUPTO:
cc += IMM2_SIZE; cc += IMM2_SIZE;
/* Fall through */
case OP_TYPEQUERY: case OP_TYPEQUERY:
case OP_TYPEMINQUERY: case OP_TYPEMINQUERY:
@ -1399,6 +1406,7 @@ do
case OP_NOTEXACTI: case OP_NOTEXACTI:
case OP_NOTPOSUPTOI: case OP_NOTPOSUPTOI:
cc += IMM2_SIZE; cc += IMM2_SIZE;
/* Fall through */
case OP_QUERY: case OP_QUERY:
case OP_MINQUERY: case OP_MINQUERY:
@ -1425,27 +1433,41 @@ do
case OP_NCLASS: case OP_NCLASS:
#if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8 #if defined SUPPORT_UNICODE || PCRE2_CODE_UNIT_WIDTH != 8
case OP_XCLASS: case OP_XCLASS:
end = cc + ((*cc == OP_XCLASS) ? GET(cc, 1) : (unsigned int)(1 + (32 / sizeof(PCRE2_UCHAR)))); accelerated_start = cc;
cc += ((*cc == OP_XCLASS) ? GET(cc, 1) : (unsigned int)(1 + (32 / sizeof(PCRE2_UCHAR))));
#else #else
end = cc + (1 + (32 / sizeof(PCRE2_UCHAR))); accelerated_start = cc;
cc += (1 + (32 / sizeof(PCRE2_UCHAR)));
#endif #endif
if ((*end >= OP_CRSTAR && *end <= OP_CRMINPLUS) || (*end >= OP_CRPOSSTAR && *end <= OP_CRPOSPLUS)) switch (*cc)
{ {
accelerated_start = cc; case OP_CRSTAR:
cc = end + 1; case OP_CRMINSTAR:
case OP_CRPLUS:
case OP_CRMINPLUS:
case OP_CRPOSSTAR:
case OP_CRPOSPLUS:
cc++;
break; break;
}
fast_forward_allowed = FALSE; case OP_CRRANGE:
case OP_CRMINRANGE:
case OP_CRPOSRANGE:
cc += 2 * IMM2_SIZE;
/* Fall through */
case OP_CRQUERY:
case OP_CRMINQUERY:
case OP_CRPOSQUERY:
cc++;
if (count == 0) if (count == 0)
count = 1; count = 1;
/* Fall through */
cc = end; default:
if (*end == OP_CRQUERY || *end == OP_CRMINQUERY || *end == OP_CRPOSQUERY) accelerated_start = NULL;
cc++; fast_forward_allowed = FALSE;
else if (*end == OP_CRRANGE || *end == OP_CRMINRANGE || *end == OP_CRPOSRANGE) break;
cc += 1 + 2 * IMM2_SIZE; }
continue; continue;
case OP_ONCE: case OP_ONCE: