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