]> granicus.if.org Git - php/commitdiff
clanup
authorDmitry Stogov <dmitry@zend.com>
Wed, 29 Jun 2016 14:53:39 +0000 (17:53 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 29 Jun 2016 14:53:39 +0000 (17:53 +0300)
ext/opcache/Optimizer/zend_inference.c
ext/opcache/Optimizer/zend_ssa.c

index 6986abc8669f73a4dad7bb746f9a74b5937a5881..66201751bcb2b45177263e82fd065d6a942951b7 100644 (file)
@@ -3867,7 +3867,9 @@ void zend_func_return_info(const zend_op_array   *op_array,
                                }
 
                                if (opline->op1_type == IS_CONST) {
-                                       if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_NULL) {
+                                       zval *zv = CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants);
+
+                                       if (Z_TYPE_P(zv) == IS_NULL) {
                                                if (tmp_has_range < 0) {
                                                        tmp_has_range = 1;
                                                        tmp_range.underflow = 0;
@@ -3882,7 +3884,7 @@ void zend_func_return_info(const zend_op_array   *op_array,
                                                                tmp_range.max = MAX(tmp_range.max, 0);
                                                        }
                                                }
-                                       } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_FALSE) {
+                                       } else if (Z_TYPE_P(zv) == IS_FALSE) {
                                                if (tmp_has_range < 0) {
                                                        tmp_has_range = 1;
                                                        tmp_range.underflow = 0;
@@ -3897,7 +3899,7 @@ void zend_func_return_info(const zend_op_array   *op_array,
                                                                tmp_range.max = MAX(tmp_range.max, 0);
                                                        }
                                                }
-                                       } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_TRUE) {
+                                       } else if (Z_TYPE_P(zv) == IS_TRUE) {
                                                if (tmp_has_range < 0) {
                                                        tmp_has_range = 1;
                                                        tmp_range.underflow = 0;
@@ -3912,19 +3914,19 @@ void zend_func_return_info(const zend_op_array   *op_array,
                                                                tmp_range.max = MAX(tmp_range.max, 1);
                                                        }
                                                }
-                                       } else if (Z_TYPE_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)) == IS_LONG) {
+                                       } else if (Z_TYPE_P(zv) == IS_LONG) {
                                                if (tmp_has_range < 0) {
                                                        tmp_has_range = 1;
                                                        tmp_range.underflow = 0;
-                                                       tmp_range.min = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
-                                                       tmp_range.max = Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants));
+                                                       tmp_range.min = Z_LVAL_P(zv);
+                                                       tmp_range.max = Z_LVAL_P(zv);
                                                        tmp_range.overflow = 0;
                                                } else if (tmp_has_range) {
                                                        if (!tmp_range.underflow) {
-                                                               tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
+                                                               tmp_range.min = MIN(tmp_range.min, Z_LVAL_P(zv));
                                                        }
                                                        if (!tmp_range.overflow) {
-                                                               tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(CRT_CONSTANT_EX(op_array, opline->op1, info->ssa.rt_constants)));
+                                                               tmp_range.max = MAX(tmp_range.max, Z_LVAL_P(zv));
                                                        }
                                                }
                                        } else {
index 6f1fff961cacc482b6191bb5e5b084d666f7c828..3d09c7e5af5134b9e76acaba0daa99e7b3eb5025 100644 (file)
@@ -165,6 +165,8 @@ static inline uint32_t mask_for_type_check(uint32_t type) {
 static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_flags, zend_op *opline, uint32_t var_num, zend_long *adjustment) /* {{{ */
 {
        zend_op *op = opline;
+       zval *zv;
+
        while (op != op_array->opcodes) {
                op--;
                if (op->result_type != IS_TMP_VAR || op->result.var != var_num) {
@@ -182,25 +184,28 @@ static int find_adjusted_tmp_var(const zend_op_array *op_array, uint32_t build_f
                                return EX_VAR_TO_NUM(op->op1.var);
                        }
                } else if (op->opcode == ZEND_ADD) {
-                       if (op->op1_type == IS_CV &&
-                               op->op2_type == IS_CONST &&
-                               Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG &&
-                               Z_LVAL_P(CRT_CONSTANT(op->op2)) != ZEND_LONG_MIN) {
-                               *adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op2));
-                               return EX_VAR_TO_NUM(op->op1.var);
-                       } else if (op->op2_type == IS_CV &&
-                                          op->op1_type == IS_CONST &&
-                                          Z_TYPE_P(CRT_CONSTANT(op->op1)) == IS_LONG &&
-                                          Z_LVAL_P(CRT_CONSTANT(op->op1)) != ZEND_LONG_MIN) {
-                               *adjustment = -Z_LVAL_P(CRT_CONSTANT(op->op1));
-                               return EX_VAR_TO_NUM(op->op2.var);
+                       if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
+                               zv = CRT_CONSTANT(op->op2);
+                               if (Z_TYPE_P(zv) == IS_LONG
+                                && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
+                                       *adjustment = -Z_LVAL_P(zv);
+                                       return EX_VAR_TO_NUM(op->op1.var);
+                               }
+                       } else if (op->op2_type == IS_CV && op->op1_type == IS_CONST) {
+                               zv = CRT_CONSTANT(op->op2);
+                               if (Z_TYPE_P(zv) == IS_LONG
+                                && Z_LVAL_P(zv) != ZEND_LONG_MIN) {
+                                       *adjustment = -Z_LVAL_P(zv);
+                                       return EX_VAR_TO_NUM(op->op2.var);
+                               }
                        }
                } else if (op->opcode == ZEND_SUB) {
-                       if (op->op1_type == IS_CV &&
-                               op->op2_type == IS_CONST &&
-                               Z_TYPE_P(CRT_CONSTANT(op->op2)) == IS_LONG) {
-                               *adjustment = Z_LVAL_P(CRT_CONSTANT(op->op2));
-                               return EX_VAR_TO_NUM(op->op1.var);
+                       if (op->op1_type == IS_CV && op->op2_type == IS_CONST) {
+                               zv = CRT_CONSTANT(op->op2);
+                               if (Z_TYPE_P(zv) == IS_LONG) {
+                                       *adjustment = Z_LVAL_P(zv);
+                                       return EX_VAR_TO_NUM(op->op1.var);
+                               }
                        }
                }
                break;
@@ -289,15 +294,18 @@ static void place_essa_pis(
                                }
                        } else if (var1 >= 0 && var2 < 0) {
                                zend_long add_val2 = 0;
-                               if ((opline-1)->op2_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_LONG) {
-                                       add_val2 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op2));
-                               } else if ((opline-1)->op2_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_FALSE) {
-                                       add_val2 = 0;
-                               } else if ((opline-1)->op2_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op2)) == IS_TRUE) {
-                                       add_val2 = 1;
+                               if ((opline-1)->op2_type == IS_CONST) {
+                                       zval *zv = CRT_CONSTANT((opline-1)->op2);
+
+                                       if (Z_TYPE_P(zv) == IS_LONG) {
+                                               add_val2 = Z_LVAL_P(zv);
+                                       } else if (Z_TYPE_P(zv) == IS_FALSE) {
+                                               add_val2 = 0;
+                                       } else if (Z_TYPE_P(zv) == IS_TRUE) {
+                                               add_val2 = 1;
+                                       } else {
+                                               var1 = -1;
+                                       }
                                } else {
                                        var1 = -1;
                                }
@@ -308,15 +316,17 @@ static void place_essa_pis(
                                }
                        } else if (var1 < 0 && var2 >= 0) {
                                zend_long add_val1 = 0;
-                               if ((opline-1)->op1_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_LONG) {
-                                       add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
-                               } else if ((opline-1)->op1_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_FALSE) {
-                                       add_val1 = 0;
-                               } else if ((opline-1)->op1_type == IS_CONST &&
-                                   Z_TYPE_P(CRT_CONSTANT((opline-1)->op1)) == IS_TRUE) {
-                                       add_val1 = 1;
+                               if ((opline-1)->op1_type == IS_CONST) {
+                                       zval *zv = CRT_CONSTANT((opline-1)->op1);
+                                       if (Z_TYPE_P(zv) == IS_LONG) {
+                                               add_val1 = Z_LVAL_P(CRT_CONSTANT((opline-1)->op1));
+                                       } else if (Z_TYPE_P(zv) == IS_FALSE) {
+                                               add_val1 = 0;
+                                       } else if (Z_TYPE_P(zv) == IS_TRUE) {
+                                               add_val1 = 1;
+                                       } else {
+                                               var2 = -1;
+                                       }
                                } else {
                                        var2 = -1;
                                }