未验证 提交 b20c355f 编写于 作者: D David Wrighton 提交者: GitHub

Disable R2R code for all associated components of a composite image (#65482)

- When loading a composite image, capture the detail that the composite image code cannot be used into the NativeImage structure, and flow that data into all associated ReadyToRunInfo structures.

Fixes #61471
上级 87d6d584
...@@ -4615,16 +4615,16 @@ void Module::RunEagerFixups() ...@@ -4615,16 +4615,16 @@ void Module::RunEagerFixups()
{ {
// For composite images, multiple modules may request initializing eager fixups // For composite images, multiple modules may request initializing eager fixups
// from multiple threads so we need to lock their resolution. // from multiple threads so we need to lock their resolution.
if (compositeNativeImage->EagerFixupsHaveRun())
{
return;
}
CrstHolder compositeEagerFixups(compositeNativeImage->EagerFixupsLock()); CrstHolder compositeEagerFixups(compositeNativeImage->EagerFixupsLock());
if (compositeNativeImage->EagerFixupsHaveRun()) if (compositeNativeImage->EagerFixupsHaveRun())
{ {
if (compositeNativeImage->ReadyToRunCodeDisabled())
GetReadyToRunInfo()->DisableAllR2RCode();
return; return;
} }
RunEagerFixupsUnlocked(); RunEagerFixupsUnlocked();
if (GetReadyToRunInfo()->ReadyToRunCodeDisabled())
compositeNativeImage->DisableAllR2RCode();
compositeNativeImage->SetEagerFixupsHaveRun(); compositeNativeImage->SetEagerFixupsHaveRun();
} }
else else
......
...@@ -59,6 +59,7 @@ NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *pImageL ...@@ -59,6 +59,7 @@ NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *pImageL
m_pImageLayout = pImageLayout; m_pImageLayout = pImageLayout;
m_fileName = imageFileName; m_fileName = imageFileName;
m_eagerFixupsHaveRun = false; m_eagerFixupsHaveRun = false;
m_readyToRunCodeDisabled = false;
} }
void NativeImage::Initialize(READYTORUN_HEADER *pHeader, LoaderAllocator *pLoaderAllocator, AllocMemTracker *pamTracker) void NativeImage::Initialize(READYTORUN_HEADER *pHeader, LoaderAllocator *pLoaderAllocator, AllocMemTracker *pamTracker)
......
...@@ -90,6 +90,7 @@ private: ...@@ -90,6 +90,7 @@ private:
Crst m_eagerFixupsLock; Crst m_eagerFixupsLock;
bool m_eagerFixupsHaveRun; bool m_eagerFixupsHaveRun;
bool m_readyToRunCodeDisabled;
private: private:
NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *peImageLayout, LPCUTF8 imageFileName); NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *peImageLayout, LPCUTF8 imageFileName);
...@@ -126,6 +127,18 @@ public: ...@@ -126,6 +127,18 @@ public:
void CheckAssemblyMvid(Assembly *assembly) const; void CheckAssemblyMvid(Assembly *assembly) const;
void DisableAllR2RCode()
{
LIMITED_METHOD_CONTRACT;
m_readyToRunCodeDisabled = true;
}
bool ReadyToRunCodeDisabled()
{
LIMITED_METHOD_CONTRACT;
return m_readyToRunCodeDisabled;
}
private: private:
IMDInternalImport *LoadManifestMetadata(); IMDInternalImport *LoadManifestMetadata();
}; };
......
...@@ -823,7 +823,7 @@ bool ReadyToRunInfo::GetPgoInstrumentationData(MethodDesc * pMD, BYTE** pAllocat ...@@ -823,7 +823,7 @@ bool ReadyToRunInfo::GetPgoInstrumentationData(MethodDesc * pMD, BYTE** pAllocat
return false; return false;
// If R2R code is disabled for this module, simply behave as if it is never found // If R2R code is disabled for this module, simply behave as if it is never found
if (m_readyToRunCodeDisabled) if (ReadyToRunCodeDisabled())
return false; return false;
if (m_pgoInstrumentationDataHashtable.IsNull()) if (m_pgoInstrumentationDataHashtable.IsNull())
...@@ -890,7 +890,7 @@ PCODE ReadyToRunInfo::GetEntryPoint(MethodDesc * pMD, PrepareCodeConfig* pConfig ...@@ -890,7 +890,7 @@ PCODE ReadyToRunInfo::GetEntryPoint(MethodDesc * pMD, PrepareCodeConfig* pConfig
goto done; goto done;
// If R2R code is disabled for this module, simply behave as if it is never found // If R2R code is disabled for this module, simply behave as if it is never found
if (m_readyToRunCodeDisabled) if (ReadyToRunCodeDisabled())
goto done; goto done;
ETW::MethodLog::GetR2RGetEntryPointStart(pMD); ETW::MethodLog::GetR2RGetEntryPointStart(pMD);
...@@ -1077,7 +1077,7 @@ BOOL ReadyToRunInfo::MethodIterator::Next() ...@@ -1077,7 +1077,7 @@ BOOL ReadyToRunInfo::MethodIterator::Next()
} }
CONTRACTL_END; CONTRACTL_END;
if (m_pInfo->m_readyToRunCodeDisabled) if (m_pInfo->ReadyToRunCodeDisabled())
return FALSE; return FALSE;
// Enumerate non-generic methods // Enumerate non-generic methods
......
...@@ -66,7 +66,7 @@ class ReadyToRunInfo ...@@ -66,7 +66,7 @@ class ReadyToRunInfo
PTR_CORCOMPILE_IMPORT_SECTION m_pImportSections; PTR_CORCOMPILE_IMPORT_SECTION m_pImportSections;
DWORD m_nImportSections; DWORD m_nImportSections;
bool m_readyToRunCodeDisabled; bool m_readyToRunCodeDisabled; // Is
NativeFormat::NativeReader m_nativeReader; NativeFormat::NativeReader m_nativeReader;
NativeFormat::NativeArray m_methodDefEntryPoints; NativeFormat::NativeArray m_methodDefEntryPoints;
...@@ -125,7 +125,13 @@ public: ...@@ -125,7 +125,13 @@ public:
void DisableAllR2RCode() void DisableAllR2RCode()
{ {
LIMITED_METHOD_CONTRACT; LIMITED_METHOD_CONTRACT;
m_readyToRunCodeDisabled = TRUE; m_readyToRunCodeDisabled = true;
}
bool ReadyToRunCodeDisabled()
{
LIMITED_METHOD_CONTRACT;
return m_readyToRunCodeDisabled;
} }
BOOL HasNonShareablePInvokeStubs() BOOL HasNonShareablePInvokeStubs()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册