Skip to content

Commit

Permalink
CoreCLR runtime fixes for composite R2R build with shared framework (#…
Browse files Browse the repository at this point in the history
…34432)

In jithelpers, switch the query over to use a ReadyToRunInfo method
to make it work in composite mode. Also fix two places in
ReadyToRunInfo that were erroneously referring to composite info
(inlining tables).

Thanks

Tomas
  • Loading branch information
trylek authored Apr 8, 2020
1 parent e4c9f29 commit 614cac4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public void AttachToDependencyGraph(DependencyAnalyzerBase<NodeFactory> graph)

AssemblyTableNode assemblyTable = null;

if (CompilationModuleGroup.CompilationModuleSet.Skip(1).Any())
if (CompilationModuleGroup.IsCompositeBuildMode)
{
assemblyTable = new AssemblyTableNode(Target);
Header.Add(Internal.Runtime.ReadyToRunSectionType.ComponentAssemblies, assemblyTable, assemblyTable);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/tools/r2rdump/TextDumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ internal override void DumpSectionContents(ReadyToRunSection section)
MetadataReader globalReader = _r2r.GetGlobalMetadataReader();
assemblyRefCount = globalReader.GetTableRowCount(TableIndex.AssemblyRef) + 1;
_writer.WriteLine($"MSIL AssemblyRef's ({assemblyRefCount} entries):");
for (int assemblyRefIndex = 1; assemblyRefIndex <= assemblyRefCount; assemblyRefIndex++)
for (int assemblyRefIndex = 1; assemblyRefIndex < assemblyRefCount; assemblyRefIndex++)
{
AssemblyReference assemblyRef = globalReader.GetAssemblyReference(MetadataTokens.AssemblyReferenceHandle(assemblyRefIndex));
string assemblyRefName = globalReader.GetString(assemblyRef.Name);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@ CORINFO_GENERIC_HANDLE JIT_GenericHandleWorker(MethodDesc * pMD, MethodTable * p
#ifdef _DEBUG
// Only in R2R mode are the module, dictionary index and dictionary slot provided as an input
_ASSERTE(dictionaryIndexAndSlot != (DWORD)-1);
_ASSERT(ExecutionManager::FindReadyToRunModule(dac_cast<TADDR>(signature)) == pModule);
_ASSERT(ReadyToRunInfo::IsNativeImageSharedBy(pModule, ExecutionManager::FindReadyToRunModule(dac_cast<TADDR>(signature))));
#endif
dictionaryIndex = (dictionaryIndexAndSlot >> 16);
}
Expand Down
9 changes: 7 additions & 2 deletions src/coreclr/src/vm/readytoruninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,11 @@ PTR_ReadyToRunInfo ReadyToRunInfo::Initialize(Module * pModule, AllocMemTracker
return new (pMemory) ReadyToRunInfo(pModule, pLayout, pHeader, nativeImage, pamTracker);
}

bool ReadyToRunInfo::IsNativeImageSharedBy(PTR_Module pModule1, PTR_Module pModule2)
{
return pModule1->GetReadyToRunInfo()->m_pComposite == pModule2->GetReadyToRunInfo()->m_pComposite;
}

ReadyToRunInfo::ReadyToRunInfo(Module * pModule, PEImageLayout * pLayout, READYTORUN_HEADER * pHeader, NativeImage *pNativeImage, AllocMemTracker *pamTracker)
: m_pModule(pModule),
m_pHeader(pHeader),
Expand Down Expand Up @@ -709,7 +714,7 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, PEImageLayout * pLayout, READYT
// For format version 4.1 and later, there is an optional inlining table
if (IsImageVersionAtLeast(4, 1))
{
IMAGE_DATA_DIRECTORY* pInlineTrackingInfoDir = m_pComposite->FindSection(ReadyToRunSectionType::InliningInfo2);
IMAGE_DATA_DIRECTORY* pInlineTrackingInfoDir = m_component.FindSection(ReadyToRunSectionType::InliningInfo2);
if (pInlineTrackingInfoDir != NULL)
{
const BYTE* pInlineTrackingMapData = (const BYTE*)m_pComposite->GetImage()->GetDirectoryData(pInlineTrackingInfoDir);
Expand All @@ -721,7 +726,7 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, PEImageLayout * pLayout, READYT
// For format version 2.1 and later, there is an optional inlining table
if (m_pPersistentInlineTrackingMap == nullptr && IsImageVersionAtLeast(2, 1))
{
IMAGE_DATA_DIRECTORY * pInlineTrackingInfoDir = m_pComposite->FindSection(ReadyToRunSectionType::InliningInfo);
IMAGE_DATA_DIRECTORY * pInlineTrackingInfoDir = m_component.FindSection(ReadyToRunSectionType::InliningInfo);
if (pInlineTrackingInfoDir != NULL)
{
const BYTE* pInlineTrackingMapData = (const BYTE*)m_pComposite->GetImage()->GetDirectoryData(pInlineTrackingInfoDir);
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/src/vm/readytoruninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ReadyToRunInfo

bool IsComponentAssembly() const { return m_isComponentAssembly; }

static bool IsNativeImageSharedBy(PTR_Module pModule1, PTR_Module pModule2);

PTR_READYTORUN_HEADER GetReadyToRunHeader() const { return m_pHeader; }

PTR_NativeImage GetNativeImage() const { return m_pNativeImage; }
Expand Down

0 comments on commit 614cac4

Please sign in to comment.