@@ -1099,23 +1099,10 @@ static zend_always_inline bool zend_value_instanceof_static(zval *zv) {
10991099 return instanceof_function (Z_OBJCE_P (zv ), called_scope );
11001100}
11011101
1102- /* The cache_slot may only be NULL in debug builds, where arginfo verification of
1103- * internal functions is enabled. Avoid unnecessary checks in release builds. */
1104- #if ZEND_DEBUG
1105- # define HAVE_CACHE_SLOT (cache_slot != NULL)
1106- #else
1107- # define HAVE_CACHE_SLOT 1
1108- #endif
1109-
1110- #define PROGRESS_CACHE_SLOT () if (HAVE_CACHE_SLOT) {cache_slot++;}
1111-
1102+ // TODO: new name
11121103static zend_always_inline zend_class_entry * zend_fetch_ce_from_cache_slot (
1113- void * * cache_slot , zend_type * type )
1104+ zend_type * type )
11141105{
1115- if (EXPECTED (HAVE_CACHE_SLOT && * cache_slot )) {
1116- return (zend_class_entry * ) * cache_slot ;
1117- }
1118-
11191106 zend_string * name = ZEND_TYPE_NAME (* type );
11201107 zend_class_entry * ce ;
11211108 if (ZSTR_HAS_CE_CACHE (name )) {
@@ -1134,39 +1121,27 @@ static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
11341121 return NULL ;
11351122 }
11361123 }
1137- if (HAVE_CACHE_SLOT ) {
1138- * cache_slot = (void * ) ce ;
1139- }
11401124 return ce ;
11411125}
11421126
11431127static bool zend_check_intersection_type_from_cache_slot (zend_type_list * intersection_type_list ,
1144- zend_class_entry * arg_ce , void * * * cache_slot_ptr )
1128+ zend_class_entry * arg_ce )
11451129{
1146- void * * cache_slot = * cache_slot_ptr ;
11471130 zend_class_entry * ce ;
11481131 zend_type * list_type ;
1149- bool status = true;
11501132 ZEND_TYPE_LIST_FOREACH (intersection_type_list , list_type ) {
1151- /* Only check classes if the type might be valid */
1152- if (status ) {
1153- ce = zend_fetch_ce_from_cache_slot (cache_slot , list_type );
1154- /* If type is not an instance of one of the types taking part in the
1155- * intersection it cannot be a valid instance of the whole intersection type. */
1156- if (!ce || !instanceof_function (arg_ce , ce )) {
1157- status = false;
1158- }
1133+ ce = zend_fetch_ce_from_cache_slot (list_type );
1134+ /* If type is not an instance of one of the types taking part in the
1135+ * intersection it cannot be a valid instance of the whole intersection type. */
1136+ if (!ce || !instanceof_function (arg_ce , ce )) {
1137+ return false;
11591138 }
1160- PROGRESS_CACHE_SLOT ();
11611139 } ZEND_TYPE_LIST_FOREACH_END ();
1162- if (HAVE_CACHE_SLOT ) {
1163- * cache_slot_ptr = cache_slot ;
1164- }
1165- return status ;
1140+ return true;
11661141}
11671142
11681143static zend_always_inline bool zend_check_type_slow (
1169- zend_type * type , zval * arg , zend_reference * ref , void * * cache_slot ,
1144+ zend_type * type , zval * arg , zend_reference * ref ,
11701145 bool is_return_type , bool is_internal )
11711146{
11721147 uint32_t type_mask ;
@@ -1175,27 +1150,25 @@ static zend_always_inline bool zend_check_type_slow(
11751150 if (UNEXPECTED (ZEND_TYPE_HAS_LIST (* type ))) {
11761151 zend_type * list_type ;
11771152 if (ZEND_TYPE_IS_INTERSECTION (* type )) {
1178- return zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ), & cache_slot );
1153+ return zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ));
11791154 } else {
11801155 ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (* type ), list_type ) {
11811156 if (ZEND_TYPE_IS_INTERSECTION (* list_type )) {
1182- if (zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* list_type ), Z_OBJCE_P (arg ), & cache_slot )) {
1157+ if (zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* list_type ), Z_OBJCE_P (arg ))) {
11831158 return true;
11841159 }
1185- /* The cache_slot is progressed in zend_check_intersection_type_from_cache_slot() */
11861160 } else {
11871161 ZEND_ASSERT (!ZEND_TYPE_HAS_LIST (* list_type ));
1188- ce = zend_fetch_ce_from_cache_slot (cache_slot , list_type );
1162+ ce = zend_fetch_ce_from_cache_slot (list_type );
11891163 /* Instance of a single type part of a union is sufficient to pass the type check */
11901164 if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
11911165 return true;
11921166 }
1193- PROGRESS_CACHE_SLOT ();
11941167 }
11951168 } ZEND_TYPE_LIST_FOREACH_END ();
11961169 }
11971170 } else {
1198- ce = zend_fetch_ce_from_cache_slot (cache_slot , type );
1171+ ce = zend_fetch_ce_from_cache_slot (type );
11991172 /* If we have a CE we check if it satisfies the type constraint,
12001173 * otherwise it will check if a standard type satisfies it. */
12011174 if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
@@ -1232,7 +1205,7 @@ static zend_always_inline bool zend_check_type_slow(
12321205}
12331206
12341207static zend_always_inline bool zend_check_type (
1235- zend_type * type , zval * arg , void * * cache_slot , zend_class_entry * scope ,
1208+ zend_type * type , zval * arg , zend_class_entry * scope ,
12361209 bool is_return_type , bool is_internal )
12371210{
12381211 zend_reference * ref = NULL ;
@@ -1247,25 +1220,25 @@ static zend_always_inline bool zend_check_type(
12471220 return 1 ;
12481221 }
12491222
1250- return zend_check_type_slow (type , arg , ref , cache_slot , is_return_type , is_internal );
1223+ return zend_check_type_slow (type , arg , ref , is_return_type , is_internal );
12511224}
12521225
12531226ZEND_API bool zend_check_user_type_slow (
1254- zend_type * type , zval * arg , zend_reference * ref , void * * cache_slot , bool is_return_type )
1227+ zend_type * type , zval * arg , zend_reference * ref , bool is_return_type )
12551228{
12561229 return zend_check_type_slow (
1257- type , arg , ref , cache_slot , is_return_type , /* is_internal */ false);
1230+ type , arg , ref , is_return_type , /* is_internal */ false);
12581231}
12591232
1260- static zend_always_inline bool zend_verify_recv_arg_type (zend_function * zf , uint32_t arg_num , zval * arg , void * * cache_slot )
1233+ static zend_always_inline bool zend_verify_recv_arg_type (zend_function * zf , uint32_t arg_num , zval * arg )
12611234{
12621235 zend_arg_info * cur_arg_info ;
12631236
12641237 ZEND_ASSERT (arg_num <= zf -> common .num_args );
12651238 cur_arg_info = & zf -> common .arg_info [arg_num - 1 ];
12661239
12671240 if (ZEND_TYPE_IS_SET (cur_arg_info -> type )
1268- && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1241+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , zf -> common .scope , 0 , 0 ))) {
12691242 zend_verify_arg_error (zf , cur_arg_info , arg_num , arg );
12701243 return 0 ;
12711244 }
@@ -1274,10 +1247,10 @@ static zend_always_inline bool zend_verify_recv_arg_type(zend_function *zf, uint
12741247}
12751248
12761249static zend_always_inline bool zend_verify_variadic_arg_type (
1277- zend_function * zf , zend_arg_info * arg_info , uint32_t arg_num , zval * arg , void * * cache_slot )
1250+ zend_function * zf , zend_arg_info * arg_info , uint32_t arg_num , zval * arg )
12781251{
12791252 ZEND_ASSERT (ZEND_TYPE_IS_SET (arg_info -> type ));
1280- if (UNEXPECTED (!zend_check_type (& arg_info -> type , arg , cache_slot , zf -> common .scope , 0 , 0 ))) {
1253+ if (UNEXPECTED (!zend_check_type (& arg_info -> type , arg , zf -> common .scope , 0 , 0 ))) {
12811254 zend_verify_arg_error (zf , arg_info , arg_num , arg );
12821255 return 0 ;
12831256 }
@@ -1302,7 +1275,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
13021275 }
13031276
13041277 if (ZEND_TYPE_IS_SET (cur_arg_info -> type )
1305- && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , /* cache_slot */ NULL , fbc -> common .scope , 0 , /* is_internal */ 1 ))) {
1278+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , fbc -> common .scope , 0 , /* is_internal */ 1 ))) {
13061279 return 0 ;
13071280 }
13081281 arg ++ ;
0 commit comments