@@ -6301,9 +6301,9 @@ static zend_type zend_compile_typename(
6301
6301
zend_error_noreturn (E_COMPILE_ERROR , "Nullable type cannot be part of an intersection type" );
6302
6302
}
6303
6303
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 ));
6307
6307
type_list -> num_types = 0 ;
6308
6308
6309
6309
ZEND_ASSERT (list -> children > 1 );
@@ -6340,18 +6340,12 @@ static zend_type zend_compile_typename(
6340
6340
}
6341
6341
}
6342
6342
6343
- ZEND_ASSERT (type_list -> num_types > 1 );
6343
+ ZEND_ASSERT (list -> children == type_list -> num_types );
6344
6344
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 );
6350
6346
ZEND_TYPE_FULL_MASK (type ) |= _ZEND_TYPE_ARENA_BIT ;
6351
6347
/* Inform that the type list is an intersection type */
6352
6348
ZEND_TYPE_FULL_MASK (type ) |= _ZEND_TYPE_INTERSECTION_BIT ;
6353
-
6354
- free_alloca (type_list , use_heap );
6355
6349
} else {
6356
6350
type = zend_compile_single_typename (ast );
6357
6351
}
0 commit comments