Skip to content

Commit a96e956

Browse files
committed
Refactor zend_check_type_slow()
1 parent a0a1d90 commit a96e956

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
@@ -1005,18 +1005,9 @@ static zend_always_inline bool zend_check_type_slow(
10051005
} else {
10061006
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(*type), list_type) {
10071007
ce = zend_fetch_ce_from_cache_slot(cache_slot, list_type);
1008-
/* If we cannot resolve the CE we cannot check if it satisfies
1009-
* the type constraint, check the next one. */
1010-
if (ce == NULL) {
1011-
if (HAVE_CACHE_SLOT) {
1012-
cache_slot++;
1013-
}
1014-
continue;
1015-
}
1016-
1017-
/* Perform actual type check */
1008+
/* Perform actual type check if we have a CE */
10181009
/* Instance of a single type part of a union is sufficient to pass the type check */
1019-
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1010+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
10201011
return true;
10211012
}
10221013
if (HAVE_CACHE_SLOT) {
@@ -1026,19 +1017,14 @@ static zend_always_inline bool zend_check_type_slow(
10261017
}
10271018
} else {
10281019
ce = zend_fetch_ce_from_cache_slot(cache_slot, type);
1029-
/* If we cannot resolve the CE we cannot check if it satisfies
1030-
* the type constraint, check if a standard type satisfies it. */
1031-
if (ce == NULL) {
1032-
goto builtin_types;
1033-
}
1034-
1035-
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1036-
return 1;
1020+
/* If we have a CE we check if it satisfies the type constraint,
1021+
* otherwise it will check if a standard type satisfies it. */
1022+
if (ce && instanceof_function(Z_OBJCE_P(arg), ce)) {
1023+
return true;
10371024
}
10381025
}
10391026
}
10401027

1041-
builtin_types:
10421028
type_mask = ZEND_TYPE_FULL_MASK(*type);
10431029
if ((type_mask & MAY_BE_CALLABLE) && zend_is_callable(arg, 0, NULL)) {
10441030
return 1;

0 commit comments

Comments
 (0)