Skip to content

Commit c2aea6e

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fix incorrect reference counting inference
2 parents 517738b + 3564001 commit c2aea6e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,9 @@ static zend_always_inline zend_result _zend_update_type_info(
26572657
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP) {
26582658
/* Nothing to do */
26592659
} else {
2660+
if (opline->opcode == ZEND_ASSIGN_OP && ssa_op->result_def >= 0 && (tmp & MAY_BE_RC1)) {
2661+
tmp |= MAY_BE_RCN;
2662+
}
26602663
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
26612664
}
26622665
if (ssa_op->result_def >= 0) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
JIT ASSIGN_OP: 007 Arrays merging with return value
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 test() {
11+
$a = [];
12+
for ($i=0; $i < 2; $i++) {
13+
$a += $a + $a += $a;
14+
$a['b'] += 1;
15+
}
16+
}
17+
test();
18+
?>
19+
DONE
20+
--EXPECTF--
21+
Warning: Undefined array key "b" in %sassign_op_007.php on line 6
22+
DONE

0 commit comments

Comments
 (0)