Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #81424: PCRE2 10.35 JIT performance regression #7573

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ext/pcre/pcre2lib/pcre2_jit_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,10 +1249,13 @@ SLJIT_ASSERT(*cc == OP_ONCE || *cc == OP_BRA || *cc == OP_CBRA);
SLJIT_ASSERT(*cc != OP_CBRA || common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] != 0);
SLJIT_ASSERT(start < EARLY_FAIL_ENHANCE_MAX);

next_alt = cc + GET(cc, 1);
if (*next_alt == OP_ALT)
fast_forward_allowed = FALSE;

do
{
count = start;
next_alt = cc + GET(cc, 1);
cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0);

while (TRUE)
Expand Down Expand Up @@ -1521,7 +1524,7 @@ do
{
count++;

if (fast_forward_allowed && *next_alt == OP_KET)
if (fast_forward_allowed)
{
common->fast_forward_bc_ptr = accelerated_start;
common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip;
Expand Down Expand Up @@ -1569,8 +1572,8 @@ do
else if (result < count)
result = count;

fast_forward_allowed = FALSE;
cc = next_alt;
next_alt = cc + GET(cc, 1);
}
while (*cc == OP_ALT);

Expand Down Expand Up @@ -11152,7 +11155,7 @@ early_fail_type = (early_fail_ptr & 0x7);
early_fail_ptr >>= 3;

/* During recursion, these optimizations are disabled. */
if (common->early_fail_start_ptr == 0)
if (common->early_fail_start_ptr == 0 && common->fast_forward_bc_ptr == NULL)
{
early_fail_ptr = 0;
early_fail_type = type_skip;
Expand Down
18 changes: 18 additions & 0 deletions ext/pcre/tests/bug81424a.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Bug #81424 (PCRE2 10.35 JIT performance regression)
--DESCRIPTION--
We're testing against the functional regression which has been introduced by
fixing the performance regression.
--FILE--
<?php
var_dump(
preg_match('/(?P<size>\d+)m|M/', "4M", $m),
$m
);
?>
--EXPECT--
int(1)
array(1) {
[0]=>
string(1) "M"
}