com php-src: Various RC inference fixes: ext/opcache/Optimizer/ zend_inference.c ext/opcache/Optimizer/zend_ssa.c
| From: | Nikita Popov | Date: | Sat, 15 Oct 2016 21:58:29 +0000 |
| Subject: | com php-src: Various RC inference fixes: ext/opcache/Optimizer/ zend_inference.c ext/opcache/Optimizer/zend_ssa.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95104@lists.php.net to get a copy of this message | ||
Commit: 659cc278e2e79f2fa48a6bf2e45e83cfeb1dea5c
Author: Nikita Popov <nikic@php.net> Fri, 14 Oct 2016 23:54:11 +0200
Parents: 1903fc62988c476d26283aa1baeca86f9a0540af
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=659cc278e2e79f2fa48a6bf2e45e83cfeb1dea5c
Log:
Various RC inference fixes
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 36bad72..33bab0e 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -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)) {
diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c
index 9360793..a0a2df9 100644
--- a/ext/opcache/Optimizer/zend_ssa.c
+++ b/ext/opcache/Optimizer/zend_ssa.c
@@ -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: