Skip to content

Commit f654ce0

Browse files
committed
Extract out the minimal structure to support referencing information from a R2R image without requiring the PE format
1 parent 9ddf979 commit f654ce0

File tree

13 files changed

+110
-32
lines changed

13 files changed

+110
-32
lines changed

src/coreclr/debug/daccess/request.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ HRESULT ClrDataAccess::GetTieredVersions(
12321232
PTR_Module pModule = (PTR_Module)pMD->GetModule();
12331233
if (pModule->IsReadyToRun())
12341234
{
1235-
PTR_PEImageLayout pImage = pModule->GetReadyToRunInfo()->GetImage();
1235+
PTR_ReadyToRunLoadedImage pImage = pModule->GetReadyToRunInfo()->GetImage();
12361236
r2rImageBase = dac_cast<TADDR>(pImage->GetBase());
12371237
r2rImageEnd = r2rImageBase + pImage->GetVirtualSize();
12381238
}

src/coreclr/vm/ceeload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,7 +2060,7 @@ BOOL Module::IsVisibleToDebugger()
20602060
return TRUE;
20612061
}
20622062

2063-
PEImageLayout * Module::GetReadyToRunImage()
2063+
ReadyToRunLoadedImage * Module::GetReadyToRunImage()
20642064
{
20652065
LIMITED_METHOD_CONTRACT;
20662066

@@ -3583,7 +3583,7 @@ void Module::RunEagerFixupsUnlocked()
35833583
{
35843584
COUNT_T nSections;
35853585
PTR_READYTORUN_IMPORT_SECTION pSections = GetImportSections(&nSections);
3586-
PEImageLayout *pNativeImage = GetReadyToRunImage();
3586+
ReadyToRunLoadedImage *pNativeImage = GetReadyToRunImage();
35873587

35883588
for (COUNT_T iSection = 0; iSection < nSections; iSection++)
35893589
{

src/coreclr/vm/ceeload.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ class Module : public ModuleBase
14451445
LPCUTF8 GetDebugName() { WRAPPER_NO_CONTRACT; return m_pPEAssembly->GetDebugName(); }
14461446
#endif
14471447

1448-
PEImageLayout * GetReadyToRunImage();
1448+
ReadyToRunLoadedImage * GetReadyToRunImage();
14491449
PTR_READYTORUN_IMPORT_SECTION GetImportSections(COUNT_T *pCount);
14501450
PTR_READYTORUN_IMPORT_SECTION GetImportSectionFromIndex(COUNT_T index);
14511451
PTR_READYTORUN_IMPORT_SECTION GetImportSectionForRVA(RVA rva);
@@ -1490,7 +1490,7 @@ class Module : public ModuleBase
14901490
BOOL FixupDelayListAux(TADDR pFixupList,
14911491
Ptr pThis, FixupNativeEntryCallback pfnCB,
14921492
PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
1493-
PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods = TRUE);
1493+
ReadyToRunLoadedImage * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods = TRUE);
14941494
void RunEagerFixups();
14951495
void RunEagerFixupsUnlocked();
14961496

src/coreclr/vm/ceeload.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ template<typename Ptr, typename FixupNativeEntryCallback>
354354
BOOL Module::FixupDelayListAux(TADDR pFixupList,
355355
Ptr pThis, FixupNativeEntryCallback pfnCB,
356356
PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections,
357-
PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods)
357+
ReadyToRunLoadedImage * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods)
358358
{
359359
CONTRACTL
360360
{

src/coreclr/vm/codeman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6289,7 +6289,7 @@ unsigned ReadyToRunJitManager::InitializeEHEnumeration(const METHODTOKEN& Method
62896289
if (pExceptionInfoDir == NULL)
62906290
return 0;
62916291

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

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

src/coreclr/vm/frames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ static PTR_BYTE FindGCRefMap(PTR_Module pZapModule, TADDR ptr)
840840
{
841841
LIMITED_METHOD_DAC_CONTRACT;
842842

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

845845
RVA rva = pNativeImage->GetDataRva(ptr);
846846

src/coreclr/vm/nativeimage.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ NativeImageIndexTraits::count_t NativeImageIndexTraits::Hash(LPCUTF8 a)
4141
return SString(SString::Utf8Literal, a).HashCaseInsensitive();
4242
}
4343

44-
NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *pImageLayout, LPCUTF8 imageFileName)
44+
NativeImage::NativeImage(AssemblyBinder *pAssemblyBinder, ReadyToRunLoadedImage *pImageLayout, LPCUTF8 imageFileName)
4545
: m_eagerFixupsLock(CrstNativeImageEagerFixups)
4646
{
4747
CONTRACTL
@@ -236,7 +236,14 @@ NativeImage *NativeImage::Open(
236236
{
237237
COMPlusThrowHR(COR_E_BADIMAGEFORMAT);
238238
}
239-
NewHolder<NativeImage> image = new NativeImage(pAssemblyBinder, peLoadedImage.Extract(), nativeImageFileName);
239+
240+
NewHolder<ReadyToRunLoadedImage> peLoadedImageHolder = new ReadyToRunLoadedImage(
241+
(TADDR)peLoadedImage->GetBase(),
242+
peLoadedImage->GetSize(),
243+
peLoadedImage.Extract(),
244+
[](void* img) { delete (PEImageLayout*)img; });
245+
246+
NewHolder<NativeImage> image = new NativeImage(pAssemblyBinder, peLoadedImageHolder.Extract(), nativeImageFileName);
240247
AllocMemTracker amTracker;
241248
image->Initialize(pHeader, pLoaderAllocator, &amTracker);
242249
pExistingImage = AppDomain::GetCurrentDomain()->SetNativeImage(nativeImageFileName, image);

src/coreclr/vm/nativeimage.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ struct AssemblyNameIndex
1212
{
1313
LPCUTF8 Name;
1414
int32_t Index;
15-
15+
1616
AssemblyNameIndex() : Name(NULL), Index(-1) {}
1717
AssemblyNameIndex(LPCUTF8 name, int32_t index) : Name(name), Index(index) {}
18-
18+
1919
static AssemblyNameIndex GetNull() { return AssemblyNameIndex(); }
2020
bool IsNull() const { return Index < 0; }
2121
};
@@ -57,6 +57,7 @@ class NativeImageIndexTraits : public NoRemoveSHashTraits<MapSHashTraits<LPCUTF8
5757
};
5858

5959
class ReadyToRunInfo;
60+
class ReadyToRunLoadedImage;
6061
class PEAssembly;
6162
class PEImage;
6263

@@ -83,21 +84,21 @@ class NativeImage
8384
AssemblyBinder *m_pAssemblyBinder;
8485
ReadyToRunInfo *m_pReadyToRunInfo;
8586
IMDInternalImport *m_pManifestMetadata;
86-
PEImageLayout *m_pImageLayout;
87+
ReadyToRunLoadedImage *m_pImageLayout;
8788
PTR_Assembly *m_pNativeMetadataAssemblyRefMap;
8889
PTR_ModuleBase m_pNativeManifestModule;
89-
90+
9091
IMAGE_DATA_DIRECTORY *m_pComponentAssemblies;
9192
uint32_t m_componentAssemblyCount;
9293
uint32_t m_manifestAssemblyCount;
9394
SHash<AssemblyNameIndexHashTraits> m_assemblySimpleNameToIndexMap;
94-
95+
9596
Crst m_eagerFixupsLock;
9697
bool m_eagerFixupsHaveRun;
9798
bool m_readyToRunCodeDisabled;
9899

99100
private:
100-
NativeImage(AssemblyBinder *pAssemblyBinder, PEImageLayout *peImageLayout, LPCUTF8 imageFileName);
101+
NativeImage(AssemblyBinder *pAssemblyBinder, ReadyToRunLoadedImage *peImageLayout, LPCUTF8 imageFileName);
101102

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

127128
Assembly *LoadManifestAssembly(uint32_t rowid, Assembly *pParentAssembly);
128-
129+
129130
PTR_READYTORUN_CORE_HEADER GetComponentAssemblyHeader(LPCUTF8 assemblySimpleName);
130131

131132
void CheckAssemblyMvid(Assembly *assembly) const;

src/coreclr/vm/pgo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,13 +1002,13 @@ class R2RInstrumentationDataReader
10021002
{
10031003
ReadyToRunInfo *m_pReadyToRunInfo;
10041004
Module* m_pModule;
1005-
PEDecoder* m_pNativeImage;
1005+
ReadyToRunLoadedImage* m_pNativeImage;
10061006

10071007
public:
10081008
StackSArray<ICorJitInfo::PgoInstrumentationSchema> schemaArray;
10091009
StackSArray<BYTE> instrumentationData;
10101010

1011-
R2RInstrumentationDataReader(ReadyToRunInfo *pReadyToRunInfo, Module* pModule, PEDecoder* pNativeImage) :
1011+
R2RInstrumentationDataReader(ReadyToRunInfo *pReadyToRunInfo, Module* pModule, ReadyToRunLoadedImage* pNativeImage) :
10121012
m_pReadyToRunInfo(pReadyToRunInfo),
10131013
m_pModule(pModule),
10141014
m_pNativeImage(pNativeImage)
@@ -1103,7 +1103,7 @@ class R2RInstrumentationDataReader
11031103

11041104
HRESULT PgoManager::getPgoInstrumentationResultsFromR2RFormat(ReadyToRunInfo *pReadyToRunInfo,
11051105
Module* pModule,
1106-
PEDecoder* pNativeImage,
1106+
ReadyToRunLoadedImage* pNativeImage,
11071107
BYTE* pR2RFormatData,
11081108
size_t pR2RFormatDataMaxSize,
11091109
BYTE** pAllocatedData,

src/coreclr/vm/pgo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "shash.h"
88

99
class ReadyToRunInfo;
10+
class ReadyToRunLoadedImage;
1011

1112
// PgoManager handles in-process and out of band profile data for jitted code.
1213
class PgoManager
@@ -26,7 +27,7 @@ class PgoManager
2627
static HRESULT allocPgoInstrumentationBySchema(MethodDesc* pMD, ICorJitInfo::PgoInstrumentationSchema* pSchema, UINT32 countSchemaItems, BYTE** pInstrumentationData);
2728
static HRESULT getPgoInstrumentationResultsFromR2RFormat(ReadyToRunInfo *pReadyToRunInfo,
2829
Module* pModule,
29-
PEDecoder* pNativeImage,
30+
ReadyToRunLoadedImage* pNativeImage,
3031
BYTE* pR2RFormatData,
3132
size_t pR2RFormatDataMaxSize,
3233
BYTE** pAllocatedData,

0 commit comments

Comments
 (0)