Skip to content
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
40 changes: 28 additions & 12 deletions src/coreclr/src/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ BOOL Module::HasNativeOrReadyToRunInlineTrackingMap()
{
LIMITED_METHOD_DAC_CONTRACT;
#ifdef FEATURE_READYTORUN
if (IsReadyToRun() && GetReadyToRunInfo()->GetInlineTrackingMap() != NULL)
{
return TRUE;
}
if (IsReadyToRun() && GetReadyToRunInfo()->GetInlineTrackingMap() != NULL)
{
return TRUE;
}
#endif
return (m_pPersistentInlineTrackingMapNGen != NULL);
}
Expand Down Expand Up @@ -500,10 +500,9 @@ BOOL Module::IsPersistedObject(void *address)

uint32_t Module::GetNativeMetadataAssemblyCount()
{
NativeImage *compositeImage = GetCompositeNativeImage();
if (compositeImage != NULL)
if (m_pNativeImage != NULL)
{
return compositeImage->GetManifestAssemblyCount();
return m_pNativeImage->GetManifestAssemblyCount();
}
else
{
Expand Down Expand Up @@ -593,15 +592,25 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
#endif // FEATURE_COLLECTIBLE_TYPES

#ifdef FEATURE_READYTORUN
m_pNativeImage = NULL;
if (!HasNativeImage() && !IsResource())
{
if ((m_pReadyToRunInfo = ReadyToRunInfo::Initialize(this, pamTracker)) != NULL)
{
COUNT_T cMeta = 0;
if (GetFile()->GetOpenedILimage()->GetNativeManifestMetadata(&cMeta) != NULL)
m_pNativeImage = m_pReadyToRunInfo->GetNativeImage();
if (m_pNativeImage != NULL)
{
m_NativeMetadataAssemblyRefMap = m_pNativeImage->GetManifestMetadataAssemblyRefMap();
}
else
{
// Load the native assembly import
GetNativeAssemblyImport(TRUE /* loadAllowed */);
// For composite images, manifest metadata gets loaded as part of the native image
COUNT_T cMeta = 0;
if (GetFile()->GetOpenedILimage()->GetNativeManifestMetadata(&cMeta) != NULL)
{
// Load the native assembly import
GetNativeAssemblyImport(TRUE /* loadAllowed */);
}
}
}
}
Expand Down Expand Up @@ -9619,7 +9628,14 @@ void Module::Fixup(DataImage *image)
image->ZeroField(this, offsetof(Module, m_AssemblyRefByNameCount), sizeof(m_AssemblyRefByNameCount));
image->ZeroPointerField(this, offsetof(Module, m_AssemblyRefByNameTable));

image->ZeroPointerField(this,offsetof(Module, m_NativeMetadataAssemblyRefMap));
#ifdef FEATURE_READYTORUN
// For composite ready-to-run images, the manifest assembly ref map is stored in the native image
// and shared by all its component images.
if (m_pNativeImage == NULL)
#endif
{
image->ZeroPointerField(this,offsetof(Module, m_NativeMetadataAssemblyRefMap));
}

//
// Fixup statics
Expand Down
11 changes: 6 additions & 5 deletions src/coreclr/src/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,7 @@ class Module
#ifdef FEATURE_READYTORUN
private:
PTR_ReadyToRunInfo m_pReadyToRunInfo;
PTR_NativeImage m_pNativeImage;
#endif

private:
Expand Down Expand Up @@ -2924,17 +2925,17 @@ class Module
#endif
}

NativeImage *GetCompositeNativeImage() const
#ifdef FEATURE_READYTORUN
PTR_ReadyToRunInfo GetReadyToRunInfo() const
{
LIMITED_METHOD_DAC_CONTRACT;
return (m_pReadyToRunInfo != NULL ? m_pReadyToRunInfo->GetNativeImage() : NULL);
return m_pReadyToRunInfo;
}

#ifdef FEATURE_READYTORUN
PTR_ReadyToRunInfo GetReadyToRunInfo() const
PTR_NativeImage GetCompositeNativeImage() const
{
LIMITED_METHOD_DAC_CONTRACT;
return m_pReadyToRunInfo;
return m_pNativeImage;
}
#endif

Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/src/vm/nativeimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ void NativeImage::Initialize(READYTORUN_HEADER *pHeader, LoaderAllocator *pLoade
// count may exceed its component assembly count as it may contain references to
// assemblies outside of the composite image that are part of its version bubble.
_ASSERTE(m_manifestAssemblyCount >= m_componentAssemblyCount);

S_SIZE_T dwAllocSize = S_SIZE_T(sizeof(PTR_Assembly)) * S_SIZE_T(m_manifestAssemblyCount);

// Note: Memory allocated on loader heap is zero filled
m_pNativeMetadataAssemblyRefMap = (PTR_Assembly*)pamTracker->Track(pLoaderAllocator->GetLowFrequencyHeap()->AllocMem(dwAllocSize));
}

NativeImage::~NativeImage()
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/src/vm/nativeimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class NativeImage
ReadyToRunInfo *m_pReadyToRunInfo;
IMDInternalImport *m_pManifestMetadata;
PEImageLayout *m_pImageLayout;
PTR_Assembly *m_pNativeMetadataAssemblyRefMap;

IMAGE_DATA_DIRECTORY *m_pComponentAssemblies;
uint32_t m_componentAssemblyCount;
Expand Down Expand Up @@ -95,6 +96,7 @@ class NativeImage
ReadyToRunInfo *GetReadyToRunInfo() const { return m_pReadyToRunInfo; }
IMDInternalImport *GetManifestMetadata() const { return m_pManifestMetadata; }
uint32_t GetManifestAssemblyCount() const { return m_manifestAssemblyCount; }
PTR_Assembly *GetManifestMetadataAssemblyRefMap() { return m_pNativeMetadataAssemblyRefMap; }

Assembly *LoadManifestAssembly(uint32_t rowid);

Expand Down