Skip to content

Commit fac3734

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix incorrect guard motion out of the loop
2 parents 21507ef + 69c10ae commit fac3734

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,17 @@ static int is_checked_guard(const zend_ssa *tssa, const zend_op **ssa_opcodes, u
10921092
&& (tssa->var_info[tssa->ops[idx].op2_use].type & MAY_BE_REF)) {
10931093
return 0;
10941094
}
1095+
if (!(tssa->var_info[tssa->ops[idx].op1_use].type & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
1096+
return 0;
1097+
}
1098+
if (opline->op2_type == IS_CONST) {
1099+
zval *zv = RT_CONSTANT(opline, opline->op2);
1100+
if (Z_TYPE_P(zv) != IS_LONG && Z_TYPE_P(zv) != IS_DOUBLE) {
1101+
return 0;
1102+
}
1103+
} else if (!(tssa->var_info[tssa->ops[idx].op2_use].type & (MAY_BE_LONG|MAY_BE_DOUBLE))) {
1104+
return 0;
1105+
}
10951106
return 1;
10961107
}
10971108
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
JIT ASSIGN_OP: 009 incorrect guard motion out of the loop
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+
function foo() {
11+
$x = $a = $c = 0;
12+
for($cnt=0;$cnt<6;$cnt++) {
13+
$a *= $a;
14+
for ($i = 0; $i <= .1; !$j++)
15+
for ($i = 0; $i <= .1; !$i++)
16+
for ($i = 0; $i << .1; !$i++);
17+
$x != $a ?: $c;
18+
$a = "3566715245541";
19+
}
20+
}
21+
@foo();
22+
@foo();
23+
@foo();
24+
?>
25+
DONE
26+
--EXPECT--
27+
DONE

0 commit comments

Comments
 (0)