Skip to content

Commit 63fea91

Browse files
committed
Allocate on the arena directly
1 parent ef364d5 commit 63fea91

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
@@ -6297,9 +6297,9 @@ static zend_type zend_compile_typename(
62976297
zend_error_noreturn(E_COMPILE_ERROR, "Nullable type cannot be part of an intersection type");
62986298
}
62996299

6300-
ALLOCA_FLAG(use_heap)
6301-
6302-
type_list = do_alloca(ZEND_TYPE_LIST_SIZE(list->children), use_heap);
6300+
/* Allocate the type list directly on the arena as it must be a type
6301+
* list of the same number of elements as the AST list has children */
6302+
type_list = zend_arena_alloc(&CG(arena), ZEND_TYPE_LIST_SIZE(list->children));
63036303
type_list->num_types = 0;
63046304

63056305
ZEND_ASSERT(list->children > 1);
@@ -6336,18 +6336,12 @@ static zend_type zend_compile_typename(
63366336
}
63376337
}
63386338

6339-
ZEND_ASSERT(type_list->num_types > 1);
6339+
ZEND_ASSERT(list->children == type_list->num_types);
63406340

6341-
/* TODO Can be arena allocated directly? */
6342-
zend_type_list *reduced_list = zend_arena_alloc(
6343-
&CG(arena), ZEND_TYPE_LIST_SIZE(type_list->num_types));
6344-
memcpy(reduced_list, type_list, ZEND_TYPE_LIST_SIZE(type_list->num_types));
6345-
ZEND_TYPE_SET_LIST(type, reduced_list);
6341+
ZEND_TYPE_SET_LIST(type, type_list);
63466342
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_ARENA_BIT;
63476343
/* Inform that the type list is an intersection type */
63486344
ZEND_TYPE_FULL_MASK(type) |= _ZEND_TYPE_INTERSECTION_BIT;
6349-
6350-
free_alloca(type_list, use_heap);
63516345
} else {
63526346
type = zend_compile_single_typename(ast);
63536347
}

0 commit comments

Comments
 (0)