Merge branch 'PHP-8.2'

* PHP-8.2:
  JIT: Fixed inaccurate range inference usage for UNDEF/NULL/FALSE
This commit is contained in:
Dmitry Stogov 2023-05-02 12:04:11 +03:00
commit f0122664fe
3 changed files with 25 additions and 2 deletions

View File

@ -4829,7 +4829,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
op2_reg = Z_REG(op2_addr);
}
if (!op2_range || (op2_range->min <= 0 && op2_range->max >= 0)) {
if ((op2_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) || !op2_range || (op2_range->min <= 0 && op2_range->max >= 0)) {
| cbz Rx(op2_reg), >1
|.cold_code
|1:

View File

@ -5286,7 +5286,7 @@ static int zend_jit_long_math_helper(dasm_State **Dst,
}
}
} else {
if (!op2_range || (op2_range->min <= 0 && op2_range->max >= 0)) {
if ((op2_type & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) || !op2_range || (op2_range->min <= 0 && op2_range->max >= 0)) {
if (Z_MODE(op2_addr) == IS_MEM_ZVAL) {
| cmp aword [Ra(Z_REG(op2_addr))+Z_OFFSET(op2_addr)], 0
} else if (Z_MODE(op2_addr) == IS_REG) {

View File

@ -0,0 +1,23 @@
--TEST--
JIT MOD: 007
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--FILE--
<?php
function test($a) {
for(;$a < -2;) {
$n % $n = $a + $a;
}
}
test(null);
?>
--EXPECTF--
Fatal error: Uncaught DivisionByZeroError: Modulo by zero in %smod_007.php:4
Stack trace:
#0 %smod_007.php(7): test(NULL)
#1 {main}
thrown in %smod_007.php on line 4