Skip to content

Commit a23f3dd

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: JIT: Fix incorrect type store elimination
2 parents f4a3868 + 54c952f commit a23f3dd

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4867,14 +4867,16 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
48674867
break;
48684868
}
48694869
op2_addr = OP2_REG_ADDR();
4870+
op2_info = OP2_INFO();
48704871
if (ra
48714872
&& ssa_op->op2_def >= 0
4872-
&& !ssa->vars[ssa_op->op2_def].no_val) {
4873+
&& (!ssa->vars[ssa_op->op2_def].no_val
4874+
|| (zend_jit_trace_type_to_info(STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->op2.var))) & MAY_BE_ANY) !=
4875+
(op2_info & MAY_BE_ANY))) {
48734876
op2_def_addr = OP2_DEF_REG_ADDR();
48744877
} else {
48754878
op2_def_addr = op2_addr;
48764879
}
4877-
op2_info = OP2_INFO();
48784880
CHECK_OP2_TRACE_TYPE();
48794881
op1_info = OP1_INFO();
48804882
if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_GUARD)) == MAY_BE_LONG

ext/opcache/tests/jit/assign_050.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
JIT ASSIGN: incorrect type store elimination
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+
--FILE--
10+
<?php
11+
function foo($a) {
12+
$b = $a;
13+
$b =! $a = $a + $b & $b & $b = $b = $a = $a + $b & $a += $a;
14+
$b = $b = $a = $a + $b & $b & $b = $a = $a + $b = $b = $a = $a + $b = $a += $a;
15+
}
16+
17+
for ($i = 0; $i < 3; $i++) {
18+
@foo(39087589046889428661);
19+
}
20+
?>
21+
DONE
22+
--EXPECT--
23+
DONE

0 commit comments

Comments
 (0)