Skip to content

Commit

Permalink
Add MCS jitflags support for the new GetLikelyClass PGO record type (d…
Browse files Browse the repository at this point in the history
…otnet#51578)

Records of this type are created when class profile histograms in dynamic PGO
data are summarized by the static PGO tooling.

These records can appear in both prejit and jit schemas when the static PGO data is
passed back to the jit.
  • Loading branch information
AndyAyersMS authored Apr 21, 2021
1 parent 79fdeb8 commit d7e2b8f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/coreclr/ToolBox/superpmi/mcs/verbjitflags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ int verbJitFlags::DoWork(const char* nameOfInput)
//
bool hasEdgeProfile = false;
bool hasClassProfile = false;
if (mc->hasPgoData(hasEdgeProfile, hasClassProfile))
bool hasLikelyClass = false;
if (mc->hasPgoData(hasEdgeProfile, hasClassProfile, hasLikelyClass))
{
rawFlags |= 1ULL << (EXTRA_JIT_FLAGS::HAS_PGO);

Expand All @@ -42,6 +43,11 @@ int verbJitFlags::DoWork(const char* nameOfInput)
{
rawFlags |= 1ULL << (EXTRA_JIT_FLAGS::HAS_CLASS_PROFILE);
}

if (hasLikelyClass)
{
rawFlags |= 1ULL << (EXTRA_JIT_FLAGS::HAS_LIKELY_CLASS);
}
}

int index = flagMap.GetIndex(rawFlags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6784,7 +6784,7 @@ int MethodContext::dumpMD5HashToBuffer(BYTE* pBuffer, int bufLen, char* hash, in
return m_hash.HashBuffer(pBuffer, bufLen, hash, hashLen);
}

bool MethodContext::hasPgoData(bool& hasEdgeProfile, bool& hasClassProfile)
bool MethodContext::hasPgoData(bool& hasEdgeProfile, bool& hasClassProfile, bool& hasLikelyClass)
{
hasEdgeProfile = false;
hasClassProfile = false;
Expand All @@ -6808,8 +6808,9 @@ bool MethodContext::hasPgoData(bool& hasEdgeProfile, bool& hasClassProfile)
{
hasEdgeProfile |= (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::EdgeIntCount);
hasClassProfile |= (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::TypeHandleHistogramCount);
hasLikelyClass |= (schema[i].InstrumentationKind == ICorJitInfo::PgoInstrumentationKind::GetLikelyClass);

if (hasEdgeProfile && hasClassProfile)
if (hasEdgeProfile && hasClassProfile && hasLikelyClass)
{
break;
}
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ enum EXTRA_JIT_FLAGS
{
HAS_PGO = 63,
HAS_EDGE_PROFILE = 62,
HAS_CLASS_PROFILE = 61
HAS_CLASS_PROFILE = 61,
HAS_LIKELY_CLASS = 60
};

// Asserts to catch changes in corjit flags definitions.

static_assert((int)EXTRA_JIT_FLAGS::HAS_PGO == (int)CORJIT_FLAGS::CorJitFlag::CORJIT_FLAG_UNUSED36, "Jit Flags Mismatch");
static_assert((int)EXTRA_JIT_FLAGS::HAS_EDGE_PROFILE == (int)CORJIT_FLAGS::CorJitFlag::CORJIT_FLAG_UNUSED35, "Jit Flags Mismatch");
static_assert((int)EXTRA_JIT_FLAGS::HAS_CLASS_PROFILE == (int)CORJIT_FLAGS::CorJitFlag::CORJIT_FLAG_UNUSED34, "Jit Flags Mismatch");
static_assert((int)EXTRA_JIT_FLAGS::HAS_LIKELY_CLASS == (int)CORJIT_FLAGS::CorJitFlag::CORJIT_FLAG_UNUSED33, "Jit Flags Mismatch");

class MethodContext
{
Expand Down Expand Up @@ -97,7 +99,7 @@ class MethodContext
int dumpMethodIdentityInfoToBuffer(char* buff, int len, bool ignoreMethodName = false, CORINFO_METHOD_INFO* optInfo = nullptr, unsigned optFlags = 0);
int dumpMethodMD5HashToBuffer(char* buff, int len, bool ignoreMethodName = false, CORINFO_METHOD_INFO* optInfo = nullptr, unsigned optFlags = 0);

bool hasPgoData(bool& hasEdgeProfile, bool& hasClassProfile);
bool hasPgoData(bool& hasEdgeProfile, bool& hasClassProfile, bool& hasLikelyClass);

void recGlobalContext(const MethodContext& other);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ std::string SpmiDumpHelper::DumpJitFlags(unsigned long long flags)
AddFlagNumeric(HAS_PGO, EXTRA_JIT_FLAGS::HAS_PGO);
AddFlagNumeric(HAS_EDGE_PROFILE, EXTRA_JIT_FLAGS::HAS_EDGE_PROFILE);
AddFlagNumeric(HAS_CLASS_PROFILE, EXTRA_JIT_FLAGS::HAS_CLASS_PROFILE);
AddFlagNumeric(HAS_LIKELY_CLASS, EXTRA_JIT_FLAGS::HAS_LIKELY_CLASS);

#undef AddFlag
#undef AddFlagNumeric
Expand Down

0 comments on commit d7e2b8f

Please sign in to comment.