com php-src: clanup: ext/opcache/Optimizer/zend_inference.c ext/opcache/Optimizer/zend_ssa.c

From: Date: Wed, 29 Jun 2016 14:53:39 +0000
Subject: com php-src: clanup: ext/opcache/Optimizer/zend_inference.c ext/opcache/Optimizer/zend_ssa.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-92715@lists.php.net to get a copy of this message
Commit: 871cd76af4d11042432ef778c255c22b17435031 Author: Dmitry Stogov <dmitry@zend.com> Wed, 29 Jun 2016 17:53:39 +0300 Parents: f5dbba0d54329a1bcfb652180577a3cdadbc5077 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=871cd76af4d11042432ef778c255c22b17435031 Log: clanup Changed paths: M ext/opcache/Optimizer/zend_inference.c M ext/opcache/Optimizer/zend_ssa.c Diff: diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 6986abc..6620175 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -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 { diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index 6f1fff9..3d09c7e 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -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; }

« previous php.cvs (#92715) next »