Skip to content

Commit 49bc7e3

Browse files
committed
Allocate on the arena directly
1 parent 4f0848d commit 49bc7e3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Zend/zend_compile.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6301,9 +6301,9 @@ static zend_type zend_compile_typename(
63016301
zend_error_noreturn(E_COMPILE_ERROR, "Nullable type cannot be part of an intersection type");
63026302
}
63036303

6304-
ALLOCA_FLAG(use_heap)
6305-
6306-
type_list = do_alloca(ZEND_TYPE_LIST_SIZE(list->children), use_heap);
6304+
/* Allocate the type list directly on the arena as it must be a type
6305+
* list of the same number of elements as the AST list has children */
6306+
type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(list->children));
63076307
type_list->num_types = 0;
63086308

63096309
ZEND_ASSERT(list->children > 1);
@@ -6340,18 +6340,12 @@ static zend_type zend_compile_typename(
63406340
}
63416341
}
63426342

6343-
ZEND_ASSERT(type_list->num_types > 1);
6343+
ZEND_ASSERT(list->children == type_list->num_types);
63446344

6345-
/* TODO Can be arena allocated directly? */
6346-
zend_type_list *reduced_list = zend_arena_alloc(
6347-
&CG(arena), ZEND_TYPE_LIST_SIZE(type_list->num_types));
6348-
memcpy(reduced_list, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types));
6349-
ZEND_TYPE_SET_LIST(type, reduced_list);
6345+
ZEND_TYPE_SET_LIST(type, type_list);
63506346
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
63516347
/* Inform that the type list is an intersection type */
63526348
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_INTERSECTION_BIT;
6353-
6354-
free_alloca(type_list, use_heap);
63556349
} else {
63566350
type = zend_compile_single_typename(ast);
63576351
}

0 commit comments

Comments
 (0)