com php-src: Fixed SSA construction for PRE_INC_OBJ and family (these opcodes change the source object ): ext/opcache/Optimizer/zend_dfg.c
ext/opcache/Opt imizer/zend_inference.c ext/opcache/Optimizer/zend_ssa .c
| From: | Dmitry Stogov | Date: | Thu, 31 Aug 2017 10:16:21 +0000 |
| Subject: | com php-src: Fixed SSA construction for PRE_INC_OBJ and family (these opcodes change the source object ): ext/opcache/Optimizer/zend_dfg.c ext/opcache/Opt imizer/zend_inference.c ext/opcache/Optimizer/zend_ssa .c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99208@lists.php.net to get a copy of this message | ||
Commit: 2e462e12db7a35fd75ec0d9f1b7b7a0531f1af10
Author: Dmitry Stogov <dmitry@zend.com> Thu, 31 Aug 2017 13:16:21 +0300
Parents: a8835d05d58e867ed9c11673256a447b011c7cc4
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2e462e12db7a35fd75ec0d9f1b7b7a0531f1af10
Log:
Fixed SSA construction for PRE_INC_OBJ and family (these opcodes change the source object)
Changed paths:
M ext/opcache/Optimizer/zend_dfg.c
M ext/opcache/Optimizer/zend_inference.c
M ext/opcache/Optimizer/zend_ssa.c
Diff:
diff --git a/ext/opcache/Optimizer/zend_dfg.c b/ext/opcache/Optimizer/zend_dfg.c
index 3b4c9bb..49be85c 100644
--- a/ext/opcache/Optimizer/zend_dfg.c
+++ b/ext/opcache/Optimizer/zend_dfg.c
@@ -128,6 +128,10 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg
case ZEND_FETCH_OBJ_FUNC_ARG:
case ZEND_FETCH_OBJ_UNSET:
case ZEND_VERIFY_RETURN_TYPE:
+ case ZEND_PRE_INC_OBJ:
+ case ZEND_PRE_DEC_OBJ:
+ case ZEND_POST_INC_OBJ:
+ case ZEND_POST_DEC_OBJ:
op1_def:
/*
def always come along with dtor or separation,
* thus the origin var info might be also used in the feature(CG) */
diff --git a/ext/opcache/Optimizer/zend_inference..c b/ext/opcache/Optimizer/zend_inference.c
index a0a23e6..d719837 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -2559,6 +2559,28 @@ static int zend_update_type_info(const zend_op_array *op_array,
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
}
break;
+ case ZEND_PRE_INC_OBJ:
+ case ZEND_PRE_DEC_OBJ:
+ case ZEND_POST_INC_OBJ:
+ 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;
+ }
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].op1_def);
+ COPY_SSA_OBJ_TYPE(ssa_ops[i].op1_use, ssa_ops[i].op1_def);
+ }
+ if (ssa_ops[i].result_def >= 0) {
+ // TODO: ???
+ tmp = MAY_BE_REF | MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY |
MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
+ UPDATE_SSA_TYPE(tmp, ssa_ops[i].result_def);
+ }
+ break;
case ZEND_ASSIGN:
if (opline->op2_type == IS_CV && ssa_ops[i].op2_def >= 0) {
tmp = t2;
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index e100be4...f3b597a 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -644,6 +644,17 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags,
//NEW_SSA_VAR(next->op1.var)
}
break;
+ case ZEND_PRE_INC_OBJ:
+ case ZEND_PRE_DEC_OBJ:
+ case ZEND_POST_INC_OBJ:
+ case ZEND_POST_DEC_OBJ:
+ 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_ADD_ARRAY_ELEMENT:
ssa_ops[k].result_use = var[EX_VAR_TO_NUM(opline->result.var)];
case ZEND_INIT_ARRAY: