Skip to content

Commit fda520d

Browse files
committed
Support resolving arg/return intersection types in the JIT
1 parent 47372df commit fda520d

File tree

1 file changed

+57
-23
lines changed

1 file changed

+57
-23
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,36 +1346,70 @@ static zend_always_inline bool zend_jit_verify_type_common(zval *arg, zend_arg_i
13461346
zend_class_entry *ce;
13471347
if (ZEND_TYPE_HAS_LIST(arg_info->type)) {
13481348
zend_type *list_type;
1349-
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(arg_info->type), list_type) {
1350-
if (*cache_slot) {
1351-
ce = *cache_slot;
1352-
} else {
1353-
zend_string *name = ZEND_TYPE_NAME(*list_type);
1349+
if (ZEND_TYPE_HAS_INTERSECTION(arg_info->type)) {
1350+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(arg_info->type), list_type) {
1351+
if (*cache_slot) {
1352+
ce = *cache_slot;
1353+
} else {
1354+
zend_string *name = ZEND_TYPE_NAME(*list_type);
13541355

1355-
if (ZSTR_HAS_CE_CACHE(name)) {
1356-
ce = ZSTR_GET_CE_CACHE(name);
1357-
if (!ce) {
1358-
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
1356+
if (ZSTR_HAS_CE_CACHE(name)) {
1357+
ce = ZSTR_GET_CE_CACHE(name);
13591358
if (!ce) {
1360-
cache_slot++;
1361-
continue;
1359+
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
1360+
if (!ce) {
1361+
/* Cannot resolve */
1362+
return false;
1363+
}
1364+
}
1365+
} else {
1366+
ce = zend_fetch_class(name,
1367+
ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD | ZEND_FETCH_CLASS_SILENT);
1368+
if (!ce) {
1369+
/* Cannot resolve */
1370+
return false;
13621371
}
13631372
}
1373+
*cache_slot = ce;
1374+
}
1375+
if (!instanceof_function(Z_OBJCE_P(arg), ce)) {
1376+
return false;
1377+
}
1378+
cache_slot++;
1379+
} ZEND_TYPE_LIST_FOREACH_END();
1380+
return true;
1381+
} else {
1382+
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(arg_info->type), list_type) {
1383+
if (*cache_slot) {
1384+
ce = *cache_slot;
13641385
} else {
1365-
ce = zend_fetch_class(name,
1366-
ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD | ZEND_FETCH_CLASS_SILENT);
1367-
if (!ce) {
1368-
cache_slot++;
1369-
continue;
1386+
zend_string *name = ZEND_TYPE_NAME(*list_type);
1387+
1388+
if (ZSTR_HAS_CE_CACHE(name)) {
1389+
ce = ZSTR_GET_CE_CACHE(name);
1390+
if (!ce) {
1391+
ce = zend_lookup_class_ex(name, NULL, ZEND_FETCH_CLASS_NO_AUTOLOAD);
1392+
if (!ce) {
1393+
cache_slot++;
1394+
continue;
1395+
}
1396+
}
1397+
} else {
1398+
ce = zend_fetch_class(name,
1399+
ZEND_FETCH_CLASS_AUTO | ZEND_FETCH_CLASS_NO_AUTOLOAD | ZEND_FETCH_CLASS_SILENT);
1400+
if (!ce) {
1401+
cache_slot++;
1402+
continue;
1403+
}
13701404
}
1405+
*cache_slot = ce;
13711406
}
1372-
*cache_slot = ce;
1373-
}
1374-
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1375-
return 1;
1376-
}
1377-
cache_slot++;
1378-
} ZEND_TYPE_LIST_FOREACH_END();
1407+
if (instanceof_function(Z_OBJCE_P(arg), ce)) {
1408+
return 1;
1409+
}
1410+
cache_slot++;
1411+
} ZEND_TYPE_LIST_FOREACH_END();
1412+
}
13791413
} else {
13801414
if (EXPECTED(*cache_slot)) {
13811415
ce = (zend_class_entry *) *cache_slot;

0 commit comments

Comments
 (0)