[php-src] PR #19680: Fix deoptimization after exit during POST_(INC|DEC)
| From: | arnaud-lb | Date: | Wed, 03 Sep 2025 10:10:42 +0000 |
| Subject: | [php-src] PR #19680: Fix deoptimization after exit during POST_(INC|DEC) | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33048@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19680
Author: arnaud-lb
Fixes GH-19669
When the assumption that
POST_(INC|DEC) overflows turns out to be false, we don't
reconstruct the result variable on exit.
Fix by updating stack info before creating the exit point.
I need to check if other guards in zend_jit_inc_dec are possibly affected.
Analysis of the reproducer:
``` php
function test() {
$a = PHP_INT_MIN;
$b = 0;
while ($b++ < 2) {
$a = (int) ($a-- + $a - $b);
}
return $a;
}
```
Opcodes:
```
0003 T2 = POST_DEC CV0($a)
0004 T3 = ADD T2 CV0($a)
0005 T2 = SUB T3 CV1($b)
```
* POST_DEC is expect to underflow, so a guard is emitted
* The guard fails at some point
* During compilation of a side trace, the type of T2 in ADD T2 CV0($a)
doesn't match type inference, which causes the assertion failure. This is because exiting from
POST_DEC CV0($a) didn't update T2.