summaryrefslogtreecommitdiff
path: root/ext/opcache
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-01-07 18:47:18 +0100
committerNikita Popov <nikic@php.net>2016-01-07 18:53:10 +0100
commitc602ac60b9bab6293d0174a9e0b880d4b9109414 (patch)
treeece947dd562a4edad27f4bce16dab722166de58f /ext/opcache
parent04dc5d742091f991b7630a53df8d7ccd137d2797 (diff)
downloadphp-git-c602ac60b9bab6293d0174a9e0b880d4b9109414.tar.gz
Fix CE fetching for NEW object type inference
Create a common function for getting a class entry.
Diffstat (limited to 'ext/opcache')
-rw-r--r--ext/opcache/Optimizer/zend_inference.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c
index f87f6f529b..6bc7fb7a53 100644
--- a/ext/opcache/Optimizer/zend_inference.c
+++ b/ext/opcache/Optimizer/zend_inference.c
@@ -2174,6 +2174,20 @@ uint32_t zend_array_element_type(uint32_t t1, int write, int insert)
return tmp;
}
+static inline zend_class_entry *get_class_entry(const zend_script *script, zend_string *lcname) {
+ zend_class_entry *ce = zend_hash_find_ptr(&script->class_table, lcname);
+ if (ce) {
+ return ce;
+ }
+
+ ce = zend_hash_find_ptr(CG(class_table), lcname);
+ if (ce && ce->type == ZEND_INTERNAL_CLASS) {
+ return ce;
+ }
+
+ return NULL;
+}
+
static void zend_update_type_info(const zend_op_array *op_array,
zend_ssa *ssa,
const zend_script *script,
@@ -3114,13 +3128,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
// class type hinting...
zend_string *lcname = zend_string_tolower(arg_info->class_name);
tmp |= MAY_BE_OBJECT;
- ce = zend_hash_find_ptr(&script->class_table, lcname);
- if (!ce) {
- ce = zend_hash_find_ptr(CG(class_table), lcname);
- if (ce && ce->type != ZEND_INTERNAL_CLASS) {
- ce = NULL;
- }
- }
+ ce = get_class_entry(script, lcname);
zend_string_release(lcname);
} else if (arg_info->type_hint != IS_UNDEF) {
if (arg_info->type_hint == IS_CALLABLE) {
@@ -3221,14 +3229,8 @@ static void zend_update_type_info(const zend_op_array *op_array,
} else if (opline->op2_type == IS_CONST) {
zval *zv = CRT_CONSTANT_EX(op_array, opline->op2, ssa->rt_constants);
if (Z_TYPE_P(zv) == IS_STRING) {
- if ((ce = zend_hash_find_ptr(&script->class_table, Z_STR_P(zv+1))) != NULL) {
- UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
- } else if ((ce = zend_hash_find_ptr(CG(class_table), Z_STR_P(zv+1))) != NULL &&
- ce->type == ZEND_INTERNAL_CLASS) {
- UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
- } else {
- UPDATE_SSA_OBJ_TYPE(NULL, 0, ssa_ops[i].result_def);
- }
+ ce = get_class_entry(script, Z_STR_P(zv+1));
+ UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
} else {
UPDATE_SSA_OBJ_TYPE(NULL, 0, ssa_ops[i].result_def);
}
@@ -3243,7 +3245,7 @@ static void zend_update_type_info(const zend_op_array *op_array,
case ZEND_NEW:
tmp = MAY_BE_RC1|MAY_BE_RCN|MAY_BE_OBJECT;
if (opline->op1_type == IS_CONST &&
- (ce = zend_hash_find_ptr(CG(class_table), Z_STR_P(CRT_CONSTANT_EX(op_array, opline->op1, ssa->rt_constants)+1))) != NULL) {
+ (ce = get_class_entry(script, Z_STR_P(CRT_CONSTANT_EX(op_array, opline->op1, ssa->rt_constants)+1))) != NULL) {
UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_ops[i].result_def);
} else if ((t1 & MAY_BE_CLASS) && ssa_ops[i].op1_use >= 0 && ssa_var_info[ssa_ops[i].op1_use].ce) {
UPDATE_SSA_OBJ_TYPE(ssa_var_info[ssa_ops[i].op1_use].ce, ssa_var_info[ssa_ops[i].op1_use].is_instanceof, ssa_ops[i].result_def);