Skip to content

Commit 6c4d24e

Browse files
committedSep 10, 2022
Update cache slot size calculation in compact_literals.c
1 parent c70a828 commit 6c4d24e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
 

‎Zend/Optimizer/compact_literals.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,23 @@ static size_t type_num_classes(const zend_op_array *op_array, uint32_t arg_num)
6363

6464
if (ZEND_TYPE_IS_COMPLEX(arg_info->type)) {
6565
if (ZEND_TYPE_HAS_LIST(arg_info->type)) {
66-
return ZEND_TYPE_LIST(arg_info->type)->num_types;
66+
/* Intersection types cannot have nested list types */
67+
if (ZEND_TYPE_IS_INTERSECTION(arg_info->type)) {
68+
return ZEND_TYPE_LIST(arg_info->type)->num_types;
69+
}
70+
ZEND_ASSERT(ZEND_TYPE_IS_UNION(arg_info->type));
71+
size_t count = 0;
72+
zend_type *list_type;
73+
74+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(arg_info->type), list_type) {
75+
if (ZEND_TYPE_IS_INTERSECTION(*list_type)) {
76+
count += ZEND_TYPE_LIST(*list_type)->num_types;
77+
} else {
78+
ZEND_ASSERT(!ZEND_TYPE_HAS_LIST(*list_type));
79+
count += 1;
80+
}
81+
} ZEND_TYPE_LIST_FOREACH_END();
82+
return count;
6783
}
6884
return 1;
6985
}

‎Zend/zend_compile.c

+1
Original file line numberDiff line numberDiff line change
@@ -2375,6 +2375,7 @@ static void zend_compile_memoized_expr(znode *result, zend_ast *expr) /* {{{ */
23752375
}
23762376
/* }}} */
23772377

2378+
/* Remember to update type_num_classes() in compact_literals.c when changing this function */
23782379
static size_t zend_type_get_num_classes(zend_type type) {
23792380
if (!ZEND_TYPE_IS_COMPLEX(type)) {
23802381
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.