Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clean up
  • Loading branch information
EgorBo committed Feb 26, 2022
commit 1d25f00adcb06adebb1fed6e9cf3408eec46f918
24 changes: 8 additions & 16 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11582,6 +11582,7 @@ GenTree* Compiler::impCastClassOrIsInstToTree(
}
}

// Check if this cast helper have some profile data
if (impIsCastHelperMayHaveProfileData(helper))
{
LikelyClassRecord likelyClass[1]; // multiple guesses aren't yet supported
Expand All @@ -11593,26 +11594,17 @@ GenTree* Compiler::impCastClassOrIsInstToTree(
if ((likelyCls != NO_CLASS_HANDLE) &&
(likelyClass->likelihood > (UINT32)JitConfig.JitGuardedDevirtualizationChainLikelihood()))
{
if (isCastClass && canExpandInline && likelyCls == pResolvedToken->hClass)
if ((info.compCompHnd->compareTypesForCast(likelyCls, pResolvedToken->hClass) ==
TypeCompareState::Must))
{
// likelyClass is the same as declared - castclass is going to use the latter
// as a fast path anyway so do nothing here.
}
else if ((info.compCompHnd->compareTypesForEquality(likelyCls, likelyCls) ==
TypeCompareState::Must) &&
(info.compCompHnd->compareTypesForCast(likelyCls, pResolvedToken->hClass) ==
TypeCompareState::Must))
{
const UINT32 attrs = info.compCompHnd->getClassAttribs(likelyCls);
assert((attrs & (CORINFO_FLG_INTERFACE | CORINFO_FLG_ABSTRACT)) == 0);
assert((info.compCompHnd->getClassAttribs(likelyCls) &
(CORINFO_FLG_INTERFACE | CORINFO_FLG_ABSTRACT)) == 0);
JITDUMP("Adding \"is %s (%X)\" check as a fast path for %s using PGO data.\n",
eeGetClassName(likelyCls), likelyCls, isCastClass ? "castclass" : "isinst");
eeGetClassName(likelyCls), likelyCls, isCastClass ? "castclass" : "isinst");

canExpandInline = true;
partialExpand = true;
exactCls = gtNewIconEmbClsHndNode(likelyCls);

printf("!!! EGOR::::::::: %s -> %s\n", info.compMethodName, eeGetClassName(likelyCls));
partialExpand = true;
exactCls = gtNewIconEmbClsHndNode(likelyCls);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ CONFIG_STRING(JitEnablePatchpointRange, W("JitEnablePatchpointRange"))
// Profile instrumentation options
CONFIG_INTEGER(JitMinimalJitProfiling, W("JitMinimalJitProfiling"), 1)
CONFIG_INTEGER(JitMinimalPrejitProfiling, W("JitMinimalPrejitProfiling"), 0)
CONFIG_INTEGER(JitCastProfiling, W("JitCastProfiling"), 0) // Profile castclass and isinst
CONFIG_INTEGER(JitCastProfiling, W("JitCastProfiling"), 1) // CI test, will disable it back
CONFIG_INTEGER(JitClassProfiling, W("JitClassProfiling"), 1) // Profile virtual and interface calls
CONFIG_INTEGER(JitEdgeProfiling, W("JitEdgeProfiling"), 1) // Profile edges instead of blocks
CONFIG_INTEGER(JitCollect64BitCounts, W("JitCollect64BitCounts"), 0) // Collect counts as 64-bit values.
Expand Down