Skip to content

Commit

Permalink
Check for name vs ce in a few more places
Browse files Browse the repository at this point in the history
The type lists may contain CEs, we should not assume they only
contain names.
  • Loading branch information
nikic committed Jul 14, 2020
1 parent 7c16d11 commit 7e6b2e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
18 changes: 8 additions & 10 deletions ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ static HashTable *zend_persist_attributes(HashTable *attributes)

static void zend_persist_type(zend_type *type) {
if (ZEND_TYPE_HAS_LIST(*type)) {
zend_type *list_type;
zend_type_list *list = ZEND_TYPE_LIST(*type);
if (ZEND_TYPE_USES_ARENA(*type)) {
if (!ZCG(is_immutable_class)) {
Expand All @@ -308,17 +307,16 @@ static void zend_persist_type(zend_type *type) {
list = zend_shared_memdup_put_free(list, ZEND_TYPE_LIST_SIZE(list->num_types));
}
ZEND_TYPE_SET_PTR(*type, list);
}

ZEND_TYPE_LIST_FOREACH(list, list_type) {
zend_string *type_name = ZEND_TYPE_NAME(*list_type);
zend_type *single_type;
ZEND_TYPE_FOREACH(*type, single_type) {
if (ZEND_TYPE_HAS_NAME(*single_type)) {
zend_string *type_name = ZEND_TYPE_NAME(*single_type);
zend_accel_store_interned_string(type_name);
ZEND_TYPE_SET_PTR(*list_type, type_name);
} ZEND_TYPE_LIST_FOREACH_END();
} else if (ZEND_TYPE_HAS_NAME(*type)) {
zend_string *type_name = ZEND_TYPE_NAME(*type);
zend_accel_store_interned_string(type_name);
ZEND_TYPE_SET_PTR(*type, type_name);
}
ZEND_TYPE_SET_PTR(*single_type, type_name);
}
} ZEND_TYPE_FOREACH_END();
}

static void zend_persist_op_array_ex(zend_op_array *op_array, zend_persistent_script* main_persistent_script)
Expand Down
19 changes: 9 additions & 10 deletions ext/opcache/zend_persist_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,22 +174,21 @@ static void zend_persist_attributes_calc(HashTable *attributes)
static void zend_persist_type_calc(zend_type *type)
{
if (ZEND_TYPE_HAS_LIST(*type)) {
zend_type *list_type;
if (ZEND_TYPE_USES_ARENA(*type) && !ZCG(is_immutable_class)) {
ADD_ARENA_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types));
} else {
ADD_SIZE(ZEND_TYPE_LIST_SIZE(ZEND_TYPE_LIST(*type)->num_types));
}
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*type), list_type) {
zend_string *type_name = ZEND_TYPE_NAME(*list_type);
ADD_INTERNED_STRING(type_name);
ZEND_TYPE_SET_PTR(*list_type, type_name);
} ZEND_TYPE_LIST_FOREACH_END();
} else if (ZEND_TYPE_HAS_NAME(*type)) {
zend_string *type_name = ZEND_TYPE_NAME(*type);
ADD_INTERNED_STRING(type_name);
ZEND_TYPE_SET_PTR(*type, type_name);
}

zend_type *single_type;
ZEND_TYPE_FOREACH(*type, single_type) {
if (ZEND_TYPE_HAS_NAME(*single_type)) {
zend_string *type_name = ZEND_TYPE_NAME(*single_type);
ADD_INTERNED_STRING(type_name);
ZEND_TYPE_SET_PTR(*single_type, type_name);
}
} ZEND_TYPE_FOREACH_END();
}

static void zend_persist_op_array_calc_ex(zend_op_array *op_array)
Expand Down

0 comments on commit 7e6b2e2

Please sign in to comment.