This refactoring is preparation for disabling fragile NGen support in the runtime. It keeps fragile-NGen specific code under FEATURE_PREJIT and moves the code required to support R2R to be outside FEATURE_PREJIT.
The eventual goal is to compile the runtime without FEATURE_PREJIT defined to avoid fragile-NGen specific overhead.
}
#endif
+#else //!FEATURE_PREJIT
+//dummy implementation for dac
+HRESULT ClrDataAccess::DumpNativeImage(CLRDATA_ADDRESS loadedBase,
+ LPCWSTR name,
+ IXCLRDataDisplay* display,
+ IXCLRLibrarySupport* support,
+ IXCLRDisassemblySupport* dis)
+{
+ return E_FAIL;
+}
+#endif //FEATURE_PREJIT
/* REVISIT_TODO Mon 10/10/2005
* Here is where it gets bad. There is no DAC build of gcdump, so instead
#pragma warning(default:4244)
#pragma warning(default:4189)
#endif // __MSC_VER
-
-
-#else //!FEATURE_PREJIT
-//dummy implementation for dac
-HRESULT ClrDataAccess::DumpNativeImage(CLRDATA_ADDRESS loadedBase,
- LPCWSTR name,
- IXCLRDataDisplay * display,
- IXCLRLibrarySupport * support,
- IXCLRDisassemblySupport * dis)
-{
- return E_FAIL;
-}
-#endif //FEATURE_PREJIT
//some DPTR definitions that aren't elsewhere in the source
typedef DPTR(const COR_SIGNATURE) PTR_CCOR_SIGNATURE;
typedef DPTR(IMAGE_SECTION_HEADER) PTR_IMAGE_SECTION_HEADER;
-typedef DPTR(CerNgenRootTable) PTR_CerNgenRootTable;
typedef DPTR(struct CerRoot) PTR_CerRoot;
-typedef DPTR(MethodContextElement) PTR_MethodContextElement;
typedef DPTR(DictionaryEntry) PTR_DictionaryEntry;
typedef DPTR(GuidInfo) PTR_GuidInfo;
#if defined(FEATURE_COMINTEROP)
void DumpTypes( PTR_Module module );
- void DumpNgenRootTable( PTR_CerNgenRootTable table, const char * name,
- unsigned offset, unsigned fieldSize );
-
void DumpMethodTable( PTR_MethodTable mt, const char * name,
PTR_Module module );
#ifndef _COR_COMPILE_H_
#define _COR_COMPILE_H_
-#ifndef FEATURE_PREJIT
-#error FEATURE_PREJIT is required for this file
-#endif // FEATURE_PREJIT
-
#if !defined(_TARGET_X86_) || defined(FEATURE_PAL)
#ifndef WIN64EXCEPTIONS
#define WIN64EXCEPTIONS
MDInternalImport_TrustedNativeImage = 2, // The image is a native image, and so its format can be trusted
MDInternalImport_ILMetaData = 4, // Open the IL metadata, even if this is a native image
MDInternalImport_TrustedNativeImage_and_IL = MDInternalImport_TrustedNativeImage | MDInternalImport_ILMetaData,
- MDInternalImport_NativeImageInstall = 0x100, // The image is a native image that is being installed into NIC
#endif
- MDInternalImport_CheckLongPath =8, // also check long version of the path
- MDInternalImport_CheckShortPath =0x10, // also check long version of the path
MDInternalImport_OnlyLookInCache =0x20, // Only look in the cache. (If the cache does not have the image already loaded, return NULL)
}; // enum MDInternalImportFlags
ULONG fn__ThePreStubPatchLabel;
ULONG fn__PrecodeFixupThunk;
+#ifdef FEATURE_PREJIT
ULONG fn__StubDispatchFixupStub;
- ULONG fn__StubDispatchFixupPatchLabel;;
+ ULONG fn__StubDispatchFixupPatchLabel;
+#endif
#ifdef FEATURE_COMINTEROP
ULONG fn__Unknown_AddRef;
ULONG fn__Unknown_AddRefSpecial;
JITHELPER(CORINFO_HELP_EE_PINVOKE_FIXUP, NDirectImportThunk, CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#ifdef FEATURE_PREJIT
JITHELPER(CORINFO_HELP_EE_VSD_FIXUP, StubDispatchFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#else
+ JITHELPER(CORINFO_HELP_EE_VSD_FIXUP, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#endif
JITHELPER(CORINFO_HELP_EE_EXTERNAL_FIXUP, ExternalMethodFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB)
JITHELPER(CORINFO_HELP_EE_VTABLE_FIXUP, VirtualMethodFixupStub, CORINFO_HELP_SIG_NO_ALIGN_STUB)
#include "cor.h"
#include "corhdr.h"
-#ifdef FEATURE_PREJIT
#include "corcompile.h"
-#else // FEATURE_PREJIT
-typedef DPTR(struct COR_ILMETHOD) PTR_COR_ILMETHOD;
-struct CORCOMPILE_HEADER { int dummy_field; };
-typedef DPTR(struct CORCOMPILE_HEADER) PTR_CORCOMPILE_HEADER;
-#define CORCOMPILE_IS_POINTER_TAGGED(fixup) (false)
-#endif // FEATURE_PREJIT
#include "readytorun.h"
typedef DPTR(struct READYTORUN_HEADER) PTR_READYTORUN_HEADER;
// Debug directory access, returns NULL if no such entry
PTR_IMAGE_DEBUG_DIRECTORY GetDebugDirectoryEntry(UINT index) const;
+ PTR_CVOID GetNativeManifestMetadata(COUNT_T* pSize = NULL) const;
+
#ifdef FEATURE_PREJIT
CHECK CheckNativeHeaderVersion() const;
PCODE GetNativeColdCode(COUNT_T * pSize = NULL) const;
CORCOMPILE_METHOD_PROFILE_LIST *GetNativeProfileDataList(COUNT_T *pSize = NULL) const;
- PTR_CVOID GetNativeManifestMetadata(COUNT_T *pSize = NULL) const;
const void *GetNativePreferredBase() const;
BOOL GetNativeILHasSecurityDirectory() const;
BOOL GetNativeILIsIbcOptimized() const;
// They are constant, FieldMarshal, MethodSemantics, ClassLayout, FieldLayout, ImplMap, FieldRVA, NestedClass, and MethodImpl
CLookUpHash * m_pLookUpHashs[TBL_COUNT];
-#if defined(FEATURE_PREJIT) && !defined(DACCESS_COMPILE)
+#if !defined(DACCESS_COMPILE)
MapSHash<UINT32, UINT32> m_StringPoolOffsetHash;
#endif
RETURN PTR_CORCOMPILE_METHOD_PROFILE_LIST(GetDirectoryData(pDir));
}
-
+#endif // FEATURE_PREJIT
PTR_CVOID PEDecoder::GetNativeManifestMetadata(COUNT_T *pSize) const
{
CONTRACT_END;
IMAGE_DATA_DIRECTORY *pDir;
- if (HasReadyToRunHeader())
+#ifdef FEATURE_PREJIT
+ if (!HasReadyToRunHeader())
+ {
+ pDir = GetMetaDataHelper(METADATA_SECTION_MANIFEST);
+ }
+ else
+#endif
{
READYTORUN_HEADER * pHeader = GetReadyToRunHeader();
pDir = &pSection->Section;
}
}
- else
- {
- pDir = GetMetaDataHelper(METADATA_SECTION_MANIFEST);
- }
if (pSize != NULL)
*pSize = VAL32(pDir->Size);
RETURN dac_cast<PTR_VOID>(GetDirectoryData(pDir));
}
+#ifdef FEATURE_PREJIT
+
PTR_CORCOMPILE_IMPORT_SECTION PEDecoder::GetNativeImportSections(COUNT_T *pCount) const
{
CONTRACT(PTR_CORCOMPILE_IMPORT_SECTION)
extern VSD_ResolveWorker:proc
extern CHAIN_SUCCESS_COUNTER:dword
+ifdef FEATURE_PREJIT
extern StubDispatchFixupWorker:proc
extern ProcessCLRException:proc
+endif
BACKPATCH_FLAG equ 1 ;; Also known as SDF_ResolveBackPatch in the EE
PROMOTE_CHAIN_FLAG equ 2 ;; Also known as SDF_ResolvePromoteChain in the EE
LEAF_END ResolveWorkerChainLookupAsmStub, _TEXT
+ifdef FEATURE_PREJIT
NESTED_ENTRY StubDispatchFixupStub, _TEXT, ProcessCLRException
PROLOG_WITH_TRANSITION_BLOCK
TAILJMP_RAX
NESTED_END StubDispatchFixupStub, _TEXT
+endif
end
// Get the NI PEFile if available.
PEImageHolder pPEImageNI;
+#ifdef FEATURE_PREJIT
if (dwAvailableImages & ASSEMBLY_IMAGE_TYPE_NATIVE)
{
DWORD dwImageType;
pPEImageNI = PEImage::OpenImage(pIResourceNI, MDInternalImport_TrustedNativeImage);
}
+#endif // FEATURE_PREJIT
_ASSERTE(pPEImageIL != nullptr);
// Create a PEAssembly using the IL and NI images.
#ifdef FEATURE_COMINTEROP
, m_InteropAttributeStatus(INTEROP_ATTRIBUTE_UNSET)
#endif
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
, m_isInstrumentedStatus(IS_INSTRUMENTED_UNSET)
#endif
{
return result;
}
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
BOOL Assembly::IsInstrumented()
{
STATIC_CONTRACT_THROWS;
BOOL IsSIMDVectorAssembly() { LIMITED_METHOD_DAC_CONTRACT; return m_fIsSIMDVectorAssembly; }
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
BOOL IsInstrumented();
BOOL IsInstrumentedHelper();
#endif // FEATURE_PREJIT
BOOL m_fIsSIMDVectorAssembly;
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
enum IsInstrumentedStatus {
IS_INSTRUMENTED_UNSET = 0,
IS_INSTRUMENTED_FALSE = 1,
}
}
+#ifdef FEATURE_PREJIT
// Form the PEImage for the NI assembly, if specified
if (pwzNIPath != NULL)
{
ThrowHR(COR_E_BADIMAGEFORMAT);
}
}
+#endif // FEATURE_PREJIT
Assembly *pLoadedAssembly = AssemblyNative::LoadFromPEImage(pBinderContext, pILImage, pNIImage);
m_nativeImageProfiling = FALSE;
+#ifdef FEATURE_PREJIT
if (HasNativeImage())
{
PEImageLayout * pNativeImage = GetNativeImage();
m_methodProfileList = pNativeImage->GetNativeProfileDataList(&cbProfileList);
}
else // ReadyToRun image
+#endif
{
#ifdef FEATURE_READYTORUN
// We already setup the m_methodProfileList in the ReadyToRunInfo constructor
}
#endif // defined(HAVE_GCCOVER)
}
+#else // FEATURE_PREJIT
+BOOL Module::IsPersistedObject(void *address)
+{
+ LIMITED_METHOD_CONTRACT;
+ return FALSE;
+}
+#endif // FEATURE_PREJIT
void Module::SetNativeMetadataAssemblyRefInCache(DWORD rid, PTR_Assembly pAssembly)
{
S_SIZE_T dwAllocSize = S_SIZE_T(sizeof(PTR_Assembly)) * S_SIZE_T(dwMaxRid);
AllocMemTracker amTracker;
- PTR_Assembly * NativeMetadataAssemblyRefMap = (PTR_Assembly *) amTracker.Track( GetLoaderAllocator()->GetLowFrequencyHeap()->AllocMem(dwAllocSize) );
+ PTR_Assembly* NativeMetadataAssemblyRefMap = (PTR_Assembly*)amTracker.Track(GetLoaderAllocator()->GetLowFrequencyHeap()->AllocMem(dwAllocSize));
// Note: Memory allocated on loader heap is zero filled
- if (InterlockedCompareExchangeT<PTR_Assembly *>(&m_NativeMetadataAssemblyRefMap, NativeMetadataAssemblyRefMap, NULL) == NULL)
+ if (InterlockedCompareExchangeT<PTR_Assembly*>(&m_NativeMetadataAssemblyRefMap, NativeMetadataAssemblyRefMap, NULL) == NULL)
amTracker.SuppressRelease();
}
_ASSERTE(m_NativeMetadataAssemblyRefMap != NULL);
_ASSERTE(rid <= GetNativeAssemblyImport()->GetCountWithTokenKind(mdtAssemblyRef));
- m_NativeMetadataAssemblyRefMap[rid-1] = pAssembly;
-}
-#else // FEATURE_PREJIT
-BOOL Module::IsPersistedObject(void *address)
-{
- LIMITED_METHOD_CONTRACT;
- return FALSE;
+ m_NativeMetadataAssemblyRefMap[rid - 1] = pAssembly;
}
-#endif // FEATURE_PREJIT
-
// Module initialization occurs in two phases: the constructor phase and the Initialize phase.
//
// The Initialize() phase completes the initialization after the constructor has run.
}
}
-#ifdef FEATURE_COMINTEROP
+#if defined(FEATURE_COMINTEROP) && defined(FEATURE_PREJIT)
if (IsCompilationProcess() && m_pGuidToTypeHash == NULL)
{
// only allocate this during NGEN-ing
}
CONTRACTL_END;
-#ifdef FEATURE_READYTORUN
- if (IsReadyToRun())
- return GetReadyToRunInfo()->GetImportSections(pCount);
+#ifdef FEATURE_PREJIT
+ if (!IsReadyToRun())
+ return GetNativeImage()->GetNativeImportSections(pCount);
#endif
- return GetNativeImage()->GetNativeImportSections(pCount);
+ return GetReadyToRunInfo()->GetImportSections(pCount);
}
PTR_CORCOMPILE_IMPORT_SECTION Module::GetImportSectionFromIndex(COUNT_T index)
}
CONTRACTL_END;
-#ifdef FEATURE_READYTORUN
- if (IsReadyToRun())
- return GetReadyToRunInfo()->GetImportSectionFromIndex(index);
+#ifdef FEATURE_PREJIT
+ if (!IsReadyToRun())
+ return GetNativeImage()->GetNativeImportSectionFromIndex(index);
#endif
- return GetNativeImage()->GetNativeImportSectionFromIndex(index);
+ return GetReadyToRunInfo()->GetImportSectionFromIndex(index);
}
PTR_CORCOMPILE_IMPORT_SECTION Module::GetImportSectionForRVA(RVA rva)
}
CONTRACTL_END;
-#ifdef FEATURE_READYTORUN
- if (IsReadyToRun())
- return GetReadyToRunInfo()->GetImportSectionForRVA(rva);
+#ifdef FEATURE_PREJIT
+ if (!IsReadyToRun())
+ return GetNativeImage()->GetNativeImportSectionForRVA(rva);
#endif
- return GetNativeImage()->GetNativeImportSectionForRVA(rva);
+ return GetReadyToRunInfo()->GetImportSectionForRVA(rva);
}
TADDR Module::GetIL(DWORD target)
return (address >= pLayout->GetBase()
&& address < (BYTE*)pLayout->GetBase() + pLayout->GetVirtualSize());
}
+#endif // FEATURE_PREJIT
Module *Module::GetModuleFromIndex(DWORD ix)
{
}
}
}
-#endif // FEATURE_PREJIT
#endif // !DACCESS_COMPILE
-#ifdef FEATURE_PREJIT
-
Module *Module::GetModuleFromIndexIfLoaded(DWORD ix)
{
CONTRACT(Module*)
}
#ifndef DACCESS_COMPILE
-
-BYTE *Module::GetNativeFixupBlobData(RVA rva)
-{
- CONTRACT(BYTE *)
- {
- INSTANCE_CHECK;
- NOTHROW;
- GC_NOTRIGGER;
- MODE_ANY;
- POSTCONDITION(CheckPointer(RETVAL));
- }
- CONTRACT_END;
-
- RETURN (BYTE *) GetNativeOrReadyToRunImage()->GetRvaData(rva);
-}
-
-IMDInternalImport *Module::GetNativeAssemblyImport(BOOL loadAllowed)
+IMDInternalImport* Module::GetNativeAssemblyImport(BOOL loadAllowed)
{
- CONTRACT(IMDInternalImport *)
+ CONTRACT(IMDInternalImport*)
{
INSTANCE_CHECK;
if (loadAllowed) GC_TRIGGERS; else GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(HasNativeOrReadyToRunImage());
POSTCONDITION(loadAllowed ?
- CheckPointer(RETVAL):
- CheckPointer(RETVAL, NULL_OK));
+ CheckPointer(RETVAL) :
+ CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
+#ifdef FEATURE_PREJIT
// Check if image is R2R
- if (GetFile()->IsILImageReadyToRun())
+ if (!GetFile()->IsILImageReadyToRun())
{
- RETURN GetFile()->GetOpenedILimage()->GetNativeMDImport(loadAllowed);
+ RETURN GetFile()->GetPersistentNativeImage()->GetNativeMDImport(loadAllowed);
}
- else
+#endif
+
+ RETURN GetFile()->GetOpenedILimage()->GetNativeMDImport(loadAllowed);
+}
+
+BYTE* Module::GetNativeFixupBlobData(RVA rva)
+{
+ CONTRACT(BYTE*)
{
- RETURN GetFile()->GetPersistentNativeImage()->GetNativeMDImport(loadAllowed);
+ INSTANCE_CHECK;
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ POSTCONDITION(CheckPointer(RETVAL));
}
+ CONTRACT_END;
+
+ RETURN(BYTE*) GetNativeOrReadyToRunImage()->GetRvaData(rva);
}
+#endif // DACCESS_COMPILE
+
+#ifdef FEATURE_PREJIT
+
+#ifndef DACCESS_COMPILE
/*static*/
void Module::RestoreMethodTablePointerRaw(MethodTable ** ppMT,
//-----------------------------------------------------------------------------
-BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION * pSection, SIZE_T fixupIndex, SIZE_T *fixupCell)
-{
- CONTRACTL
- {
- STANDARD_VM_CHECK;
- PRECONDITION(CheckPointer(fixupCell));
- }
- CONTRACTL_END;
-
- // Ensure that the compiler won't fetch the value twice
- SIZE_T fixup = VolatileLoadWithoutBarrier(fixupCell);
-
- if (pSection->Signatures != NULL)
- {
- if (fixup == NULL)
- {
- PTR_DWORD pSignatures = dac_cast<PTR_DWORD>(GetNativeOrReadyToRunImage()->GetRvaData(pSection->Signatures));
-
- if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell))
- return FALSE;
-
- _ASSERTE(*fixupCell != NULL);
- }
- }
- else
- {
- if (CORCOMPILE_IS_FIXUP_TAGGED(fixup, pSection))
- {
- // Fixup has not been fixed up yet
- if (!LoadDynamicInfoEntry(this, (RVA)CORCOMPILE_UNTAG_TOKEN(fixup), fixupCell))
- return FALSE;
-
- _ASSERTE(!CORCOMPILE_IS_FIXUP_TAGGED(*fixupCell, pSection));
- }
- else
- {
- //
- // Handle tables are special. We may need to restore static handle or previous
- // attempts to load handle could have been partial.
- //
- if (pSection->Type == CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE)
- {
- TypeHandle::FromPtr((void *)fixup).CheckRestore();
- }
- else
- if (pSection->Type == CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE)
- {
- ((MethodDesc *)(fixup))->CheckRestore();
- }
- }
- }
-
- return TRUE;
-}
-
-//-----------------------------------------------------------------------------
-
void Module::RunEagerFixups()
{
STANDARD_VM_CONTRACT;
}
#endif //FEATURE_PREJIT
+#ifndef DACCESS_COMPILE
+//-----------------------------------------------------------------------------
-#ifndef DACCESS_COMPILE
+BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupIndex, SIZE_T* fixupCell)
+{
+ CONTRACTL
+ {
+ STANDARD_VM_CHECK;
+ PRECONDITION(CheckPointer(fixupCell));
+ }
+ CONTRACTL_END;
+
+ // Ensure that the compiler won't fetch the value twice
+ SIZE_T fixup = VolatileLoadWithoutBarrier(fixupCell);
+
+ if (pSection->Signatures != NULL)
+ {
+ if (fixup == NULL)
+ {
+ PTR_DWORD pSignatures = dac_cast<PTR_DWORD>(GetNativeOrReadyToRunImage()->GetRvaData(pSection->Signatures));
+
+ if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell))
+ return FALSE;
+
+ _ASSERTE(*fixupCell != NULL);
+ }
+ }
+ else
+ {
+ if (CORCOMPILE_IS_FIXUP_TAGGED(fixup, pSection))
+ {
+ // Fixup has not been fixed up yet
+ if (!LoadDynamicInfoEntry(this, (RVA)CORCOMPILE_UNTAG_TOKEN(fixup), fixupCell))
+ return FALSE;
+
+ _ASSERTE(!CORCOMPILE_IS_FIXUP_TAGGED(*fixupCell, pSection));
+ }
+ else
+ {
+ //
+ // Handle tables are special. We may need to restore static handle or previous
+ // attempts to load handle could have been partial.
+ //
+ if (pSection->Type == CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE)
+ {
+ TypeHandle::FromPtr((void*)fixup).CheckRestore();
+ }
+ else
+ if (pSection->Type == CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE)
+ {
+ ((MethodDesc*)(fixup))->CheckRestore();
+ }
+ }
+ }
+
+ return TRUE;
+}
#ifdef FEATURE_PREJIT
//
{
m_pBinder->EnumMemoryRegions(flags);
}
+#ifdef FEATURE_PREJIT
m_ModuleCtorInfo.EnumMemoryRegions(flags);
+#endif
// Save the LookupMap structures.
m_MethodDefToDescMap.ListEnumMemoryRegions(flags);
#include "ilstubcache.h"
#include "classhash.h"
-#ifdef FEATURE_PREJIT
#include "corcompile.h"
-#include "dataimage.h"
#include <gcinfodecoder.h>
+
+#ifdef FEATURE_PREJIT
+#include "dataimage.h"
#endif // FEATURE_PREJIT
#ifdef FEATURE_COMINTEROP
class DynamicMethodTable;
class CodeVersionManager;
class TieredCompilationManager;
+class ProfileEmitter;
#ifdef FEATURE_PREJIT
-class CerNgenRootTable;
-struct MethodContextElement;
class TypeHandleList;
-class ProfileEmitter;
class TrackingMap;
struct MethodInModule;
class PersistentInlineTrackingMapNGen;
+extern VerboseLevel g_CorCompileVerboseLevel;
+#endif
+
// Hash table parameter of available classes (name -> module/class) hash
#define AVAILABLE_CLASSES_HASH_BUCKETS 1024
#define AVAILABLE_CLASSES_HASH_BUCKETS_COLLECTIBLE 128
typedef DPTR(PersistentInlineTrackingMapNGen) PTR_PersistentInlineTrackingMapNGen;
-extern VerboseLevel g_CorCompileVerboseLevel;
-#endif // FEATURE_PREJIT
-
//
// LookupMaps are used to implement RID maps
// It is a linked list of nodes, each handling a successive (and consecutive)
// Note that none of these flags survive a prejit save/restore.
MODULE_IS_TENURED = 0x00000001, // Set once we know for sure the Module will not be freed until the appdomain itself exits
- M_CER_ROOT_TABLE_ON_HEAP = 0x00000002, // Set when m_pCerNgenRootTable is allocated from heap (at ngen time)
+ // unused = 0x00000002,
CLASSES_FREED = 0x00000004,
IS_EDIT_AND_CONTINUE = 0x00000008, // is EnC Enabled for this module
PTR_ReadyToRunInfo m_pReadyToRunInfo;
#endif
-#ifdef FEATURE_PREJIT
-
private:
- PTR_NGenLayoutInfo m_pNGenLayoutInfo;
-
PTR_ProfilingBlobTable m_pProfilingBlobTable; // While performing IBC instrumenting this hashtable is populated with the External defs
CorProfileData * m_pProfileData; // While ngen-ing with IBC optimizations this contains a link to the IBC data for the assembly
DWORD m_dwExportedTypeCount;
#endif // PROFILING_SUPPORTED_DATA
+#ifdef FEATURE_PREJIT
+ PTR_NGenLayoutInfo m_pNGenLayoutInfo;
+
#if defined(FEATURE_COMINTEROP)
public:
#endif // defined(FEATURE_COMINTEROP)
-#endif // FEATURE_PREJIT
-
// Module wide static fields information
ModuleCtorInfo m_ModuleCtorInfo;
-#ifdef FEATURE_PREJIT
+#endif // FEATURE_PREJIT
+
struct TokenProfileData
{
static TokenProfileData *CreateNoThrow(void);
} *m_tokenProfileData;
+#ifdef FEATURE_PREJIT
// Stats for prejit log
NgenStats *m_pNgenStats;
#endif // FEATURE_PREJIT
m_pDllMain = pMD;
}
+#ifdef FEATURE_PREJIT
// This data is only valid for NGEN'd modules, and for modules we're creating at NGEN time.
ModuleCtorInfo* GetZapModuleCtorInfo()
{
LIMITED_METHOD_DAC_CONTRACT;
-
+
return &m_ModuleCtorInfo;
}
+#endif
private:
PCCOR_SIGNATURE GetEncodedSig(RVA fixupRva, Module **ppDefiningModule);
PCCOR_SIGNATURE GetEncodedSigIfLoaded(RVA fixupRva, Module **ppDefiningModule);
+#endif
- BYTE *GetNativeFixupBlobData(RVA fixup);
+ BYTE* GetNativeFixupBlobData(RVA fixup);
IMDInternalImport *GetNativeAssemblyImport(BOOL loadAllowed = TRUE);
IMDInternalImport *GetNativeAssemblyImportIfLoaded();
PEDecoder * pNativeImage);
void RunEagerFixups();
- IMDInternalImport *GetNativeFixupImport();
Module *GetModuleFromIndex(DWORD ix);
Module *GetModuleFromIndexIfLoaded(DWORD ix);
+#ifdef FEATURE_PREJIT
// This is to rebuild stub dispatch maps to module-local values.
void UpdateStubDispatchTypeTable(DataImage *image);
return m_pNGenLayoutInfo->m_VirtualMethodThunks.IsInRange(code);
}
+#endif // FEATURE_PREJIT
ICorJitInfo::ProfileBuffer * AllocateProfileBuffer(mdToken _token, DWORD _size, DWORD _ILSize);
HANDLE OpenMethodProfileDataLogFile(GUID mvid);
void LogTokenAccess(mdToken token, SectionFormat format, ULONG flagNum);
void LogTokenAccess(mdToken token, ULONG flagNum);
+#ifdef FEATURE_PREJIT
BOOL AreTypeSpecsTriaged()
{
return m_dwTransientFlags & TYPESPECS_TRIAGED;
LPCSTR *m_AssemblyRefByNameTable; // array that maps mdAssemblyRef tokens into their simple name
DWORD m_AssemblyRefByNameCount; // array size
-#if defined(FEATURE_PREJIT)
// a.dll calls a method in b.dll and that method call a method in c.dll. When ngening
// a.dll it is possible then method in b.dll can be inlined. When that happens a.ni.dll stores
// an added native metadata which has information about assemblyRef to c.dll
// is not called for each fixup
PTR_Assembly *m_NativeMetadataAssemblyRefMap;
-#endif // defined(FEATURE_PREJIT)
public:
-#if !defined(DACCESS_COMPILE) && defined(FEATURE_PREJIT)
+#if !defined(DACCESS_COMPILE)
PTR_Assembly GetNativeMetadataAssemblyRefFromCache(DWORD rid)
{
PTR_Assembly * NativeMetadataAssemblyRefMap = VolatileLoadWithoutBarrier(&m_NativeMetadataAssemblyRefMap);
}
void SetNativeMetadataAssemblyRefInCache(DWORD rid, PTR_Assembly pAssembly);
-#endif // !defined(DACCESS_COMPILE) && defined(FEATURE_PREJIT)
+#endif // !defined(DACCESS_COMPILE)
};
//
return pDomain->GetDomainLocalBlock()->GetModuleSlot(GetModuleIndex());
}
-#ifdef FEATURE_PREJIT
-
#include "nibblestream.h"
FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList)
return TRUE;
}
-#endif //FEATURE_PREJIT
-
inline PTR_LoaderAllocator Module::GetLoaderAllocator()
{
LIMITED_METHOD_DAC_CONTRACT;
EXTERN_C ICorJitCompiler* __stdcall getJit();
#endif // FEATURE_MERGE_JIT_AND_ENGINE
-// Set this to the result of LoadJIT as a courtesy to code:CorCompileGetRuntimeDll
-extern HMODULE s_ngenCompilerDll;
-
BOOL EEJitManager::LoadJIT()
{
STANDARD_VM_CONTRACT;
g_JitLoadData.jld_id = JIT_LOAD_MAIN;
LoadAndInitializeJIT(ExecutionManager::GetJitName(), &m_JITCompiler, &newJitCompiler, &g_JitLoadData);
-
- // Set as a courtesy to code:CorCompileGetRuntimeDll
- s_ngenCompilerDll = m_JITCompiler;
#endif // !FEATURE_MERGE_JIT_AND_ENGINE
#ifdef ALLOW_SXS_JIT
}
#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
+static void GetFuncletStartOffsetsHelper(PCODE pCodeStart, SIZE_T size, SIZE_T ofsAdj,
+ PTR_RUNTIME_FUNCTION pFunctionEntry, TADDR moduleBase,
+ DWORD * pnFunclets, DWORD* pStartFuncletOffsets, DWORD dwLength)
+{
+ _ASSERTE(FitsInU4((pCodeStart + size) - moduleBase));
+ DWORD endAddress = (DWORD)((pCodeStart + size) - moduleBase);
+
+ // Entries are sorted and terminated by sentinel value (DWORD)-1
+ for (; RUNTIME_FUNCTION__BeginAddress(pFunctionEntry) < endAddress; pFunctionEntry++)
+ {
+#ifdef _TARGET_AMD64_
+ _ASSERTE((pFunctionEntry->UnwindData & RUNTIME_FUNCTION_INDIRECT) == 0);
+#endif
+
+#if defined(EXCEPTION_DATA_SUPPORTS_FUNCTION_FRAGMENTS)
+ if (IsFunctionFragment(moduleBase, pFunctionEntry))
+ {
+ // This is a fragment (not the funclet beginning); skip it
+ continue;
+ }
+#endif // EXCEPTION_DATA_SUPPORTS_FUNCTION_FRAGMENTS
+
+ if (*pnFunclets < dwLength)
+ {
+ TADDR funcletStartAddress = (moduleBase + RUNTIME_FUNCTION__BeginAddress(pFunctionEntry)) + ofsAdj;
+ _ASSERTE(FitsInU4(funcletStartAddress - pCodeStart));
+ pStartFuncletOffsets[*pnFunclets] = (DWORD)(funcletStartAddress - pCodeStart);
+ }
+ (*pnFunclets)++;
+ }
+}
+
+#if defined(WIN64EXCEPTIONS) && defined(DACCESS_COMPILE)
+
+//
+// To locate an entry in the function entry table (the program exceptions data directory), the debugger
+// performs a binary search over the table. This function reports the entries that are encountered in the
+// binary search.
+//
+// Parameters:
+// pRtf: The target function table entry to be located
+// pNativeLayout: A pointer to the loaded native layout for the module containing pRtf
+//
+static void EnumRuntimeFunctionEntriesToFindEntry(PTR_RUNTIME_FUNCTION pRtf, PTR_PEImageLayout pNativeLayout)
+{
+ pRtf.EnumMem();
+
+ if (pNativeLayout == NULL)
+ {
+ return;
+ }
+
+ IMAGE_DATA_DIRECTORY * pProgramExceptionsDirectory = pNativeLayout->GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXCEPTION);
+ if (!pProgramExceptionsDirectory ||
+ (pProgramExceptionsDirectory->Size == 0) ||
+ (pProgramExceptionsDirectory->Size % sizeof(T_RUNTIME_FUNCTION) != 0))
+ {
+ // Program exceptions directory malformatted
+ return;
+ }
+
+ PTR_BYTE moduleBase(pNativeLayout->GetBase());
+ PTR_RUNTIME_FUNCTION firstFunctionEntry(moduleBase + pProgramExceptionsDirectory->VirtualAddress);
+
+ if (pRtf < firstFunctionEntry ||
+ ((dac_cast<TADDR>(pRtf) - dac_cast<TADDR>(firstFunctionEntry)) % sizeof(T_RUNTIME_FUNCTION) != 0))
+ {
+ // Program exceptions directory malformatted
+ return;
+ }
+
+ // Review conversion of size_t to ULONG.
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4267)
+#endif // defined(_MSC_VER)
+
+ ULONG indexToLocate = pRtf - firstFunctionEntry;
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif // defined(_MSC_VER)
+
+ ULONG low = 0; // index in the function entry table of low end of search range
+ ULONG high = (pProgramExceptionsDirectory->Size) / sizeof(T_RUNTIME_FUNCTION) - 1; // index of high end of search range
+ ULONG mid = (low + high) / 2; // index of entry to be compared
+
+ if (indexToLocate > high)
+ {
+ return;
+ }
+
+ while (indexToLocate != mid)
+ {
+ PTR_RUNTIME_FUNCTION functionEntry = firstFunctionEntry + mid;
+ functionEntry.EnumMem();
+ if (indexToLocate > mid)
+ {
+ low = mid + 1;
+ }
+ else
+ {
+ high = mid - 1;
+ }
+ mid = (low + high) / 2;
+ _ASSERTE(low <= mid && mid <= high);
+ }
+}
+#endif // WIN64EXCEPTIONS
+
#ifdef FEATURE_PREJIT
//***************************************************************************************
//***************************************************************************************
return IJitManager::GetFuncletStartAddress(pCodeInfo);
}
-static void GetFuncletStartOffsetsHelper(PCODE pCodeStart, SIZE_T size, SIZE_T ofsAdj,
- PTR_RUNTIME_FUNCTION pFunctionEntry, TADDR moduleBase,
- DWORD * pnFunclets, DWORD* pStartFuncletOffsets, DWORD dwLength)
-{
- _ASSERTE(FitsInU4((pCodeStart + size) - moduleBase));
- DWORD endAddress = (DWORD)((pCodeStart + size) - moduleBase);
-
- // Entries are sorted and terminated by sentinel value (DWORD)-1
- for ( ; RUNTIME_FUNCTION__BeginAddress(pFunctionEntry) < endAddress; pFunctionEntry++)
- {
-#ifdef _TARGET_AMD64_
- _ASSERTE((pFunctionEntry->UnwindData & RUNTIME_FUNCTION_INDIRECT) == 0);
-#endif
-
-#if defined(EXCEPTION_DATA_SUPPORTS_FUNCTION_FRAGMENTS)
- if (IsFunctionFragment(moduleBase, pFunctionEntry))
- {
- // This is a fragment (not the funclet beginning); skip it
- continue;
- }
-#endif // EXCEPTION_DATA_SUPPORTS_FUNCTION_FRAGMENTS
-
- if (*pnFunclets < dwLength)
- {
- TADDR funcletStartAddress = (moduleBase + RUNTIME_FUNCTION__BeginAddress(pFunctionEntry)) + ofsAdj;
- _ASSERTE(FitsInU4(funcletStartAddress - pCodeStart));
- pStartFuncletOffsets[*pnFunclets] = (DWORD)(funcletStartAddress - pCodeStart);
- }
- (*pnFunclets)++;
- }
-}
-
DWORD NativeImageJitManager::GetFuncletStartOffsets(const METHODTOKEN& MethodToken, DWORD* pStartFuncletOffsets, DWORD dwLength)
{
CONTRACTL
#if defined(WIN64EXCEPTIONS)
-//
-// To locate an entry in the function entry table (the program exceptions data directory), the debugger
-// performs a binary search over the table. This function reports the entries that are encountered in the
-// binary search.
-//
-// Parameters:
-// pRtf: The target function table entry to be located
-// pNativeLayout: A pointer to the loaded native layout for the module containing pRtf
-//
-static void EnumRuntimeFunctionEntriesToFindEntry(PTR_RUNTIME_FUNCTION pRtf, PTR_PEImageLayout pNativeLayout)
-{
- pRtf.EnumMem();
-
- if (pNativeLayout == NULL)
- {
- return;
- }
-
- IMAGE_DATA_DIRECTORY * pProgramExceptionsDirectory = pNativeLayout->GetDirectoryEntry(IMAGE_DIRECTORY_ENTRY_EXCEPTION);
- if (!pProgramExceptionsDirectory ||
- (pProgramExceptionsDirectory->Size == 0) ||
- (pProgramExceptionsDirectory->Size % sizeof(T_RUNTIME_FUNCTION) != 0))
- {
- // Program exceptions directory malformatted
- return;
- }
-
- PTR_BYTE moduleBase(pNativeLayout->GetBase());
- PTR_RUNTIME_FUNCTION firstFunctionEntry(moduleBase + pProgramExceptionsDirectory->VirtualAddress);
-
- if (pRtf < firstFunctionEntry ||
- ((dac_cast<TADDR>(pRtf) - dac_cast<TADDR>(firstFunctionEntry)) % sizeof(T_RUNTIME_FUNCTION) != 0))
- {
- // Program exceptions directory malformatted
- return;
- }
-
-// Review conversion of size_t to ULONG.
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable:4267)
-#endif // defined(_MSC_VER)
-
- ULONG indexToLocate = pRtf - firstFunctionEntry;
-
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif // defined(_MSC_VER)
-
- ULONG low = 0; // index in the function entry table of low end of search range
- ULONG high = (pProgramExceptionsDirectory->Size)/sizeof(T_RUNTIME_FUNCTION) - 1; // index of high end of search range
- ULONG mid = (low + high) /2; // index of entry to be compared
-
- if (indexToLocate > high)
- {
- return;
- }
-
- while (indexToLocate != mid)
- {
- PTR_RUNTIME_FUNCTION functionEntry = firstFunctionEntry + mid;
- functionEntry.EnumMem();
- if (indexToLocate > mid)
- {
- low = mid + 1;
- }
- else
- {
- high = mid - 1;
- }
- mid = (low + high) /2;
- _ASSERTE( low <= mid && mid <= high );
- }
-}
-
//
// EnumMemoryRegionsForMethodUnwindInfo - enumerate the memory necessary to read the unwind info for the
// specified method.
#endif //WIN64EXCEPTIONS
#endif // #ifdef DACCESS_COMPILE
+#endif // FEATURE_PREJIT
+
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
+
// Return start of exception info for a method, or 0 if the method has no EH info
DWORD NativeExceptionInfoLookupTable::LookupExceptionInfoRVAForMethod(PTR_CORCOMPILE_EXCEPTION_LOOKUP_TABLE pExceptionLookupTable,
COUNT_T numLookupEntries,
return -1;
}
+#ifdef FEATURE_PREJIT
BOOL NativeUnwindInfoLookupTable::HasExceptionInfo(NGenLayoutInfo * pNgenLayout, PTR_RUNTIME_FUNCTION pMainRuntimeFunction)
{
LIMITED_METHOD_DAC_CONTRACT;
return rva;
}
-
#endif // FEATURE_PREJIT
+#endif // FEATURE_PREJIT || FEATURE_READYTORUN
+
#ifndef DACCESS_COMPILE
//-----------------------------------------------------------------------------
#endif //DACCESS_COMPILE
};
+inline TADDR NativeImageJitManager::JitTokenToStartAddress(const METHODTOKEN& MethodToken)
+{
+ CONTRACTL{
+ NOTHROW;
+ GC_NOTRIGGER;
+ HOST_NOCALLS;
+ SUPPORTS_DAC;
+ } CONTRACTL_END;
+
+ return JitTokenToModuleBase(MethodToken) +
+ RUNTIME_FUNCTION__BeginAddress(dac_cast<PTR_RUNTIME_FUNCTION>(MethodToken.m_pCodeHeader));
+}
+
+#endif // FEATURE_PREJIT
+
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
+
class NativeExceptionInfoLookupTable
{
public:
int StartIndex,
int EndIndex);
+#ifdef FEATURE_PREJIT
static BOOL HasExceptionInfo(NGenLayoutInfo * pNgenLayout, PTR_RUNTIME_FUNCTION pMainRuntimeFunction);
static PTR_MethodDesc GetMethodDesc(NGenLayoutInfo * pNgenLayout, PTR_RUNTIME_FUNCTION pMainRuntimeFunction, TADDR moduleBase);
private:
static DWORD GetMethodDescRVA(NGenLayoutInfo * pNgenLayout, PTR_RUNTIME_FUNCTION pMainRuntimeFunction);
+#endif
};
-inline TADDR NativeImageJitManager::JitTokenToStartAddress(const METHODTOKEN& MethodToken)
-{
- CONTRACTL {
- NOTHROW;
- GC_NOTRIGGER;
- HOST_NOCALLS;
- SUPPORTS_DAC;
- } CONTRACTL_END;
-
- return JitTokenToModuleBase(MethodToken) +
- RUNTIME_FUNCTION__BeginAddress(dac_cast<PTR_RUNTIME_FUNCTION>(MethodToken.m_pCodeHeader));
-}
-
-#endif // FEATURE_PREJIT
+#endif // FEATURE_PREJIT || FEATURE_READYTORUN
#ifdef FEATURE_READYTORUN
if (!pLayout->CheckFormat())
IfFailGo(COR_E_BADIMAGEFORMAT);
+#ifdef FEATURE_PREJIT
if (bNativeImage && pPEImage->IsNativeILILOnly())
{
pPEImage->GetNativeILPEKindAndMachine(&pdwPAFlags[0], &pdwPAFlags[1]);
}
else
+#endif
{
pPEImage->GetPEKindAndMachine(&pdwPAFlags[0], &pdwPAFlags[1]);
}
PEImage* GetNativeImage();
void SetNativeImage(PEImage * pNativeImage);
PEImage* GetILImage();
+#else
+ BOOL HasNativeImage() { return FALSE; }
+ PEImage* GetNativeImage() { return NULL; }
#endif
void SetHRBindResult(HRESULT hrBindResult);
HRESULT GetHRBindResult();
#ifdef FEATURE_COMINTEROP
if (SF_IsReverseCOMStub(dwStubFlags))
{
+#ifdef FEATURE_PREJIT
if (fGcMdaEnabled)
return NULL;
// reverse COM stubs live in a hash table
StubMethodHashTable *pHash = pMD->GetLoaderModule()->GetStubMethodHashTable();
return (pHash == NULL ? NULL : pHash->FindMethodDesc(pMD));
+#else
+ return NULL;
+#endif
}
else
#endif // FEATURE_COMINTEROP
GetFile()->FlushExternalLog();
StackSString ss;
- ss.Printf("ZapRequire: Could not get native image for %s.\n"
- "Use FusLogVw.exe to check the reason.",
+ ss.Printf("ZapRequire: Could not get native image for %s.\n",
GetSimpleName());
#if defined(_DEBUG)
PEFile* pFile = pModule->GetFile();
if (pFile)
{
+#ifdef FEATURE_PREJIT
// if we have a native imaged loaded for this module then get the version information from that.
if (pFile->IsNativeLoaded())
{
}
}
}
+#endif
// if we failed to get the version info from the native image then fall back to the IL image.
if (!succeeded)
{
ULONG Result = ERROR_SUCCESS;
-
+#ifdef FEATURE_PREJIT
// do not fire the ETW event when:
// 1. We did not load the native image
// 2. We do not have IBC data for the native image
Result &= FireEtwModuleRangeLoadPrivate(ClrInstanceId, ModuleID, rangeBegin, rangeSize, rangeType, ibcType, virtualSectionType);
}
}
+#endif
+
return Result;
}
_StubDispatchFixupStub@0 endp
+endif ; FEATURE_PREJIT
+
;==========================================================================
_ExternalMethodFixupStub@0 proc public
_DelayLoad_MethodCall@0 endp
endif
+ifdef FEATURE_PREJIT
+
;=======================================================================================
; The call in softbound vtable slots initially points to this function.
; The pupose of this function is to transfer the control to right target and
if ( ((dwKeyFlags & InstMethodHashEntry::UnboxingStub) == 0) != (unboxingStub == 0) )
continue;
+#ifdef FEATURE_PREJIT
// Note pMD->GetMethodTable() might not be restored at this point.
RelativeFixupPointer<PTR_MethodTable> * ppMT = pMD->GetMethodTablePtr();
TADDR pMT = ppMT->GetValueMaybeTagged((TADDR)ppMT);
if (!ZapSig::CompareTaggedPointerToTypeHandle(GetModule(), pMT, declaringType))
+#else
+ if (TypeHandle(pMD->GetMethodTable()) != declaringType)
+#endif
{
continue; // Next iteration of the for loop
}
for (DWORD i = 0; i < inst.GetNumArgs(); i++)
{
+#ifdef FEATURE_PREJIT
// Fetch the type handle as TADDR. It may be may be encoded fixup - TypeHandle debug-only validation
// asserts on encoded fixups.
TADDR candidateArg = ((FixupPointer<TADDR> *)candidateInst.GetRawArgs())[i].GetValue();
if (!ZapSig::CompareTaggedPointerToTypeHandle(GetModule(), candidateArg, inst[i]))
+#else
+ if (candidateInst[i] != inst[i])
+#endif
{
match = false;
break;
return SpecialIsGenericTypeVisibleFromCom(hndType);
}
+#ifdef FEATURE_PREJIT
//---------------------------------------------------------------------------
// Determines if a method is likely to be used for forward COM/WinRT interop.
BOOL MethodNeedsForwardComStub(MethodDesc *pMD, DataImage *pImage)
return FALSE;
}
-#ifdef FEATURE_PREJIT
//---------------------------------------------------------------------------
// Determines if a method is visible from COM in a way that requires a marshaling
// stub, i.e. it allows early binding.
ClrFlushInstructionCache(table, tableSize);
#endif // CROSSGEN_COMPILE
}
+#endif // FEATURE_PREJIT
#ifdef FEATURE_READYTORUN
CorInfoHelpFunc MapReadyToRunHelper(ReadyToRunHelper helperNum)
return TRUE;
}
-#endif // FEATURE_PREJIT
void* CEEInfo::getTailCallCopyArgsThunk(CORINFO_SIG_INFO *pSig,
CorInfoHelperTailCallSpecialHandling flags)
);
-#ifdef FEATURE_PREJIT
BOOL LoadDynamicInfoEntry(Module *currentModule,
RVA fixupRva,
SIZE_T *entry);
-#endif // FEATURE_PREJIT
//
// The legacy x86 monitor helpers do not need a state argument
}
CONTRACTL_END;
+#ifdef FEATURE_PREJIT
g_IBCLogger.LogMethodTableAccess(this);
MethodTable * pMTForModule = IsArray() ? this : GetCanonicalMethodTable();
return pMTForModule->GetLoaderModule();
return Module::RestoreModulePointerIfLoaded(pMTForModule->GetModuleOverridePtr(), pMTForModule->GetLoaderModule());
+#else
+ return GetModule();
+#endif
}
#ifndef DACCESS_COMPILE
GCPROTECT_BEGININTERIOR(pStaticBase);
+#ifdef FEATURE_PREJIT
// In ngened case, we have cached array with boxed statics MTs. In JITed case, we have just the FieldDescs
ClassCtorInfoEntry *pClassCtorInfoEntry = GetClassCtorInfoIfExists();
if (pClassCtorInfoEntry != NULL)
DWORD numBoxedStatics = pClassCtorInfoEntry->numBoxedStatics;
for (DWORD i = 0; i < numBoxedStatics; i++)
{
-#ifdef FEATURE_PREJIT
Module::RestoreMethodTablePointer(&(ppMTs[i]), GetLoaderModule());
-#endif
+
MethodTable *pFieldMT = ppMTs[i].GetValue();
_ASSERTE(pFieldMT);
GCPROTECT_END();
}
else
+#endif
{
// We should never take this codepath in zapped images.
_ASSERTE(!IsZapped());
{
LIMITED_METHOD_CONTRACT;
+#ifdef FEATURE_PREJIT
if (!IsZapped())
return NULL;
}
}
}
+#endif // FEATURE_PREJIT
return NULL;
}
// Will always return a valid HMODULE for CLR_INFO, but will return NULL for NGEN_COMPILER_INFO
// if the DLL has not yet been loaded (it does not try to cause a load).
-// Gets set by IJitManager::LoadJit (yes, this breaks the abstraction boundary).
-HMODULE s_ngenCompilerDll = NULL;
-
extern HMODULE CorCompileGetRuntimeDll(CorCompileRuntimeDlls id)
{
CONTRACTL
if (system)
m_flags |= PEFILE_SYSTEM;
+#ifdef FEATURE_PREJIT
// We check the precondition above that either pBindResultInfo is null or both pPEImageIL and pPEImageNI are,
// so we'll only get a max of one native image passed in.
if (pPEImageNI != NULL)
SetNativeImage(pPEImageNI);
}
-#ifdef FEATURE_PREJIT
if (pBindResultInfo && pBindResultInfo->HasNativeImage())
SetNativeImage(pBindResultInfo->GetNativeImage());
#endif
pLayoutToCheck = pLayoutHolder;
}
+#ifdef FEATURE_PREJIT
if (PEFile::ShouldTreatNIAsMSIL())
{
// This PEImage may intentionally be an NI image, being used as if it were an
CHECK(pLayoutToCheck->CheckCORFormat());
}
else
+#endif
{
CHECK(pLayoutToCheck->CheckILFormat());
}
return m_pMDImport;
}
-#ifdef FEATURE_PREJIT
IMDInternalImport* PEImage::GetNativeMDImport(BOOL loadAllowed)
{
CONTRACTL
}
_ASSERTE(m_pNativeMDImport);
}
-#endif
void PEImage::OpenMDImport()
{
ThrowFormat(COR_E_ASSEMBLYEXPECTED);
CHECK checkGoodFormat;
+#ifdef FEATURE_PREJIT
if (fIL)
{
checkGoodFormat = CheckILFormat();
{
checkGoodFormat = CheckNativeFormat();
}
+#else
+ checkGoodFormat = CheckILFormat();
+#endif
if (!checkGoodFormat)
ThrowFormat(COR_E_BADIMAGEFORMAT);
PEImage::PEImage():
m_refCount(1),
m_bIsTrustedNativeImage(FALSE),
- m_bIsNativeImageInstall(FALSE),
m_bPassiveDomainOnly(FALSE),
m_bInHashMap(FALSE),
#ifdef METADATATRACKER_DATA
StackSString path;
GetPathFromDll(hMod, path);
- PEImageHolder pImage(PEImage::OpenImage(path,(MDInternalImportFlags)(MDInternalImport_CheckLongPath|MDInternalImport_CheckShortPath)));
+ PEImageHolder pImage(PEImage::OpenImage(path,(MDInternalImportFlags)(0)));
if (pImage->HasLoadedLayout())
RETURN dac_cast<PTR_PEImage>(pImage.Extract());
static BOOL PathEquals(const SString &p1, const SString &p2);
BOOL IsTrustedNativeImage(){LIMITED_METHOD_CONTRACT; return m_bIsTrustedNativeImage;};
void SetIsTrustedNativeImage(){LIMITED_METHOD_CONTRACT; m_bIsTrustedNativeImage=TRUE;};
- BOOL IsNativeImageInstall(){LIMITED_METHOD_CONTRACT; return m_bIsNativeImageInstall;}
- void SetIsNativeImageInstall(){LIMITED_METHOD_CONTRACT; m_bIsNativeImageInstall=TRUE;};
void SetModuleFileNameHintForDAC();
#ifdef DACCESS_COMPILE
BOOL IsNativeILILOnly();
BOOL IsNativeILDll();
void GetNativeILPEKindAndMachine(DWORD* pdwKind, DWORD* pdwMachine);
- PTR_CVOID GetNativeManifestMetadata(COUNT_T *pSize = NULL);
#endif
+ PTR_CVOID GetNativeManifestMetadata(COUNT_T *pSize = NULL);
BOOL HasDirectoryEntry(int entry);
mdToken GetEntryPointToken();
DWORD GetCorHeaderFlags();
SString m_sModuleFileNameHintUsedByDac; // This is only used by DAC
private:
BOOL m_bIsTrustedNativeImage;
- BOOL m_bIsNativeImageInstall;
BOOL m_bPassiveDomainOnly;
#ifdef FEATURE_LAZY_COW_PAGES
BOOL m_bAllocatedLazyCOWPages;
#endif
}
-#ifdef FEATURE_PREJIT
inline PTR_CVOID PEImage::GetNativeManifestMetadata(COUNT_T *pSize)
{
WRAPPER_NO_CONTRACT;
return pLayout->GetNativeManifestMetadata(pSize);
}
}
-#endif
inline PTR_CVOID PEImage::GetMetadata(COUNT_T *pSize)
{
#ifdef FEATURE_PREJIT
if (flags & MDInternalImport_TrustedNativeImage)
pImage->SetIsTrustedNativeImage();
- if (flags & MDInternalImport_NativeImageInstall)
- pImage->SetIsNativeImageInstall();
#endif
pImage->Init(pPath);
}
-#if !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_)
+#if !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_) && defined(FEATURE_PREJIT)
//==========================================================================================
// In NGen image, virtual slots inherited from cross-module dependencies point to jump thunks.
#endif
return pCode;
}
-#endif // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_)
+#endif // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_) && defined(FEATURE_PREJIT)
#ifdef FEATURE_READYTORUN
typedef DPTR(struct READYTORUN_SECTION) PTR_READYTORUN_SECTION;
-#ifndef FEATURE_PREJIT
-typedef DPTR(struct READYTORUN_IMPORT_SECTION) PTR_CORCOMPILE_IMPORT_SECTION;
-#endif
-
class PrepareCodeConfig;
typedef DPTR(class ReadyToRunInfo) PTR_ReadyToRunInfo;
}
return TRUE;
}
-#endif
case STUB_CODE_BLOCK_EXTERNAL_METHOD_THUNK:
{
}
__fallthrough;
+#endif
case STUB_CODE_BLOCK_METHOD_CALL_THUNK:
#ifdef DACCESS_COMPILE
EMEM_OUT(("MEM: %p JumpStubStubManager\n", dac_cast<TADDR>(this)));
}
-#ifdef FEATURE_PREJIT
void
RangeSectionStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
DAC_ENUM_VTHIS();
EMEM_OUT(("MEM: %p RangeSectionStubManager\n", dac_cast<TADDR>(this)));
}
-#endif
void
ILStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
// Now check the instantiations. Some type arguments might be encoded.
for (DWORD i = 0; i < inst.GetNumArgs(); i++)
{
+#ifdef FEATURE_PREJIT
// Fetch the type handle as TADDR. It may be may be encoded fixup - TypeHandle debug-only validation
// asserts on encoded fixups.
DACCOP_IGNORE(CastOfMarshalledType, "Dual mode DAC problem, but since the size is the same, the cast is safe");
TADDR candidateArg = ((FixupPointer<TADDR> *)candidateInst.GetRawArgs())[i].GetValue();
if (!ZapSig::CompareTaggedPointerToTypeHandle(GetModule(), candidateArg, inst[i]))
+#else
+ if (candidateInst[i] != inst[i])
+#endif
{
return FALSE;
}
TypeHandle *retAndArgTypes2 = pTD->GetRetAndArgTypesPointer();
for (DWORD i = 0; i <= numArgs; i++)
{
+#ifdef FEATURE_PREJIT
TADDR candidateArg = retAndArgTypes2[i].AsTAddr();
if (!ZapSig::CompareTaggedPointerToTypeHandle(GetModule(), candidateArg, retAndArgTypes[i]))
+#else
+ if (retAndArgTypes2[i] != retAndArgTypes[i])
+#endif
{
return FALSE;
}
#include "common.h"
-#ifdef FEATURE_PREJIT
#include "zapsig.h"
#include "typedesc.h"
#include "compile.h"
RETURN(TRUE);
}
+#ifdef FEATURE_PREJIT
/*static*/
BOOL ZapSig::CompareFixupToTypeHandle(Module * pModule, TADDR fixup, TypeHandle handle)
{
ZapSig::Context zapSigContext(pDefiningModule, pModule);
return ZapSig::CompareSignatureToTypeHandle(pSig, pDefiningModule, handle, &zapSigContext);
}
+#endif // FEATURE_PREJIT
/*static*/
BOOL ZapSig::CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2)
// Ensure that the compiler won't fetch the value twice
SIZE_T fixup = VolatileLoadWithoutBarrier((SIZE_T *)pTypeHnd);
+#ifdef FEATURE_PREJIT
if (CORCOMPILE_IS_POINTER_TAGGED(fixup))
{
Module *pContainingModule = ExecutionManager::FindZapModule(dac_cast<TADDR>(pTypeHnd));
}
}
else
+#endif // FEATURE_PREJIT
return TypeHandle::FromTAddr(fixup) == typeHnd2;
}
}
#endif // DACCESS_COMPILE
-
-#endif // FEATURE_PREJIT
pfnTokenDefinition(_pfnTokenDefinition)
{}
-#ifdef FEATURE_PREJIT
+ // Static methods
+
+ // Compare a type handle with a signature whose tokens are resolved with respect to pModule
+ // pZapSigContext is used to resolve ELEMENT_TYPE_MODULE_ZAPSIG encodings
+ static BOOL CompareSignatureToTypeHandle(PCCOR_SIGNATURE pSig,
+ Module* pModule,
+ TypeHandle handle,
+ const ZapSig::Context * pZapSigContext);
// Instance methods
BOOL GetSignatureForTypeHandle(TypeHandle typeHandle,
SigBuilder * pSigBuilder);
- // Static methods
-
- // Compare a type handle with a signature whose tokens are resolved with respect to pModule
- // pZapSigContext is used to resolve ELEMENT_TYPE_MODULE_ZAPSIG encodings
- static BOOL CompareSignatureToTypeHandle(PCCOR_SIGNATURE pSig,
- Module* pModule,
- TypeHandle handle,
- const ZapSig::Context * pZapSigContext);
-
+#ifdef FEATURE_PREJIT
// Compare a type handle with a tagged pointer. Ensure that the common path is inlined into the caller.
static FORCEINLINE BOOL CompareTaggedPointerToTypeHandle(Module * pModule, TADDR addr, TypeHandle handle)
{
}
static BOOL CompareFixupToTypeHandle(Module * pModule, TADDR fixup, TypeHandle handle);
+#endif
static BOOL CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2);
//
static CorElementType TryEncodeUsingShortcut(/* in */ MethodTable * pMT);
-#endif // FEATURE_PREJIT
private: