Skip to content

Commit

Permalink
Expand CORINFO_HELP_CHKCASTANY cast (#86728)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo committed May 26, 2023
1 parent b09e864 commit c7eed31
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/coreclr/jit/importer.cpp
Expand Up @@ -5487,6 +5487,14 @@ GenTree* Compiler::impCastClassOrIsInstToTree(
{
// Jit can only inline expand CHKCASTCLASS and CHKCASTARRAY helpers.
canExpandInline = (helper == CORINFO_HELP_CHKCASTCLASS) || (helper == CORINFO_HELP_CHKCASTARRAY);

// For ChkCastAny we ignore cases where the class is known to be abstract or is an interface.
if (helper == CORINFO_HELP_CHKCASTANY)
{
const bool isAbstract = (info.compCompHnd->getClassAttribs(pResolvedToken->hClass) &
(CORINFO_FLG_INTERFACE | CORINFO_FLG_ABSTRACT)) != 0;
canExpandInline = !isAbstract;
}
}
else if ((helper == CORINFO_HELP_ISINSTANCEOFCLASS) || (helper == CORINFO_HELP_ISINSTANCEOFARRAY))
{
Expand Down Expand Up @@ -5625,7 +5633,7 @@ GenTree* Compiler::impCastClassOrIsInstToTree(
if (isCastClass)
{
assert((helper == CORINFO_HELP_CHKCASTCLASS) || (helper == CORINFO_HELP_CHKCASTARRAY) ||
(helper == CORINFO_HELP_CHKCASTINTERFACE));
(helper == CORINFO_HELP_CHKCASTANY) || (helper == CORINFO_HELP_CHKCASTINTERFACE));

CorInfoHelpFunc specialHelper = helper;
if ((helper == CORINFO_HELP_CHKCASTCLASS) &&
Expand Down

0 comments on commit c7eed31

Please sign in to comment.