Skip to content

Commit c5de442

Browse files
Girgiasnikic
authored andcommitted
Refactor zend_check_type_slow()
1 parent 2545dac commit c5de442

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

Zend/zend_execute.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,18 +1007,9 @@ static zend_always_inline bool zend_check_type_slow(
10071007
} else {
10081008
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*type), list_type) {
10091009
ce = zend_fetch_ce_from_cache_slot(cache_slot, list_type);
1010-
/* If we cannot resolve the CE we cannot check if it satisfies
1011-
* the type constraint, check the next one. */
1012-
if (ce == NULL) {
1013-
if (HAVE_CACHE_SLOT) {
1014-
cache_slot++;
1015-
}
1016-
continue;
1017-
}
1018-
1019-
/* Perform actual type check */
1010+
/* Perform actual type check if we have a CE */
10201011
/* Instance of a single type part of a union is sufficient to pass the type check */
1021-
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1012+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
10221013
return true;
10231014
}
10241015
if (HAVE_CACHE_SLOT) {
@@ -1028,19 +1019,14 @@ static zend_always_inline bool zend_check_type_slow(
10281019
}
10291020
} else {
10301021
ce = zend_fetch_ce_from_cache_slot(cache_slot, type);
1031-
/* If we cannot resolve the CE we cannot check if it satisfies
1032-
* the type constraint, check if a standard type satisfies it. */
1033-
if (ce == NULL) {
1034-
goto builtin_types;
1035-
}
1036-
1037-
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1038-
return 1;
1022+
/* If we have a CE we check if it satisfies the type constraint,
1023+
* otherwise it will check if a standard type satisfies it. */
1024+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
1025+
return true;
10391026
}
10401027
}
10411028
}
10421029

1043-
builtin_types:
10441030
type_mask = ZEND_TYPE_FULL_MASK(*type);
10451031
if ((type_mask & MAY_BE_CALLABLE) && zend_is_callable(arg, 0, NULL)) {
10461032
return 1;

0 commit comments

Comments
 (0)