@@ -1099,23 +1099,9 @@ static zend_always_inline bool zend_value_instanceof_static(const zval *zv) {
1099
1099
return instanceof_function (Z_OBJCE_P (zv ), called_scope );
1100
1100
}
1101
1101
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
-
1112
- static zend_always_inline zend_class_entry * zend_fetch_ce_from_cache_slot (
1113
- void * * cache_slot , const zend_type * type )
1102
+ static zend_always_inline zend_class_entry * zend_fetch_ce_from_type (
1103
+ const zend_type * type )
1114
1104
{
1115
- if (EXPECTED (HAVE_CACHE_SLOT && * cache_slot )) {
1116
- return (zend_class_entry * ) * cache_slot ;
1117
- }
1118
-
1119
1105
zend_string * name = ZEND_TYPE_NAME (* type );
1120
1106
zend_class_entry * ce ;
1121
1107
if (ZSTR_HAS_CE_CACHE (name )) {
@@ -1134,68 +1120,54 @@ static zend_always_inline zend_class_entry *zend_fetch_ce_from_cache_slot(
1134
1120
return NULL ;
1135
1121
}
1136
1122
}
1137
- if (HAVE_CACHE_SLOT ) {
1138
- * cache_slot = (void * ) ce ;
1139
- }
1140
1123
return ce ;
1141
1124
}
1142
1125
1143
- static bool zend_check_intersection_type_from_cache_slot (
1126
+ static bool zend_check_intersection_type_from_list (
1144
1127
const zend_type_list * intersection_type_list ,
1145
- const zend_class_entry * arg_ce ,
1146
- void * * * cache_slot_ptr )
1128
+ zend_class_entry * arg_ce )
1147
1129
{
1148
- void * * cache_slot = * cache_slot_ptr ;
1130
+ zend_class_entry * ce ;
1149
1131
const zend_type * list_type ;
1150
- bool status = true;
1151
1132
ZEND_TYPE_LIST_FOREACH (intersection_type_list , list_type ) {
1152
- /* Only check classes if the type might be valid */
1153
- if (status ) {
1154
- zend_class_entry * ce = zend_fetch_ce_from_cache_slot (cache_slot , list_type );
1155
- /* If type is not an instance of one of the types taking part in the
1156
- * intersection it cannot be a valid instance of the whole intersection type. */
1157
- if (!ce || !instanceof_function (arg_ce , ce )) {
1158
- status = false;
1159
- }
1133
+ ce = zend_fetch_ce_from_type (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;
1160
1138
}
1161
- PROGRESS_CACHE_SLOT ();
1162
1139
} ZEND_TYPE_LIST_FOREACH_END ();
1163
- if (HAVE_CACHE_SLOT ) {
1164
- * cache_slot_ptr = cache_slot ;
1165
- }
1166
- return status ;
1140
+ return true;
1167
1141
}
1168
1142
1169
1143
static zend_always_inline bool zend_check_type_slow (
1170
- const zend_type * type , zval * arg , const zend_reference * ref , void * * cache_slot ,
1144
+ const zend_type * type , zval * arg , const zend_reference * ref ,
1171
1145
bool is_return_type , bool is_internal )
1172
1146
{
1173
1147
if (ZEND_TYPE_IS_COMPLEX (* type ) && EXPECTED (Z_TYPE_P (arg ) == IS_OBJECT )) {
1174
1148
zend_class_entry * ce ;
1175
1149
if (UNEXPECTED (ZEND_TYPE_HAS_LIST (* type ))) {
1176
1150
if (ZEND_TYPE_IS_INTERSECTION (* type )) {
1177
- return zend_check_intersection_type_from_cache_slot (ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ), & cache_slot );
1151
+ return zend_check_intersection_type_from_list (ZEND_TYPE_LIST (* type ), Z_OBJCE_P (arg ));
1178
1152
} else {
1179
1153
const zend_type * list_type ;
1180
1154
ZEND_TYPE_LIST_FOREACH (ZEND_TYPE_LIST (* type ), list_type ) {
1181
1155
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 )) {
1156
+ if (zend_check_intersection_type_from_list (ZEND_TYPE_LIST (* list_type ), Z_OBJCE_P (arg ))) {
1183
1157
return true;
1184
1158
}
1185
- /* The cache_slot is progressed in zend_check_intersection_type_from_cache_slot() */
1186
1159
} else {
1187
1160
ZEND_ASSERT (!ZEND_TYPE_HAS_LIST (* list_type ));
1188
- ce = zend_fetch_ce_from_cache_slot ( cache_slot , list_type );
1161
+ ce = zend_fetch_ce_from_type ( list_type );
1189
1162
/* Instance of a single type part of a union is sufficient to pass the type check */
1190
1163
if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
1191
1164
return true;
1192
1165
}
1193
- PROGRESS_CACHE_SLOT ();
1194
1166
}
1195
1167
} ZEND_TYPE_LIST_FOREACH_END ();
1196
1168
}
1197
1169
} else {
1198
- ce = zend_fetch_ce_from_cache_slot ( cache_slot , type );
1170
+ ce = zend_fetch_ce_from_type ( type );
1199
1171
/* If we have a CE we check if it satisfies the type constraint,
1200
1172
* otherwise it will check if a standard type satisfies it. */
1201
1173
if (ce && instanceof_function (Z_OBJCE_P (arg ), ce )) {
@@ -1232,7 +1204,7 @@ static zend_always_inline bool zend_check_type_slow(
1232
1204
}
1233
1205
1234
1206
static zend_always_inline bool zend_check_type (
1235
- const zend_type * type , zval * arg , void * * cache_slot , zend_class_entry * scope ,
1207
+ const zend_type * type , zval * arg , zend_class_entry * scope ,
1236
1208
bool is_return_type , bool is_internal )
1237
1209
{
1238
1210
const zend_reference * ref = NULL ;
@@ -1247,25 +1219,25 @@ static zend_always_inline bool zend_check_type(
1247
1219
return 1 ;
1248
1220
}
1249
1221
1250
- return zend_check_type_slow (type , arg , ref , cache_slot , is_return_type , is_internal );
1222
+ return zend_check_type_slow (type , arg , ref , is_return_type , is_internal );
1251
1223
}
1252
1224
1253
1225
ZEND_API bool zend_check_user_type_slow (
1254
- const zend_type * type , zval * arg , const zend_reference * ref , void * * cache_slot , bool is_return_type )
1226
+ const zend_type * type , zval * arg , const zend_reference * ref , bool is_return_type )
1255
1227
{
1256
1228
return zend_check_type_slow (
1257
- type , arg , ref , cache_slot , is_return_type , /* is_internal */ false);
1229
+ type , arg , ref , is_return_type , /* is_internal */ false);
1258
1230
}
1259
1231
1260
- static zend_always_inline bool zend_verify_recv_arg_type (const zend_function * zf , uint32_t arg_num , zval * arg , void * * cache_slot )
1232
+ static zend_always_inline bool zend_verify_recv_arg_type (const zend_function * zf , uint32_t arg_num , zval * arg )
1261
1233
{
1262
1234
const zend_arg_info * cur_arg_info ;
1263
1235
1264
1236
ZEND_ASSERT (arg_num <= zf -> common .num_args );
1265
1237
cur_arg_info = & zf -> common .arg_info [arg_num - 1 ];
1266
1238
1267
1239
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 ))) {
1240
+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , zf -> common .scope , 0 , 0 ))) {
1269
1241
zend_verify_arg_error (zf , cur_arg_info , arg_num , arg );
1270
1242
return 0 ;
1271
1243
}
@@ -1274,10 +1246,10 @@ static zend_always_inline bool zend_verify_recv_arg_type(const zend_function *zf
1274
1246
}
1275
1247
1276
1248
static zend_always_inline bool zend_verify_variadic_arg_type (
1277
- const zend_function * zf , const zend_arg_info * arg_info , uint32_t arg_num , zval * arg , void * * cache_slot )
1249
+ const zend_function * zf , const zend_arg_info * arg_info , uint32_t arg_num , zval * arg )
1278
1250
{
1279
1251
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 ))) {
1252
+ if (UNEXPECTED (!zend_check_type (& arg_info -> type , arg , zf -> common .scope , 0 , 0 ))) {
1281
1253
zend_verify_arg_error (zf , arg_info , arg_num , arg );
1282
1254
return 0 ;
1283
1255
}
@@ -1302,7 +1274,7 @@ static zend_never_inline ZEND_ATTRIBUTE_UNUSED bool zend_verify_internal_arg_typ
1302
1274
}
1303
1275
1304
1276
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 ))) {
1277
+ && UNEXPECTED (!zend_check_type (& cur_arg_info -> type , arg , fbc -> common .scope , 0 , /* is_internal */ 1 ))) {
1306
1278
return 0 ;
1307
1279
}
1308
1280
arg ++ ;
@@ -1508,7 +1480,7 @@ ZEND_API bool zend_verify_internal_return_type(const zend_function *zf, zval *re
1508
1480
return 1 ;
1509
1481
}
1510
1482
1511
- if (UNEXPECTED (!zend_check_type (& ret_info -> type , ret , /* cache_slot */ NULL , NULL , 1 , /* is_internal */ 1 ))) {
1483
+ if (UNEXPECTED (!zend_check_type (& ret_info -> type , ret , NULL , 1 , /* is_internal */ 1 ))) {
1512
1484
zend_verify_internal_return_error (zf , ret );
1513
1485
return 0 ;
1514
1486
}
0 commit comments