mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix #81424: PCRE2 10.35 JIT performance regression
We backport the respective upstream fix[1] to our bundled pcre2lib plus the follow-up fix[2] for a functional regression. [1] <dc5f966635
> [2] <e7af7efaa1
> Closes GH-7573.
This commit is contained in:
parent
fcabe693ba
commit
788a701e22
3 changed files with 28 additions and 4 deletions
3
NEWS
3
NEWS
|
@ -5,6 +5,9 @@ PHP NEWS
|
||||||
- MySQLi:
|
- MySQLi:
|
||||||
. Fixed bug #81494 (Stopped unbuffered query does not throw error). (Nikita)
|
. Fixed bug #81494 (Stopped unbuffered query does not throw error). (Nikita)
|
||||||
|
|
||||||
|
- PCRE:
|
||||||
|
. Fixed bug #81424 (PCRE2 10.35 JIT performance regression). (cmb)
|
||||||
|
|
||||||
- Streams:
|
- Streams:
|
||||||
. Fixed bug #54340 (Memory corruption with user_filter). (Nikita)
|
. Fixed bug #54340 (Memory corruption with user_filter). (Nikita)
|
||||||
|
|
||||||
|
|
|
@ -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(*cc != OP_CBRA || common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] != 0);
|
||||||
SLJIT_ASSERT(start < EARLY_FAIL_ENHANCE_MAX);
|
SLJIT_ASSERT(start < EARLY_FAIL_ENHANCE_MAX);
|
||||||
|
|
||||||
|
next_alt = cc + GET(cc, 1);
|
||||||
|
if (*next_alt == OP_ALT)
|
||||||
|
fast_forward_allowed = FALSE;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
count = start;
|
count = start;
|
||||||
next_alt = cc + GET(cc, 1);
|
|
||||||
cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0);
|
cc += 1 + LINK_SIZE + ((*cc == OP_CBRA) ? IMM2_SIZE : 0);
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
|
@ -1521,7 +1524,7 @@ do
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (fast_forward_allowed && *next_alt == OP_KET)
|
if (fast_forward_allowed)
|
||||||
{
|
{
|
||||||
common->fast_forward_bc_ptr = accelerated_start;
|
common->fast_forward_bc_ptr = accelerated_start;
|
||||||
common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip;
|
common->private_data_ptrs[(accelerated_start + 1) - common->start] = ((*private_data_start) << 3) | type_skip;
|
||||||
|
@ -1569,8 +1572,8 @@ do
|
||||||
else if (result < count)
|
else if (result < count)
|
||||||
result = count;
|
result = count;
|
||||||
|
|
||||||
fast_forward_allowed = FALSE;
|
|
||||||
cc = next_alt;
|
cc = next_alt;
|
||||||
|
next_alt = cc + GET(cc, 1);
|
||||||
}
|
}
|
||||||
while (*cc == OP_ALT);
|
while (*cc == OP_ALT);
|
||||||
|
|
||||||
|
@ -11152,7 +11155,7 @@ early_fail_type = (early_fail_ptr & 0x7);
|
||||||
early_fail_ptr >>= 3;
|
early_fail_ptr >>= 3;
|
||||||
|
|
||||||
/* During recursion, these optimizations are disabled. */
|
/* 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_ptr = 0;
|
||||||
early_fail_type = type_skip;
|
early_fail_type = type_skip;
|
||||||
|
|
18
ext/pcre/tests/bug81424a.phpt
Normal file
18
ext/pcre/tests/bug81424a.phpt
Normal file
|
@ -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"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue