]> granicus.if.org Git - php/commitdiff
Remove object auto-vivification leftovers in type-inference
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Mar 2020 13:53:13 +0000 (14:53 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 17 Mar 2020 13:54:11 +0000 (14:54 +0100)
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.

ext/opcache/Optimizer/zend_inference.c

index 8db27f86e60493b714bef328d390db8dc5248577..8c80c29e25c17d1179b64e4fdfaa2937b212abeb 100644 (file)
@@ -2525,14 +2525,8 @@ static zend_always_inline int _zend_update_type_info(
                                }
                        } else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
                                if (opline->op1_type == IS_CV) {
-                                       if (!(orig & MAY_BE_REF)) {
-                                               if (orig & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
-                                                       orig &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
-                                                       orig |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
-                                               }
-                                               if (orig & MAY_BE_OBJECT) {
-                                                       orig |= (MAY_BE_RC1|MAY_BE_RCN);
-                                               }
+                                       if (orig & MAY_BE_OBJECT) {
+                                               orig |= (MAY_BE_RC1|MAY_BE_RCN);
                                        }
                                        UPDATE_SSA_TYPE(orig, ssa_op->op1_def);
                                        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(
                case ZEND_ASSIGN_OBJ:
                        if (opline->op1_type == IS_CV) {
                                tmp = t1;
-                               if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
-                                       tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
-                                       tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
-                               }
                                if (tmp & MAY_BE_OBJECT) {
                                        tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                }
@@ -2791,10 +2781,6 @@ static zend_always_inline int _zend_update_type_info(
                case ZEND_POST_DEC_OBJ:
                        if (opline->op1_type == IS_CV) {
                                tmp = t1;
-                               if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
-                                       tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
-                                       tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
-                               }
                                if (tmp & MAY_BE_OBJECT) {
                                        tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                }
@@ -2870,10 +2856,6 @@ static zend_always_inline int _zend_update_type_info(
                case ZEND_ASSIGN_OBJ_REF:
                        if (opline->op1_type == IS_CV) {
                                tmp = t1;
-                               if (t1 & (MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE)) {
-                                       tmp &= ~(MAY_BE_UNDEF|MAY_BE_NULL|MAY_BE_FALSE);
-                                       tmp |= MAY_BE_OBJECT | MAY_BE_RC1 | MAY_BE_RCN;
-                               }
                                if (tmp & MAY_BE_OBJECT) {
                                        tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                }