Skip to content

Commit 02fae1f

Browse files
committed
Fixed bug #79888 (Incorrect execution with JIT enabled)
1 parent ee7eecf commit 02fae1f

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010

1111
- JIT:
1212
. Fixed bug #79864 (JIT segfault in Symfony OptionsResolver). (Dmitry)
13+
. Fixed bug #79888 (Incorrect execution with JIT enabled). (Dmitry)
1314

1415
- LDAP:
1516
. Fixed memory leaks. (ptomulik)

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12576,7 +12576,10 @@ static zend_regset zend_jit_get_scratch_regset(const zend_op *opline, const zend
1257612576
}
1257712577
} else {
1257812578
ZEND_REGSET_INCL(regset, ZREG_R0);
12579-
ZEND_REGSET_INCL(regset, ZREG_R1);
12579+
ZEND_REGSET_INCL(regset, ZREG_R2);
12580+
if (opline->op2_type == IS_CONST) {
12581+
ZEND_REGSET_INCL(regset, ZREG_R1);
12582+
}
1258012583
}
1258112584
}
1258212585
break;

ext/opcache/tests/jit/bug79888.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug #79888 (Incorrect execution with JIT enabled)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=64
8+
opcache.jit=1205
9+
--SKIPIF--
10+
<?php require_once('skipif.inc'); ?>
11+
--FILE--
12+
<?php
13+
function testPrime(int $a): bool {
14+
if ($a < 2) {
15+
return false;
16+
} else if ($a == 2) {
17+
return true;
18+
}
19+
for ($j = 2; $j < $a; $j++) {
20+
if (($a % $j) == 0) {
21+
return false;
22+
}
23+
}
24+
return true;
25+
}
26+
27+
$max = 1000;
28+
$cnt = 0;
29+
echo "Testing Primes until: " . $max . "\n";
30+
for ($i = 2; $i <= $max; $i++)
31+
{
32+
if (testPrime($i)) $cnt++;
33+
}
34+
echo "Primect: {$cnt}\n";
35+
?>
36+
--EXPECT--
37+
Testing Primes until: 1000
38+
Primect: 168

0 commit comments

Comments
 (0)