Skip to content

Commit 535a055

Browse files
committed
Fixed incorrect reference counter inference
1 parent 8fe8082 commit 535a055

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ static zend_always_inline int _zend_update_type_info(
25052505
}
25062506
if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) {
25072507
tmp |= (t1 & (MAY_BE_RC1|MAY_BE_RCN));
2508-
if (opline->op1_type == IS_CV) {
2508+
if (opline->opcode == ZEND_COPY_TMP || opline->op1_type == IS_CV) {
25092509
tmp |= MAY_BE_RCN;
25102510
}
25112511
}

ext/opcache/Optimizer/zend_ssa.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,14 @@ static zend_always_inline int _zend_ssa_rename_op(const zend_op_array *op_array,
770770
//NEW_SSA_VAR(opline->op2.var)
771771
}
772772
break;
773+
case ZEND_COPY_TMP:
774+
if (build_flags & ZEND_SSA_RC_INFERENCE) {
775+
ssa_ops[k].op1_def = ssa_vars_count;
776+
var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
777+
ssa_vars_count++;
778+
//NEW_SSA_VAR(opline->op1.var)
779+
}
780+
break;
773781
default:
774782
break;
775783
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
JIT COPY_TMP: 002
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+
$x[~"abc"] ??= 0;
12+
?>
13+
DONE
14+
--EXPECT--
15+
DONE

0 commit comments

Comments
 (0)