Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CoreCLR runtime fixes for composite R2R build with shared framework #34432

Merged
merged 2 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,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 @@ -708,7 +713,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 @@ -720,7 +725,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 @@ -88,6 +88,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