Skip to content

Commit b4ccc52

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix incorrect elimination of type store
2 parents 5459ed4 + c29f6ba commit b4ccc52

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2923,7 +2923,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29232923
if (opline->result_type != IS_UNUSED) {
29242924
res_use_info = -1;
29252925

2926-
if (opline->result_type == IS_CV) {
2926+
if (opline->result_type == IS_CV
2927+
&& ssa_op->result_use >= 0
2928+
&& !ssa->vars[ssa_op->result_use].no_val) {
29272929
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
29282930

29292931
if (Z_MODE(res_use_addr) != IS_REG
@@ -2981,7 +2983,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
29812983
} else {
29822984
res_use_info = -1;
29832985

2984-
if (opline->result_type == IS_CV) {
2986+
if (opline->result_type == IS_CV
2987+
&& ssa_op->result_use >= 0
2988+
&& !ssa->vars[ssa_op->result_use].no_val) {
29852989
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
29862990

29872991
if (Z_MODE(res_use_addr) != IS_REG
@@ -3032,7 +3036,9 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
30323036
} else {
30333037
res_use_info = -1;
30343038

3035-
if (opline->result_type == IS_CV) {
3039+
if (opline->result_type == IS_CV
3040+
&& ssa_op->result_use >= 0
3041+
&& !ssa->vars[ssa_op->result_use].no_val) {
30363042
zend_jit_addr res_use_addr = RES_USE_REG_ADDR();
30373043

30383044
if (Z_MODE(res_use_addr) != IS_REG

ext/opcache/tests/jit/mul_008.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
JIT MUL: 008 incorrect elimination of type store
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--SKIPIF--
10+
<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
11+
--FILE--
12+
<?php
13+
function foo(int $a){
14+
$a=$a%10;
15+
$a=$f=$a*(6158978401740);
16+
$a=$f=$a*(261740);
17+
$a%0;
18+
}
19+
foo(3);
20+
?>
21+
--EXPECTF--
22+
Fatal error: Uncaught DivisionByZeroError: Modulo by zero in %smul_008.php:6
23+
Stack trace:
24+
#0 %smul_008.php(8): foo(%d)
25+
#1 {main}
26+
thrown in %smul_008.php on line 6

0 commit comments

Comments
 (0)