Skip to content

Commit

Permalink
Re-create profile data on profile-use-only mode (#71754)
Browse files Browse the repository at this point in the history
Activate multicorejit recorder to re-create the profile data
when the multicorejit player cannot be executed due to BADIMAGEFORMAT error on profile-use-only mode
  • Loading branch information
wscho77 authored Aug 11, 2022
1 parent ac0de3e commit 3dd36c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
12 changes: 5 additions & 7 deletions src/coreclr/vm/multicorejit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,16 +1202,13 @@ void MulticoreJitManager::StartProfile(AppDomain * pDomain, ICLRPrivBinder *pBin

if ((pProfile != NULL) && (pProfile[0] != 0)) // Ignore empty file name, just same as StopProfile
{
bool gatherProfile = (int)CLRConfig::GetConfigValue(CLRConfig::INTERNAL_MultiCoreJitNoProfileGather) == 0;

MulticoreJitRecorder * pRecorder = new (nothrow) MulticoreJitRecorder(
pDomain,
pBinderContext,
gatherProfile);
pBinderContext);

if (pRecorder != NULL)
{
gatherProfile = pRecorder->CanGatherProfile();
bool gatherProfile = (int)CLRConfig::GetConfigValue(CLRConfig::INTERNAL_MultiCoreJitNoProfileGather) == 0;

m_pMulticoreJitRecorder = pRecorder;

Expand All @@ -1221,9 +1218,10 @@ void MulticoreJitManager::StartProfile(AppDomain * pDomain, ICLRPrivBinder *pBin

MulticoreJitTrace(("MulticoreJitRecorder session %d created: %x", sessionID, hr));

if ((hr == COR_E_BADIMAGEFORMAT) || SUCCEEDED(hr)) // Ignore COR_E_BADIMAGEFORMAT, always record new profile
if ((hr == COR_E_BADIMAGEFORMAT) || (SUCCEEDED(hr) && gatherProfile)) // Ignore COR_E_BADIMAGEFORMAT, always record new profile
{
m_fRecorderActive = gatherProfile;
m_pMulticoreJitRecorder->Activate();
m_fRecorderActive = m_pMulticoreJitRecorder->CanGatherProfile();
}

_FireEtwMulticoreJit(W("STARTPROFILE"), W("Recorder"), m_fRecorderActive, hr, 0);
Expand Down
18 changes: 9 additions & 9 deletions src/coreclr/vm/multicorejitimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class MulticoreJitRecorder

public:

MulticoreJitRecorder(AppDomain * pDomain, ICLRPrivBinder * pBinderContext, bool fRecorderActive)
MulticoreJitRecorder(AppDomain * pDomain, ICLRPrivBinder * pBinderContext)
: m_stats(pDomain->GetMulticoreJitManager().GetStats())
, m_ModuleList(nullptr)
, m_JitInfoArray(nullptr)
Expand All @@ -665,18 +665,10 @@ class MulticoreJitRecorder
m_pDomain = pDomain;
m_pBinderContext = pBinderContext;

if (fRecorderActive)
{
m_ModuleList = new (nothrow) RecorderModuleInfo[MAX_MODULES];
}
m_ModuleCount = 0;

m_ModuleDepCount = 0;

if (fRecorderActive)
{
m_JitInfoArray = new (nothrow) RecorderInfo[MAX_METHODS];
}
m_JitInfoCount = 0;

m_fFirstMethod = true;
Expand Down Expand Up @@ -726,6 +718,14 @@ class MulticoreJitRecorder
(m_ModuleCount >= MAX_MODULES);
}

void Activate()
{
LIMITED_METHOD_CONTRACT;

m_ModuleList = new (nothrow) RecorderModuleInfo[MAX_MODULES];
m_JitInfoArray = new (nothrow) RecorderInfo[MAX_METHODS];
}

void RecordMethodJitOrLoad(MethodDesc * pMethod, bool application);

MulticoreJitCodeInfo RequestMethodCode(MethodDesc * pMethod, MulticoreJitManager * pManager);
Expand Down

0 comments on commit 3dd36c2

Please sign in to comment.