Skip to content

Commit 4896337

Browse files
committed
Improved reference-counting inference
1 parent 0280c64 commit 4896337

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3394,7 +3394,7 @@ static zend_always_inline int _zend_update_type_info(
33943394
break;
33953395
case ZEND_FETCH_THIS:
33963396
UPDATE_SSA_OBJ_TYPE(op_array->scope, 1, ssa_op->result_def);
3397-
UPDATE_SSA_TYPE(MAY_BE_RC1|MAY_BE_RCN|MAY_BE_OBJECT, ssa_op->result_def);
3397+
UPDATE_SSA_TYPE(MAY_BE_RCN|MAY_BE_OBJECT, ssa_op->result_def);
33983398
break;
33993399
case ZEND_FETCH_OBJ_R:
34003400
case ZEND_FETCH_OBJ_IS:
@@ -3408,20 +3408,22 @@ static zend_always_inline int _zend_update_type_info(
34083408
tmp = zend_fetch_prop_type(script, prop_info, &ce);
34093409
if (opline->result_type != IS_TMP_VAR) {
34103410
tmp |= MAY_BE_REF | MAY_BE_INDIRECT;
3411-
} else if (prop_info) {
3412-
/* FETCH_OBJ_R/IS for plain property increments reference counter,
3413-
so it can't be 1 */
3414-
tmp &= ~MAY_BE_RC1;
3415-
} else {
3416-
zend_class_entry *ce = NULL;
3417-
3418-
if (opline->op1_type == IS_UNUSED) {
3419-
ce = op_array->scope;
3420-
} else if (ssa_op->op1_use >= 0 && !ssa->var_info[ssa_op->op1_use].is_instanceof) {
3421-
ce = ssa->var_info[ssa_op->op1_use].ce;
3422-
}
3423-
if (ce && !ce->create_object && !ce->__get) {
3411+
} else if (!(opline->op1_type & (IS_VAR|IS_TMP_VAR)) || !(t1 & MAY_BE_RC1)) {
3412+
if (prop_info) {
3413+
/* FETCH_OBJ_R/IS for plain property increments reference counter,
3414+
so it can't be 1 */
34243415
tmp &= ~MAY_BE_RC1;
3416+
} else {
3417+
zend_class_entry *ce = NULL;
3418+
3419+
if (opline->op1_type == IS_UNUSED) {
3420+
ce = op_array->scope;
3421+
} else if (ssa_op->op1_use >= 0 && !ssa->var_info[ssa_op->op1_use].is_instanceof) {
3422+
ce = ssa->var_info[ssa_op->op1_use].ce;
3423+
}
3424+
if (ce && !ce->create_object && !ce->__get) {
3425+
tmp &= ~MAY_BE_RC1;
3426+
}
34253427
}
34263428
}
34273429
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);

0 commit comments

Comments
 (0)