[php-src] Issue #10896: JITTed code duplication problem
| From: | wxue1 | Date: | Tue, 21 Mar 2023 06:44:55 +0000 |
| Subject: | [php-src] Issue #10896: JITTed code duplication problem | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243951@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10896
Author: wxue1
### Description
The following code:
```php
<?php
function add($x){
return $x + 1;
}
$x = 0;
for($i = 0; $i < 1000; $i++) {
if($i % 10 == 0) {
$x = add($x);
}
if($i % 8 == 0) {
$x = add($x);
}
}
echo("x=$x\n");
?>
```
Duplicated JITTed code in this case:
```
---- TRACE 2 start (side trace 1/7) $main() /home/wxue/php-src/t2.php:12
0013 INIT_FCALL 1 112 string("add")
>init add
0014 SEND_VAR CV0($x) 1 ; op1(int)
0015 V2 = DO_UCALL
>enter add
0001 T1 = ADD CV0($x) int(1) ; op1(int)
0002 RETURN T1 ; op1(int)
<back /home/wxue/php-src/t2.php
0016 ASSIGN CV0($x) V2 ; op1(int) op2(int)
0017 PRE_INC CV1($i) ; op1(int)
---- TRACE 2 stop (link to 1)
---- TRACE 3 start (side trace 1/4) $main() /home/wxue/php-src/t2.php:9
0006 INIT_FCALL 1 112 string("add")
>init add
0007 SEND_VAR CV0($x) 1 ; op1(int)
0008 V2 = DO_UCALL
>enter add
0001 T1 = ADD CV0($x) int(1) ; op1(int)
0002 RETURN T1 ; op1(int)
<back /home/wxue/php-src/t2.php
0009 ASSIGN CV0($x) V2 ; op1(int) op2(int)
0010 T3 = MOD CV1($i) int(8) ; op1(int)
0011 T2 = IS_EQUAL T3 int(0) ; op1(int)
0012 ;JMPZ T2 0017
0017 PRE_INC CV1($i) ; op1(int)
---- TRACE 3 stop (link to 1)
```
But I expected the add function to be JITTed only once.
### PHP Version
PHP 8.1.4
### Operating System
Ubuntu 20.04