Skip to content

Commit 13d1244

Browse files
committed
Tracing JIT: Fixed ADD with two references to arrays
1 parent 6021e72 commit 13d1244

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4659,7 +4659,7 @@ static int zend_jit_math_helper(dasm_State **Dst,
46594659
{
46604660
zend_bool same_ops = zend_jit_same_addr(op1_addr, op2_addr);
46614661

4662-
if ((op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG)) {
4662+
if ((op1_info & MAY_BE_LONG) && (op2_info & MAY_BE_LONG) && (res_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
46634663
if (op1_info & (MAY_BE_ANY-MAY_BE_LONG)) {
46644664
if (op1_info & MAY_BE_DOUBLE) {
46654665
| IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >3
@@ -4720,7 +4720,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
47204720
}
47214721
} else if ((op1_info & MAY_BE_DOUBLE) &&
47224722
!(op1_info & MAY_BE_LONG) &&
4723-
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
4723+
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4724+
(res_info & MAY_BE_DOUBLE)) {
47244725
if (op1_info & (MAY_BE_ANY-MAY_BE_DOUBLE)) {
47254726
| IF_NOT_ZVAL_TYPE op1_addr, IS_DOUBLE, >6
47264727
}
@@ -4754,7 +4755,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
47544755
}
47554756
} else if ((op2_info & MAY_BE_DOUBLE) &&
47564757
!(op2_info & MAY_BE_LONG) &&
4757-
(op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
4758+
(op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4759+
(res_info & MAY_BE_DOUBLE)) {
47584760
if (op2_info & (MAY_BE_ANY-MAY_BE_DOUBLE)) {
47594761
| IF_NOT_ZVAL_TYPE op2_addr, IS_DOUBLE, >6
47604762
}
@@ -4793,7 +4795,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
47934795
if ((op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_LONG|MAY_BE_DOUBLE))) ||
47944796
(op2_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_LONG|MAY_BE_DOUBLE)))) {
47954797
if ((op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4796-
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
4798+
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4799+
(res_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
47974800
|.cold_code
47984801
}
47994802
|6:
@@ -4855,7 +4858,8 @@ static int zend_jit_math_helper(dasm_State **Dst,
48554858
}
48564859
}
48574860
if ((op1_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4858-
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
4861+
(op2_info & (MAY_BE_LONG|MAY_BE_DOUBLE)) &&
4862+
(res_info & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
48594863
| jmp <5
48604864
|.code
48614865
}

ext/opcache/tests/jit/add_009.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
JIT ADD: 009 two array references
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
$a = [];
11+
var_dump(($b =& $a) + ($b =& $a));
12+
?>
13+
--EXPECT--
14+
array(0) {
15+
}

0 commit comments

Comments
 (0)