Skip to content

Commit

Permalink
PGO: Enable profiled casts by default (#96597)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Jan 8, 2024
1 parent 0451127 commit f21dc6c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5572,13 +5572,20 @@ GenTree* Compiler::impCastClassOrIsInstToTree(
op2->gtFlags |= GTF_DONT_CSE;

GenTreeCall* call = gtNewHelperCallNode(helper, TYP_REF, op2, op1);

// Instrument this castclass/isinst
if ((JitConfig.JitClassProfiling() > 0) && impIsCastHelperEligibleForClassProbe(call) && !isClassExact)
{
HandleHistogramProfileCandidateInfo* pInfo = new (this, CMK_Inlining) HandleHistogramProfileCandidateInfo;
pInfo->ilOffset = ilOffset;
pInfo->probeIndex = info.compHandleHistogramProbeCount++;
call->gtHandleHistogramProfileCandidateInfo = pInfo;
compCurBB->SetFlags(BBF_HAS_HISTOGRAM_PROFILE);
// It doesn't make sense to instrument "x is T" or "(T)x" for shared T
if ((info.compCompHnd->getClassAttribs(pResolvedToken->hClass) & CORINFO_FLG_SHAREDINST) == 0)
{
HandleHistogramProfileCandidateInfo* pInfo =
new (this, CMK_Inlining) HandleHistogramProfileCandidateInfo;
pInfo->ilOffset = ilOffset;
pInfo->probeIndex = info.compHandleHistogramProbeCount++;
call->gtHandleHistogramProfileCandidateInfo = pInfo;
compCurBB->SetFlags(BBF_HAS_HISTOGRAM_PROFILE);
}
}
return call;
}
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 @@ -616,7 +616,7 @@ CONFIG_INTEGER(JitMinimalJitProfiling, W("JitMinimalJitProfiling"), 1)
CONFIG_INTEGER(JitMinimalPrejitProfiling, W("JitMinimalPrejitProfiling"), 0)

CONFIG_INTEGER(JitProfileValues, W("JitProfileValues"), 1) // Value profiling, e.g. Buffer.Memmove's size
CONFIG_INTEGER(JitProfileCasts, W("JitProfileCasts"), 0) // Profile castclass/isinst
CONFIG_INTEGER(JitProfileCasts, W("JitProfileCasts"), 1) // Profile castclass/isinst
CONFIG_INTEGER(JitConsumeProfileForCasts, W("JitConsumeProfileForCasts"), 1) // Consume profile data (if any) for
// castclass/isinst

Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6925,8 +6925,14 @@ int MethodContext::repGetIntConfigValue(const WCHAR* name, int defaultValue)
key.nameIndex = (DWORD)nameIndex;
key.defaultValue = defaultValue;

DWORD value = LookupByKeyOrMissNoMessage(GetIntConfigValue, key);
int index = GetIntConfigValue->GetIndex(key);
if (index == -1)
{
// default value has changed
return defaultValue;
}

DWORD value = GetIntConfigValue->GetItem(index);
DEBUG_REP(dmpGetIntConfigValue(key, value));
return (int)value;
}
Expand Down

0 comments on commit f21dc6c

Please sign in to comment.