]> granicus.if.org Git - php/commitdiff
Various RC inference fixes
authorNikita Popov <nikic@php.net>
Fri, 14 Oct 2016 21:54:11 +0000 (23:54 +0200)
committerNikita Popov <nikic@php.net>
Sat, 15 Oct 2016 21:58:29 +0000 (23:58 +0200)
ext/opcache/Optimizer/zend_inference.c
ext/opcache/Optimizer/zend_ssa.c

index 36bad724f813b7b8d41f502bdec9237148264e09..33bab0e7c576a4377abf892c6686b9608e1a3490 100644 (file)
@@ -2022,7 +2022,7 @@ static int zend_infer_ranges(const zend_op_array *op_array, zend_ssa *ssa) /* {{
                uint32_t __type = (_type);                                                                              \
                int __var = (_var);                                                                                             \
                if (__type & MAY_BE_REF) {                                                                              \
-                       __type |= MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; \
+                       __type |= MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; \
                }                                                                                                                               \
                if (__var >= 0) {                                                                                               \
                        if (ssa_vars[__var].var < op_array->last_var) {                         \
@@ -2527,8 +2527,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
                                                   (tmp & (MAY_BE_ARRAY|MAY_BE_OBJECT))) {
                                                        tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                        } else if (opline->extended_value == IS_STRING &&
-                                                  (t1 & MAY_BE_STRING) &&
-                                                  (opline->op1_type == IS_CV)) {
+                                                  (t1 & MAY_BE_STRING)) {
                                                tmp |= MAY_BE_RC1 | MAY_BE_RCN;
                                        } else {
                                                tmp |= MAY_BE_RC1;
@@ -2783,7 +2782,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
                                if (t1 & MAY_BE_STRING) {
                                        tmp |= MAY_BE_STRING;
                                }
-                               if (t1 & (MAY_BE_ANY - MAY_BE_STRING)) {
+                               if (t1 & ((MAY_BE_ANY|MAY_BE_UNDEF) - MAY_BE_STRING)) {
                                        tmp |= (OP1_DATA_INFO() & (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF));
 
                                        if (opline->op2_type == IS_UNUSED) {
@@ -2796,7 +2795,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
                                                tmp |= MAY_BE_NULL;
                                        }
                                        if (t1 & (MAY_BE_ANY - (MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING | MAY_BE_ARRAY))) {
-                                               /* null and false are implicitly converted to array, anything else
+                                               /* undef, null and false are implicitly converted to array, anything else
                                                 * results in a null return value. */
                                                tmp |= MAY_BE_NULL;
                                        }
@@ -2948,7 +2947,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
                case ZEND_YIELD:
                        if (ssa_ops[i].op1_def >= 0) {
                                if (op_array->fn_flags & ZEND_ACC_RETURN_REFERENCE) {
-                                       tmp = t1 & MAY_BE_REF;
+                                       tmp = t1 | MAY_BE_REF;
                                } else {
                                        tmp = t1 & ~(MAY_BE_RC1|MAY_BE_RCN);
                                        if (t1 & (MAY_BE_RC1|MAY_BE_RCN)) {
index 936079396cf9e0f26308616f3a4e25088d3ef115..a0a2df92de95270f3cf6d3db3580b49cffffd76f 100644 (file)
@@ -590,33 +590,33 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags,
                        }
                        switch (opline->opcode) {
                                case ZEND_ASSIGN:
-                                       if (opline->op1_type == IS_CV) {
-                                               ssa_ops[k].op1_def = ssa_vars_count;
-                                               var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
-                                               ssa_vars_count++;
-                                               //NEW_SSA_VAR(opline->op1.var)
-                                       }
                                        if ((build_flags & ZEND_SSA_RC_INFERENCE) && opline->op2_type == IS_CV) {
                                                ssa_ops[k].op2_def = ssa_vars_count;
                                                var[EX_VAR_TO_NUM(opline->op2.var)] = ssa_vars_count;
                                                ssa_vars_count++;
                                                //NEW_SSA_VAR(opline->op2.var)
                                        }
-                                       break;
-                               case ZEND_ASSIGN_REF:
-//TODO: ???
                                        if (opline->op1_type == IS_CV) {
                                                ssa_ops[k].op1_def = ssa_vars_count;
                                                var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
                                                ssa_vars_count++;
                                                //NEW_SSA_VAR(opline->op1.var)
                                        }
+                                       break;
+                               case ZEND_ASSIGN_REF:
+//TODO: ???
                                        if (opline->op2_type == IS_CV) {
                                                ssa_ops[k].op2_def = ssa_vars_count;
                                                var[EX_VAR_TO_NUM(opline->op2.var)] = ssa_vars_count;
                                                ssa_vars_count++;
                                                //NEW_SSA_VAR(opline->op2.var)
                                        }
+                                       if (opline->op1_type == IS_CV) {
+                                               ssa_ops[k].op1_def = ssa_vars_count;
+                                               var[EX_VAR_TO_NUM(opline->op1.var)] = ssa_vars_count;
+                                               ssa_vars_count++;
+                                               //NEW_SSA_VAR(opline->op1.var)
+                                       }
                                        break;
                                case ZEND_BIND_GLOBAL:
                                case ZEND_BIND_STATIC: