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
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,9 @@ HRESULT ClrDataAccess::GetTieredVersions(
PTR_Module pModule = (PTR_Module)pMD->GetModule();
if (pModule->IsReadyToRun())
{
PTR_PEImageLayout pImage = pModule->GetReadyToRunInfo()->GetImage();
PTR_ReadyToRunLoadedImage pImage = pModule->GetReadyToRunInfo()->GetImage();
r2rImageBase = dac_cast<TADDR>(pImage->GetBase());
r2rImageEnd = r2rImageBase + pImage->GetSize();
r2rImageEnd = r2rImageBase + pImage->GetVirtualSize();
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ BOOL Module::IsVisibleToDebugger()
return TRUE;
}

PEImageLayout * Module::GetReadyToRunImage()
ReadyToRunLoadedImage * Module::GetReadyToRunImage()
{
LIMITED_METHOD_CONTRACT;

Expand Down Expand Up @@ -3583,7 +3583,7 @@ void Module::RunEagerFixupsUnlocked()
{
COUNT_T nSections;
PTR_READYTORUN_IMPORT_SECTION pSections = GetImportSections(&nSections);
PEImageLayout *pNativeImage = GetReadyToRunImage();
ReadyToRunLoadedImage *pNativeImage = GetReadyToRunImage();

for (COUNT_T iSection = 0; iSection < nSections; iSection++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ class Module : public ModuleBase
LPCUTF8 GetDebugName() { WRAPPER_NO_CONTRACT; return m_pPEAssembly->GetDebugName(); }
#endif

PEImageLayout * GetReadyToRunImage();
ReadyToRunLoadedImage * GetReadyToRunImage();
PTR_READYTORUN_IMPORT_SECTION GetImportSections(COUNT_T *pCount);
PTR_READYTORUN_IMPORT_SECTION GetImportSectionFromIndex(COUNT_T index);
PTR_READYTORUN_IMPORT_SECTION GetImportSectionForRVA(RVA rva);
Expand Down Expand Up @@ -1490,7 +1490,7 @@ class Module : public ModuleBase
BOOL FixupDelayListAux(TADDR pFixupList,
Ptr pThis, FixupNativeEntryCallback pfnCB,
PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods = TRUE);
ReadyToRunLoadedImage * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods = TRUE);
void RunEagerFixups();
void RunEagerFixupsUnlocked();

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/ceeload.inl
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ template<typename Ptr, typename FixupNativeEntryCallback>
BOOL Module::FixupDelayListAux(TADDR pFixupList,
Ptr pThis, FixupNativeEntryCallback pfnCB,
PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods)
ReadyToRunLoadedImage * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods)
{
CONTRACTL
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6289,7 +6289,7 @@ unsigned ReadyToRunJitManager::InitializeEHEnumeration(const METHODTOKEN& Method
if (pExceptionInfoDir == NULL)
return 0;

PEImageLayout * pLayout = pReadyToRunInfo->GetImage();
ReadyToRunLoadedImage * pLayout = pReadyToRunInfo->GetImage();

PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE pExceptionLookupTable = dac_cast<PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE>(pLayout->GetRvaData(pExceptionInfoDir->VirtualAddress));

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/frames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ static PTR_BYTE FindGCRefMap(PTR_Module pZapModule, TADDR ptr)
{
LIMITED_METHOD_DAC_CONTRACT;

PEImageLayout *pNativeImage = pZapModule->GetReadyToRunImage();
ReadyToRunLoadedImage *pNativeImage = pZapModule->GetReadyToRunImage();

RVA rva = pNativeImage->GetDataRva(ptr);

Expand Down
13 changes: 10 additions & 3 deletions src/coreclr/vm/nativeimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ NativeImageIndexTraits::count_t NativeImageIndexTraits::Hash(LPCUTF8 a)
return SString(SString::Utf8Literal, a).HashCaseInsensitive();
}

NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *pImageLayout, LPCUTF8 imageFileName)
NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, ReadyToRunLoadedImage *pImageLayout, LPCUTF8 imageFileName)
: m_eagerFixupsLock(CrstNativeImageEagerFixups)
{
CONTRACTL
Expand All @@ -64,7 +64,7 @@ void NativeImage::Initialize(READYTORUN_HEADER *pHeader, LoaderAllocator *pLoade
{
LoaderHeap *pHeap = pLoaderAllocator->GetHighFrequencyHeap();

m_pReadyToRunInfo = new ReadyToRunInfo(/*pModule*/ NULL, pLoaderAllocator, m_pImageLayout, pHeader, this, pamTracker);
m_pReadyToRunInfo = new ReadyToRunInfo(/*pModule*/ NULL, pLoaderAllocator, pHeader, this, m_pImageLayout, pamTracker);
m_pComponentAssemblies = m_pReadyToRunInfo->FindSection(ReadyToRunSectionType::ComponentAssemblies);
m_componentAssemblyCount = m_pComponentAssemblies->Size / sizeof(READYTORUN_COMPONENT_ASSEMBLIES_ENTRY);

Expand Down Expand Up @@ -236,7 +236,14 @@ NativeImage *NativeImage::Open(
{
COMPlusThrowHR(COR_E_BADIMAGEFORMAT);
}
NewHolder<NativeImage> image = new NativeImage(pAssemblyBinder, peLoadedImage.Extract(), nativeImageFileName);

NewHolder<ReadyToRunLoadedImage> peLoadedImageHolder = new ReadyToRunLoadedImage(
(TADDR)peLoadedImage->GetBase(),
peLoadedImage->GetVirtualSize(),
peLoadedImage.Extract(),
[](void* img) { delete (PEImageLayout*)img; });

NewHolder<NativeImage> image = new NativeImage(pAssemblyBinder, peLoadedImageHolder.Extract(), nativeImageFileName);
AllocMemTracker amTracker;
image->Initialize(pHeader, pLoaderAllocator, &amTracker);
pExistingImage = AppDomain::GetCurrentDomain()->SetNativeImage(nativeImageFileName, image);
Expand Down
15 changes: 8 additions & 7 deletions src/coreclr/vm/nativeimage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct AssemblyNameIndex
{
LPCUTF8 Name;
int32_t Index;

AssemblyNameIndex() : Name(NULL), Index(-1) {}
AssemblyNameIndex(LPCUTF8 name, int32_t index) : Name(name), Index(index) {}

static AssemblyNameIndex GetNull() { return AssemblyNameIndex(); }
bool IsNull() const { return Index < 0; }
};
Expand Down Expand Up @@ -57,6 +57,7 @@ class NativeImageIndexTraits : public NoRemoveSHashTraits<MapSHashTraits<LPCUTF8
};

class ReadyToRunInfo;
class ReadyToRunLoadedImage;
class PEAssembly;
class PEImage;

Expand All @@ -83,21 +84,21 @@ class NativeImage
AssemblyBinder *m_pAssemblyBinder;
ReadyToRunInfo *m_pReadyToRunInfo;
IMDInternalImport *m_pManifestMetadata;
PEImageLayout *m_pImageLayout;
ReadyToRunLoadedImage *m_pImageLayout;
PTR_Assembly *m_pNativeMetadataAssemblyRefMap;
PTR_ModuleBase m_pNativeManifestModule;

IMAGE_DATA_DIRECTORY *m_pComponentAssemblies;
uint32_t m_componentAssemblyCount;
uint32_t m_manifestAssemblyCount;
SHash<AssemblyNameIndexHashTraits> m_assemblySimpleNameToIndexMap;

Crst m_eagerFixupsLock;
bool m_eagerFixupsHaveRun;
bool m_readyToRunCodeDisabled;

private:
NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *peImageLayout, LPCUTF8 imageFileName);
NativeImage(AssemblyBinder *pAssemblyBinder, ReadyToRunLoadedImage *peImageLayout, LPCUTF8 imageFileName);

protected:
void Initialize(READYTORUN_HEADER *header, LoaderAllocator *loaderAllocator, AllocMemTracker *pamTracker);
Expand Down Expand Up @@ -125,7 +126,7 @@ class NativeImage
AssemblyBinder *GetAssemblyBinder() const { return m_pAssemblyBinder; }

Assembly *LoadManifestAssembly(uint32_t rowid, Assembly *pParentAssembly);

PTR_READYTORUN_CORE_HEADER GetComponentAssemblyHeader(LPCUTF8 assemblySimpleName);

void CheckAssemblyMvid(Assembly *assembly) const;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/pgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,13 +1002,13 @@ class R2RInstrumentationDataReader
{
ReadyToRunInfo *m_pReadyToRunInfo;
Module* m_pModule;
PEDecoder* m_pNativeImage;
ReadyToRunLoadedImage* m_pNativeImage;

public:
StackSArray<ICorJitInfo::PgoInstrumentationSchema> schemaArray;
StackSArray<BYTE> instrumentationData;

R2RInstrumentationDataReader(ReadyToRunInfo *pReadyToRunInfo, Module* pModule, PEDecoder* pNativeImage) :
R2RInstrumentationDataReader(ReadyToRunInfo *pReadyToRunInfo, Module* pModule, ReadyToRunLoadedImage* pNativeImage) :
m_pReadyToRunInfo(pReadyToRunInfo),
m_pModule(pModule),
m_pNativeImage(pNativeImage)
Expand Down Expand Up @@ -1103,7 +1103,7 @@ class R2RInstrumentationDataReader

HRESULT PgoManager::getPgoInstrumentationResultsFromR2RFormat(ReadyToRunInfo *pReadyToRunInfo,
Module* pModule,
PEDecoder* pNativeImage,
ReadyToRunLoadedImage* pNativeImage,
BYTE* pR2RFormatData,
size_t pR2RFormatDataMaxSize,
BYTE** pAllocatedData,
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/vm/pgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "shash.h"

class ReadyToRunInfo;
class ReadyToRunLoadedImage;

// PgoManager handles in-process and out of band profile data for jitted code.
class PgoManager
Expand All @@ -26,7 +27,7 @@ class PgoManager
static HRESULT allocPgoInstrumentationBySchema(MethodDesc* pMD, ICorJitInfo::PgoInstrumentationSchema* pSchema, UINT32 countSchemaItems, BYTE** pInstrumentationData);
static HRESULT getPgoInstrumentationResultsFromR2RFormat(ReadyToRunInfo *pReadyToRunInfo,
Module* pModule,
PEDecoder* pNativeImage,
ReadyToRunLoadedImage* pNativeImage,
BYTE* pR2RFormatData,
size_t pR2RFormatDataMaxSize,
BYTE** pAllocatedData,
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
{
GCX_PREEMP_THREAD_EXISTS(CURRENT_THREAD);

PEImageLayout *pNativeImage = pModule->GetReadyToRunImage();
ReadyToRunLoadedImage *pNativeImage = pModule->GetReadyToRunImage();

RVA rva = pNativeImage->GetDataRva(pIndirection);

Expand Down Expand Up @@ -3216,7 +3216,7 @@ PCODE DynamicHelperFixup(TransitionBlock * pTransitionBlock, TADDR * pCell, DWOR
{
STANDARD_VM_CONTRACT;

PEImageLayout *pNativeImage = pModule->GetReadyToRunImage();
ReadyToRunLoadedImage *pNativeImage = pModule->GetReadyToRunImage();

RVA rva = pNativeImage->GetDataRva((TADDR)pCell);

Expand Down
21 changes: 16 additions & 5 deletions src/coreclr/vm/readytoruninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ReadyToRunCoreInfo::ReadyToRunCoreInfo()
{
}

ReadyToRunCoreInfo::ReadyToRunCoreInfo(PEImageLayout* pLayout, READYTORUN_CORE_HEADER *pCoreHeader)
ReadyToRunCoreInfo::ReadyToRunCoreInfo(ReadyToRunLoadedImage* pLayout, READYTORUN_CORE_HEADER *pCoreHeader)
: m_pLayout(pLayout), m_pCoreHeader(pCoreHeader), m_fForbidLoadILBodyFixups(false)
{
}
Expand Down Expand Up @@ -625,7 +625,10 @@ PTR_ReadyToRunInfo ReadyToRunInfo::Initialize(Module * pModule, AllocMemTracker
return NULL;
}

LoaderHeap *pHeap = pModule->GetLoaderAllocator()->GetHighFrequencyHeap();

NativeImage *nativeImage = NULL;
ReadyToRunLoadedImage* loadedImage = nullptr;
if (isComponentAssembly)
{
nativeImage = AcquireCompositeImage(pModule, pLayout, pHeader);
Expand All @@ -642,14 +645,14 @@ PTR_ReadyToRunInfo ReadyToRunInfo::Initialize(Module * pModule, AllocMemTracker
DoLog("Ready to Run disabled - module already loaded in another assembly load context");
return NULL;
}
void* pLoadedImageMemory = pamTracker->Track(pHeap->AllocMem((S_SIZE_T)sizeof(ReadyToRunLoadedImage)));
loadedImage = new (pLoadedImageMemory) ReadyToRunLoadedImage((TADDR)pLayout->GetBase(), pLayout->GetVirtualSize());
}

LoaderHeap *pHeap = pModule->GetLoaderAllocator()->GetHighFrequencyHeap();
void * pMemory = pamTracker->Track(pHeap->AllocMem((S_SIZE_T)sizeof(ReadyToRunInfo)));

DoLog("Ready to Run initialized successfully");

return new (pMemory) ReadyToRunInfo(pModule, pModule->GetLoaderAllocator(), pLayout, pHeader, nativeImage, pamTracker);
return new (pMemory) ReadyToRunInfo(pModule, pModule->GetLoaderAllocator(), pHeader, nativeImage, loadedImage, pamTracker);
}

bool ReadyToRunInfo::IsNativeImageSharedBy(PTR_Module pModule1, PTR_Module pModule2)
Expand Down Expand Up @@ -762,7 +765,7 @@ PTR_ReadyToRunInfo ReadyToRunInfo::ComputeAlternateGenericLocationForR2RCode(Met
}
}

ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocator, PEImageLayout * pLayout, READYTORUN_HEADER * pHeader, NativeImage *pNativeImage, AllocMemTracker *pamTracker)
ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocator, READYTORUN_HEADER * pHeader, NativeImage *pNativeImage, ReadyToRunLoadedImage * pLayout, AllocMemTracker *pamTracker)
: m_pModule(pModule),
m_pHeader(pHeader),
m_pNativeImage(pModule != NULL ? pNativeImage: NULL), // m_pNativeImage is only set for composite image components, not the composite R2R info itself
Expand All @@ -775,6 +778,9 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocat

if ((pNativeImage != NULL) && (pModule != NULL))
{
// We are intializing ReadyToRunInfo for a specific component assembly inside a composite R2R image.
// In this case, we don't use the R2R info in the PE image directly, so we don't need the native layout.
_ASSERT(pLayout == NULL);
// In multi-assembly composite images, per assembly sections are stored next to their core headers.
m_pCompositeInfo = pNativeImage->GetReadyToRunInfo();
m_pComposite = m_pCompositeInfo->GetComponentInfo();
Expand All @@ -784,6 +790,11 @@ ReadyToRunInfo::ReadyToRunInfo(Module * pModule, LoaderAllocator* pLoaderAllocat
}
else
{
// We are in one of the two following cases:
// 1. Initializing ReadyToRunInfo for a single-assembly R2R image.
// 2. Initializing ReadyToRunInfo for the composite R2R image itself.
// In this case, we'll pull the ready to run image layout from pLayout.
_ASSERT(pLayout != NULL);
m_pCompositeInfo = this;
m_component = ReadyToRunCoreInfo(pLayout, &pHeader->CoreHeader);
m_pComposite = &m_component;
Expand Down
Loading
Loading