Skip to content

Commit 023039f

Browse files
committed
Remove object auto-vivification leftovers in type-inference
undef/null/false no longer get promoted to object in PHP 8. In fact, we may drop the SSA var defs outside RC inference mode now.
1 parent 66d8d0c commit 023039f

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,14 +2525,8 @@ static zend_always_inline int _zend_update_type_info(
25252525
}
25262526
} else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
25272527
if (opline->op1_type == IS_CV) {
2528-
if (!(orig & MAY_BE_REF)) {
2529-
if (orig & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
2530-
orig &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
2531-
orig |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
2532-
}
2533-
if (orig & MAY_BE_OBJECT) {
2534-
orig |= (MAY_BE_RC1|MAY_BE_RCN);
2535-
}
2528+
if (orig & MAY_BE_OBJECT) {
2529+
orig |= (MAY_BE_RC1|MAY_BE_RCN);
25362530
}
25372531
UPDATE_SSA_TYPE(orig, ssa_op->op1_def);
25382532
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);
@@ -2741,10 +2735,6 @@ static zend_always_inline int _zend_update_type_info(
27412735
case ZEND_ASSIGN_OBJ:
27422736
if (opline->op1_type == IS_CV) {
27432737
tmp = t1;
2744-
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
2745-
tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
2746-
tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
2747-
}
27482738
if (tmp & MAY_BE_OBJECT) {
27492739
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
27502740
}
@@ -2791,10 +2781,6 @@ static zend_always_inline int _zend_update_type_info(
27912781
case ZEND_POST_DEC_OBJ:
27922782
if (opline->op1_type == IS_CV) {
27932783
tmp = t1;
2794-
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
2795-
tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
2796-
tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
2797-
}
27982784
if (tmp & MAY_BE_OBJECT) {
27992785
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
28002786
}
@@ -2870,10 +2856,6 @@ static zend_always_inline int _zend_update_type_info(
28702856
case ZEND_ASSIGN_OBJ_REF:
28712857
if (opline->op1_type == IS_CV) {
28722858
tmp = t1;
2873-
if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
2874-
tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
2875-
tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
2876-
}
28772859
if (tmp & MAY_BE_OBJECT) {
28782860
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
28792861
}

0 commit comments

Comments
 (0)