Move R2R-specific code to be outside FEATURE_PREJIT (#24075)
authorJan Kotas <jkotas@microsoft.com>
Fri, 19 Apr 2019 02:57:17 +0000 (19:57 -0700)
committerGitHub <noreply@github.com>
Fri, 19 Apr 2019 02:57:17 +0000 (19:57 -0700)
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.

41 files changed:
src/debug/daccess/nidump.cpp
src/debug/daccess/nidump.h
src/inc/corcompile.h
src/inc/corpriv.h
src/inc/daccess.h
src/inc/jithelpers.h
src/inc/pedecoder.h
src/md/inc/metamodelrw.h
src/utilcode/pedecoder.cpp
src/vm/amd64/VirtualCallStubAMD64.asm
src/vm/appdomain.cpp
src/vm/assembly.cpp
src/vm/assembly.hpp
src/vm/assemblynative.cpp
src/vm/ceeload.cpp
src/vm/ceeload.h
src/vm/ceeload.inl
src/vm/codeman.cpp
src/vm/codeman.h
src/vm/coreassemblyspec.cpp
src/vm/coreclr/corebindresult.h
src/vm/dllimport.cpp
src/vm/domainfile.cpp
src/vm/dwbucketmanager.hpp
src/vm/eventtrace.cpp
src/vm/i386/asmhelpers.asm
src/vm/instmethhash.cpp
src/vm/interoputil.cpp
src/vm/jitinterface.cpp
src/vm/jitinterface.h
src/vm/methodtable.cpp
src/vm/pefile.cpp
src/vm/peimage.cpp
src/vm/peimage.h
src/vm/peimage.inl
src/vm/prestub.cpp
src/vm/readytoruninfo.h
src/vm/stubmgr.cpp
src/vm/typehash.cpp
src/vm/zapsig.cpp
src/vm/zapsig.h

index d7d9041..761dec1 100644 (file)
@@ -9106,6 +9106,17 @@ mdTypeRef NativeImageDumper::FindTypeRefForMT( PTR_MethodTable mt )
 }
 #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
@@ -9151,16 +9162,3 @@ mdTypeRef NativeImageDumper::FindTypeRefForMT( PTR_MethodTable mt )
 #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
index a19f61a..f09bb86 100644 (file)
@@ -13,9 +13,7 @@
 //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)
@@ -186,9 +184,6 @@ public:
 
     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 );
     
index 38ae5c1..5f39c65 100644 (file)
 #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
index 81143e6..07be47c 100644 (file)
@@ -96,10 +96,7 @@ enum MDInternalImportFlags
     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
 
index 71a7d01..e4deab9 100644 (file)
@@ -620,8 +620,10 @@ typedef struct _DacGlobals
 
     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;
index 2b362a7..d7a8228 100644 (file)
 
     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)
 
index 91990d2..37051d9 100644 (file)
 #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;
@@ -305,6 +298,8 @@ class PEDecoder
     // 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;
 
@@ -322,7 +317,6 @@ class PEDecoder
     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;
index c2d24db..d2debc7 100644 (file)
@@ -790,7 +790,7 @@ public:
     // 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
 
index 13d1d27..24cde95 100644 (file)
@@ -2559,7 +2559,7 @@ CORCOMPILE_METHOD_PROFILE_LIST *PEDecoder::GetNativeProfileDataList(COUNT_T * pS
     RETURN PTR_CORCOMPILE_METHOD_PROFILE_LIST(GetDirectoryData(pDir));
 }
 
-
+#endif // FEATURE_PREJIT
 
 PTR_CVOID PEDecoder::GetNativeManifestMetadata(COUNT_T *pSize) const
 {
@@ -2574,7 +2574,13 @@ 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();
 
@@ -2590,10 +2596,6 @@ PTR_CVOID PEDecoder::GetNativeManifestMetadata(COUNT_T *pSize) const
                 pDir = &pSection->Section;
         }
     }
-    else
-    {
-        pDir = GetMetaDataHelper(METADATA_SECTION_MANIFEST);
-    }
 
     if (pSize != NULL)
         *pSize = VAL32(pDir->Size);
@@ -2601,6 +2603,8 @@ PTR_CVOID PEDecoder::GetNativeManifestMetadata(COUNT_T *pSize) const
     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)
index fc032dd..c6ae0aa 100644 (file)
@@ -10,8 +10,10 @@ CHAIN_SUCCESS_COUNTER  equ ?g_dispatch_cache_chain_success_counter@@3_KA
         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
@@ -88,6 +90,7 @@ Fail:
 LEAF_END ResolveWorkerChainLookupAsmStub, _TEXT
 
 
+ifdef FEATURE_PREJIT
 NESTED_ENTRY StubDispatchFixupStub, _TEXT, ProcessCLRException
 
         PROLOG_WITH_TRANSITION_BLOCK
@@ -105,5 +108,6 @@ PATCH_LABEL StubDispatchFixupPatchLabel
         TAILJMP_RAX
 
 NESTED_END StubDispatchFixupStub, _TEXT
+endif
 
         end
index 9ac4478..c106d9d 100644 (file)
@@ -5236,6 +5236,7 @@ AppDomain::BindHostedPrivAssembly(
 
     // Get the NI PEFile if available.
     PEImageHolder pPEImageNI;
+#ifdef FEATURE_PREJIT
     if (dwAvailableImages & ASSEMBLY_IMAGE_TYPE_NATIVE)
     {
         DWORD dwImageType;
@@ -5246,6 +5247,7 @@ AppDomain::BindHostedPrivAssembly(
 
         pPEImageNI = PEImage::OpenImage(pIResourceNI, MDInternalImport_TrustedNativeImage);
     }
+#endif // FEATURE_PREJIT
     _ASSERTE(pPEImageIL != nullptr);
     
     // Create a PEAssembly using the IL and NI images.
index 1326dfb..2d89cc4 100644 (file)
@@ -126,7 +126,7 @@ Assembly::Assembly(BaseDomain *pDomain, PEAssembly* pFile, DebuggerAssemblyContr
 #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
 {
@@ -1866,7 +1866,7 @@ BOOL Assembly::GetResource(LPCSTR szName, DWORD *cbResource,
     return result;
 }
 
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
 BOOL Assembly::IsInstrumented()
 {
     STATIC_CONTRACT_THROWS;
index d8d974b..43d9172 100644 (file)
@@ -449,7 +449,7 @@ public:
 
     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
@@ -627,7 +627,7 @@ private:
 
     BOOL                  m_fIsSIMDVectorAssembly;
 
-#ifdef FEATURE_PREJIT
+#if defined(FEATURE_PREJIT) || defined(FEATURE_READYTORUN)
     enum IsInstrumentedStatus {
         IS_INSTRUMENTED_UNSET = 0,
         IS_INSTRUMENTED_FALSE = 1,
index 66214a1..aa83093 100644 (file)
@@ -261,6 +261,7 @@ void QCALLTYPE AssemblyNative::LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext
         }
     }
     
+#ifdef FEATURE_PREJIT
     // Form the PEImage for the NI assembly, if specified
     if (pwzNIPath != NULL)
     {
@@ -281,6 +282,7 @@ void QCALLTYPE AssemblyNative::LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext
                 ThrowHR(COR_E_BADIMAGEFORMAT);
         }
     }
+#endif // FEATURE_PREJIT
     
     Assembly *pLoadedAssembly = AssemblyNative::LoadFromPEImage(pBinderContext, pILImage, pNIImage);
     
index 8c86d00..d98f180 100644 (file)
@@ -387,6 +387,7 @@ void Module::InitializeForProfiling()
 
     m_nativeImageProfiling = FALSE;
 
+#ifdef FEATURE_PREJIT
     if (HasNativeImage())
     {
         PEImageLayout * pNativeImage = GetNativeImage();
@@ -400,6 +401,7 @@ void Module::InitializeForProfiling()
         m_methodProfileList = pNativeImage->GetNativeProfileDataList(&cbProfileList);
     }
     else // ReadyToRun image
+#endif
     {
 #ifdef FEATURE_READYTORUN
         // We already setup the m_methodProfileList in the ReadyToRunInfo constructor
@@ -458,6 +460,13 @@ void Module::InitializeNativeImage(AllocMemTracker* pamTracker)
     }
 #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)
 {
@@ -478,27 +487,19 @@ void Module::SetNativeMetadataAssemblyRefInCache(DWORD rid, PTR_Assembly pAssemb
         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.
@@ -588,7 +589,7 @@ void Module::Initialize(AllocMemTracker *pamTracker, LPCWSTR szName)
             }
         }
 
-#ifdef FEATURE_COMINTEROP
+#if defined(FEATURE_COMINTEROP) && defined(FEATURE_PREJIT)
         if (IsCompilationProcess() && m_pGuidToTypeHash == NULL)
         {
             // only allocate this during NGEN-ing
@@ -4146,12 +4147,12 @@ PTR_CORCOMPILE_IMPORT_SECTION Module::GetImportSections(COUNT_T *pCount)
     }
     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)
@@ -4163,12 +4164,12 @@ 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)
@@ -4180,12 +4181,12 @@ 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)
@@ -9809,6 +9810,7 @@ BOOL Module::IsPersistedObject(void *address)
     return (address >= pLayout->GetBase()
             && address < (BYTE*)pLayout->GetBase() + pLayout->GetVirtualSize());
 }
+#endif // FEATURE_PREJIT
 
 Module *Module::GetModuleFromIndex(DWORD ix)
 {
@@ -9841,12 +9843,9 @@ Module *Module::GetModuleFromIndex(DWORD ix)
         }
     }
 }
-#endif // FEATURE_PREJIT
 
 #endif // !DACCESS_COMPILE
 
-#ifdef FEATURE_PREJIT
-
 Module *Module::GetModuleFromIndexIfLoaded(DWORD ix)
 {
     CONTRACT(Module*)
@@ -9869,25 +9868,9 @@ Module *Module::GetModuleFromIndexIfLoaded(DWORD ix)
 }
 
 #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;
@@ -9896,21 +9879,41 @@ IMDInternalImport *Module::GetNativeAssemblyImport(BOOL loadAllowed)
         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,
@@ -10548,63 +10551,6 @@ ZapHeader.ImportTable        |                    |         |     non-NULL
 
 //-----------------------------------------------------------------------------
 
-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;
@@ -10821,9 +10767,64 @@ PTR_BYTE Module::GetNativeDebugInfo(MethodDesc * pMD)
 }
 #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 
 //
@@ -13855,7 +13856,9 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags,
         {
             m_pBinder->EnumMemoryRegions(flags);
         }
+#ifdef FEATURE_PREJIT
         m_ModuleCtorInfo.EnumMemoryRegions(flags);
+#endif
 
         // Save the LookupMap structures.
         m_MethodDefToDescMap.ListEnumMemoryRegions(flags);
index 01d5ba8..99c1c78 100644 (file)
 #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
@@ -75,15 +76,16 @@ class AppDomain;
 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
@@ -107,9 +109,6 @@ class PersistentInlineTrackingMapNGen;
 
 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)
@@ -1342,7 +1341,7 @@ private:
         // 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
 
@@ -1615,11 +1614,7 @@ private:
     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
 
@@ -1632,6 +1627,9 @@ private:
     DWORD                   m_dwExportedTypeCount;
 #endif // PROFILING_SUPPORTED_DATA
 
+#ifdef FEATURE_PREJIT
+    PTR_NGenLayoutInfo      m_pNGenLayoutInfo;
+
 #if defined(FEATURE_COMINTEROP)
         public:
 
@@ -1648,12 +1646,11 @@ private:
 
 #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);
@@ -1681,6 +1678,7 @@ private:
 
     } *m_tokenProfileData;
 
+#ifdef FEATURE_PREJIT
     // Stats for prejit log
     NgenStats                *m_pNgenStats;
 #endif // FEATURE_PREJIT
@@ -2559,13 +2557,15 @@ public:
         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:
 
@@ -2734,8 +2734,9 @@ public:
 
     PCCOR_SIGNATURE GetEncodedSig(RVA fixupRva, Module **ppDefiningModule);
     PCCOR_SIGNATURE GetEncodedSigIfLoaded(RVA fixupRva, Module **ppDefiningModule);
+#endif
 
-    BYTE *GetNativeFixupBlobData(RVA fixup);
+    BYTEGetNativeFixupBlobData(RVA fixup);
 
     IMDInternalImport *GetNativeAssemblyImport(BOOL loadAllowed = TRUE);
     IMDInternalImport *GetNativeAssemblyImportIfLoaded();
@@ -2753,10 +2754,10 @@ public:
                            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);
 
@@ -2863,6 +2864,7 @@ public:
 
         return m_pNGenLayoutInfo->m_VirtualMethodThunks.IsInRange(code);
     }
+#endif // FEATURE_PREJIT
 
     ICorJitInfo::ProfileBuffer * AllocateProfileBuffer(mdToken _token, DWORD _size, DWORD _ILSize);
     HANDLE OpenMethodProfileDataLogFile(GUID mvid);
@@ -2882,6 +2884,7 @@ public:
     void LogTokenAccess(mdToken token, SectionFormat format, ULONG flagNum);
     void LogTokenAccess(mdToken token, ULONG flagNum);
 
+#ifdef FEATURE_PREJIT
     BOOL AreTypeSpecsTriaged()
     {
         return m_dwTransientFlags & TYPESPECS_TRIAGED;
@@ -3228,7 +3231,6 @@ private:
     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
@@ -3238,10 +3240,9 @@ private:
     // 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);
@@ -3254,7 +3255,7 @@ public:
     }
 
     void SetNativeMetadataAssemblyRefInCache(DWORD rid, PTR_Assembly pAssembly);
-#endif // !defined(DACCESS_COMPILE) && defined(FEATURE_PREJIT)
+#endif // !defined(DACCESS_COMPILE)
 };
 
 //
index 4997f57..e0ce07f 100644 (file)
@@ -497,8 +497,6 @@ FORCEINLINE PTR_DomainLocalModule Module::GetDomainLocalModule(AppDomain *pDomai
     return pDomain->GetDomainLocalBlock()->GetModuleSlot(GetModuleIndex());
 }
 
-#ifdef FEATURE_PREJIT
-
 #include "nibblestream.h"
 
 FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList)
@@ -629,8 +627,6 @@ BOOL Module::FixupDelayListAux(TADDR pFixupList,
     return TRUE;
 }
 
-#endif //FEATURE_PREJIT
-
 inline PTR_LoaderAllocator Module::GetLoaderAllocator()
 {
     LIMITED_METHOD_DAC_CONTRACT;
index 4188658..00ed67a 100644 (file)
@@ -1721,9 +1721,6 @@ EXTERN_C void __stdcall jitStartup(ICorJitHost* host);
 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;
@@ -1767,9 +1764,6 @@ BOOL EEJitManager::LoadJIT()
 
     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
@@ -5236,6 +5230,116 @@ DONE:
 }
 #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
 //***************************************************************************************
 //***************************************************************************************
@@ -5702,38 +5806,6 @@ TADDR NativeImageJitManager::GetFuncletStartAddress(EECodeInfo * pCodeInfo)
     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
@@ -5988,81 +6060,6 @@ void NativeImageJitManager::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
 
 #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.
@@ -6101,6 +6098,10 @@ void NativeImageJitManager::EnumMemoryRegionsForMethodUnwindInfo(CLRDataEnumMemo
 #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,
@@ -6216,6 +6217,7 @@ int NativeUnwindInfoLookupTable::LookupUnwindInfoForMethod(DWORD RelativePc,
     return -1;
 }
 
+#ifdef FEATURE_PREJIT
 BOOL NativeUnwindInfoLookupTable::HasExceptionInfo(NGenLayoutInfo * pNgenLayout, PTR_RUNTIME_FUNCTION pMainRuntimeFunction)
 {
     LIMITED_METHOD_DAC_CONTRACT;
@@ -6250,9 +6252,10 @@ DWORD NativeUnwindInfoLookupTable::GetMethodDescRVA(NGenLayoutInfo * pNgenLayout
 
     return rva;
 }
-
 #endif // FEATURE_PREJIT
 
+#endif // FEATURE_PREJIT || FEATURE_READYTORUN
+
 #ifndef DACCESS_COMPILE
 
 //-----------------------------------------------------------------------------
index e08721c..04e7dd1 100644 (file)
@@ -1615,6 +1615,23 @@ public:
 #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:
@@ -1632,27 +1649,16 @@ 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
 
index 44da972..387c25b 100644 (file)
@@ -301,11 +301,13 @@ STDAPI BinderAcquireImport(PEImage                  *pPEImage,
         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]);
         }
index 12e6d45..cd63d50 100644 (file)
@@ -48,6 +48,9 @@ public:
     PEImage* GetNativeImage();
     void SetNativeImage(PEImage * pNativeImage);
     PEImage* GetILImage();
+#else
+    BOOL HasNativeImage() { return FALSE; }
+    PEImage* GetNativeImage() { return NULL; }
 #endif
     void SetHRBindResult(HRESULT hrBindResult);
     HRESULT GetHRBindResult();
index 3883783..c9a11f3 100644 (file)
@@ -5508,12 +5508,16 @@ MethodDesc* GetStubMethodDescFromInteropMethodDesc(MethodDesc* pMD, DWORD dwStub
 #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
index 5c89767..0864ff1 100644 (file)
@@ -851,8 +851,7 @@ void DomainFile::CheckZapRequired()
     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)
index 0095eb6..9b0d7b1 100644 (file)
@@ -982,6 +982,7 @@ bool BaseBucketParamsManager::GetFileVersionInfoForModule(Module* pModule, USHOR
     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())
         {
@@ -996,6 +997,7 @@ bool BaseBucketParamsManager::GetFileVersionInfoForModule(Module* pModule, USHOR
                 }
             }
         }
+#endif
 
         // if we failed to get the version info from the native image then fall back to the IL image.
         if (!succeeded)
index 7ad93db..7c30cde 100644 (file)
@@ -5790,7 +5790,7 @@ ETW_INLINE
 {
     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
@@ -5842,6 +5842,8 @@ ETW_INLINE
             Result &= FireEtwModuleRangeLoadPrivate(ClrInstanceId, ModuleID, rangeBegin, rangeSize, rangeType, ibcType, virtualSectionType);
         }
     }
+#endif
+
     return Result;
 }
 
index 18b5c6e..85a19b8 100644 (file)
@@ -1528,6 +1528,8 @@ public _StubDispatchFixupPatchLabel@0
 
 _StubDispatchFixupStub@0 endp
 
+endif ; FEATURE_PREJIT
+
 ;==========================================================================
 _ExternalMethodFixupStub@0 proc public
 
@@ -1605,6 +1607,8 @@ _DelayLoad_MethodCall@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
index 560e955..05378b4 100644 (file)
@@ -183,12 +183,16 @@ MethodDesc* InstMethodHashTable::FindMethodDesc(TypeHandle declaringType,
         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
         }
@@ -204,11 +208,15 @@ MethodDesc* InstMethodHashTable::FindMethodDesc(TypeHandle declaringType,
 
             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;
index 7cca714..11859f5 100644 (file)
@@ -3700,6 +3700,7 @@ BOOL IsTypeVisibleFromCom(TypeHandle hndType)
     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)
@@ -3762,7 +3763,6 @@ 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.
index e00ebd0..11d5039 100644 (file)
@@ -13177,6 +13177,7 @@ void Module::LoadHelperTable()
     ClrFlushInstructionCache(table, tableSize);
 #endif // CROSSGEN_COMPILE
 }
+#endif // FEATURE_PREJIT
 
 #ifdef FEATURE_READYTORUN
 CorInfoHelpFunc MapReadyToRunHelper(ReadyToRunHelper helperNum)
@@ -13809,7 +13810,6 @@ BOOL LoadDynamicInfoEntry(Module *currentModule,
 
     return TRUE;
 }
-#endif // FEATURE_PREJIT
 
 void* CEEInfo::getTailCallCopyArgsThunk(CORINFO_SIG_INFO       *pSig,
                                         CorInfoHelperTailCallSpecialHandling flags)
index af42bd2..4b2fd00 100644 (file)
@@ -83,11 +83,9 @@ void getMethodInfoILMethodHeaderHelper(
     );
 
 
-#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
index fed3f98..3223715 100644 (file)
@@ -449,6 +449,7 @@ PTR_Module MethodTable::GetModuleIfLoaded()
     }
     CONTRACTL_END;
 
+#ifdef FEATURE_PREJIT
     g_IBCLogger.LogMethodTableAccess(this);
 
     MethodTable * pMTForModule = IsArray() ? this : GetCanonicalMethodTable();
@@ -456,6 +457,9 @@ PTR_Module MethodTable::GetModuleIfLoaded()
         return pMTForModule->GetLoaderModule();
 
     return Module::RestoreModulePointerIfLoaded(pMTForModule->GetModuleOverridePtr(), pMTForModule->GetLoaderModule());
+#else
+    return GetModule();
+#endif
 }
 
 #ifndef DACCESS_COMPILE
@@ -3224,6 +3228,7 @@ void MethodTable::AllocateRegularStaticBoxes()
 
     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)
@@ -3237,9 +3242,8 @@ void MethodTable::AllocateRegularStaticBoxes()
         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);
@@ -3252,6 +3256,7 @@ void MethodTable::AllocateRegularStaticBoxes()
         GCPROTECT_END();
     }
     else
+#endif
     {
         // We should never take this codepath in zapped images.
         _ASSERTE(!IsZapped());
@@ -8250,6 +8255,7 @@ ClassCtorInfoEntry* MethodTable::GetClassCtorInfoIfExists()
 {
     LIMITED_METHOD_CONTRACT;
 
+#ifdef FEATURE_PREJIT
     if (!IsZapped())
         return NULL;
 
@@ -8292,6 +8298,7 @@ ClassCtorInfoEntry* MethodTable::GetClassCtorInfoIfExists()
             }
         }
     }
+#endif // FEATURE_PREJIT
 
     return NULL;
 }
index 9f3c358..f0a44d8 100644 (file)
@@ -1111,9 +1111,6 @@ LPCWSTR CorCompileGetRuntimeDllName(CorCompileRuntimeDlls id)
 // 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
@@ -1905,6 +1902,7 @@ PEAssembly::PEAssembly(
     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)
@@ -1912,7 +1910,6 @@ PEAssembly::PEAssembly(
         SetNativeImage(pPEImageNI);
     }
 
-#ifdef FEATURE_PREJIT
     if (pBindResultInfo && pBindResultInfo->HasNativeImage())
         SetNativeImage(pBindResultInfo->GetNativeImage());
 #endif
index ac894b2..a79a33b 100644 (file)
@@ -123,6 +123,7 @@ CHECK PEImage::CheckILFormat()
         pLayoutToCheck = pLayoutHolder;
     }
 
+#ifdef FEATURE_PREJIT
     if (PEFile::ShouldTreatNIAsMSIL())
     {
         // This PEImage may intentionally be an NI image, being used as if it were an
@@ -132,6 +133,7 @@ CHECK PEImage::CheckILFormat()
         CHECK(pLayoutToCheck->CheckCORFormat());
     }
     else
+#endif
     {
         CHECK(pLayoutToCheck->CheckILFormat());
     }
@@ -450,7 +452,6 @@ IMDInternalImport* PEImage::GetMDImport()
     return m_pMDImport;
 }
 
-#ifdef FEATURE_PREJIT
 IMDInternalImport* PEImage::GetNativeMDImport(BOOL loadAllowed)
 {
     CONTRACTL
@@ -508,7 +509,6 @@ void PEImage::OpenNativeMDImport()
     }
     _ASSERTE(m_pNativeMDImport);
 }
-#endif
 
 void PEImage::OpenMDImport()
 {
@@ -673,6 +673,7 @@ void PEImage::VerifyIsILOrNIAssembly(BOOL fIL)
         ThrowFormat(COR_E_ASSEMBLYEXPECTED);
 
     CHECK checkGoodFormat;
+#ifdef FEATURE_PREJIT
     if (fIL)
     {
         checkGoodFormat = CheckILFormat();
@@ -681,6 +682,9 @@ void PEImage::VerifyIsILOrNIAssembly(BOOL fIL)
     {
         checkGoodFormat = CheckNativeFormat();
     }
+#else
+    checkGoodFormat = CheckILFormat();
+#endif
     if (!checkGoodFormat)
         ThrowFormat(COR_E_BADIMAGEFORMAT);
     
@@ -948,7 +952,6 @@ void PEImage::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
 PEImage::PEImage():
     m_refCount(1),
     m_bIsTrustedNativeImage(FALSE),
-    m_bIsNativeImageInstall(FALSE),
     m_bPassiveDomainOnly(FALSE),
     m_bInHashMap(FALSE),
 #ifdef METADATATRACKER_DATA
@@ -1211,7 +1214,7 @@ PTR_PEImage PEImage::LoadImage(HMODULE hMod)
 
     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());
 
index 5cfd160..4545216 100644 (file)
@@ -189,8 +189,6 @@ public:
     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
@@ -208,8 +206,8 @@ public:
     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();
@@ -293,7 +291,6 @@ private:
     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;
index 156dae6..142012e 100644 (file)
@@ -388,7 +388,6 @@ inline BOOL PEImage::IsIbcOptimized()
 #endif
 }
 
-#ifdef FEATURE_PREJIT 
 inline PTR_CVOID PEImage::GetNativeManifestMetadata(COUNT_T *pSize) 
 {
     WRAPPER_NO_CONTRACT;
@@ -400,7 +399,6 @@ inline PTR_CVOID PEImage::GetNativeManifestMetadata(COUNT_T *pSize)
         return pLayout->GetNativeManifestMetadata(pSize);
     }
 }
-#endif
 
 inline PTR_CVOID PEImage::GetMetadata(COUNT_T *pSize) 
 {
@@ -532,8 +530,6 @@ inline PTR_PEImage PEImage::OpenImage(LPCWSTR pPath, MDInternalImportFlags flags
 #ifdef FEATURE_PREJIT        
         if (flags &  MDInternalImport_TrustedNativeImage)
             pImage->SetIsTrustedNativeImage();
-        if (flags &  MDInternalImport_NativeImageInstall)
-            pImage->SetIsNativeImageInstall();
 #endif        
         pImage->Init(pPath);
 
index c63e399..4adf32e 100644 (file)
@@ -2447,7 +2447,7 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
 }
 
 
-#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.
@@ -2504,7 +2504,7 @@ EXTERN_C PCODE VirtualMethodFixupWorker(Object * pThisPtr,  CORCOMPILE_VIRTUAL_I
 #endif
     return pCode;
 }
-#endif // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_)
+#endif // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_) && defined(FEATURE_PREJIT)
 
 #ifdef FEATURE_READYTORUN
 
index 5633137..1ccd239 100644 (file)
 
 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;
index 17d262c..a18792d 100644 (file)
@@ -1467,7 +1467,6 @@ BOOL RangeSectionStubManager::DoTraceStub(PCODE stubStartAddress, TraceDestinati
             }
             return TRUE;
         }
-#endif
 
     case STUB_CODE_BLOCK_EXTERNAL_METHOD_THUNK:
         {
@@ -1481,6 +1480,7 @@ BOOL RangeSectionStubManager::DoTraceStub(PCODE stubStartAddress, TraceDestinati
         }
 
         __fallthrough;
+#endif
 
     case STUB_CODE_BLOCK_METHOD_CALL_THUNK:
 #ifdef DACCESS_COMPILE
@@ -2528,7 +2528,6 @@ JumpStubStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
     EMEM_OUT(("MEM: %p JumpStubStubManager\n", dac_cast<TADDR>(this)));
 }
 
-#ifdef FEATURE_PREJIT
 void
 RangeSectionStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
 {
@@ -2537,7 +2536,6 @@ RangeSectionStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
     DAC_ENUM_VTHIS();
     EMEM_OUT(("MEM: %p RangeSectionStubManager\n", dac_cast<TADDR>(this)));
 }
-#endif
 
 void
 ILStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
index 552960b..524dd29 100644 (file)
@@ -523,12 +523,16 @@ BOOL EETypeHashTable::CompareInstantiatedType(TypeHandle t, Module *pModule, mdT
     // 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;
         }
@@ -569,8 +573,12 @@ BOOL EETypeHashTable::CompareFnPtrType(TypeHandle t, BYTE callConv, DWORD numArg
     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;
         }
index 4db83ec..73cc604 100644 (file)
@@ -11,7 +11,6 @@
 
 
 #include "common.h"
-#ifdef FEATURE_PREJIT
 #include "zapsig.h"
 #include "typedesc.h"
 #include "compile.h"
@@ -566,6 +565,7 @@ BOOL ZapSig::GetSignatureForTypeHandle(TypeHandle      handle,
     RETURN(TRUE);
 }
 
+#ifdef FEATURE_PREJIT
 /*static*/
 BOOL ZapSig::CompareFixupToTypeHandle(Module * pModule, TADDR fixup, TypeHandle handle)
 {
@@ -588,6 +588,7 @@ BOOL ZapSig::CompareFixupToTypeHandle(Module * pModule, TADDR fixup, TypeHandle
     ZapSig::Context zapSigContext(pDefiningModule, pModule);
     return ZapSig::CompareSignatureToTypeHandle(pSig, pDefiningModule, handle, &zapSigContext);
 }
+#endif // FEATURE_PREJIT
 
 /*static*/
 BOOL ZapSig::CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2)
@@ -607,6 +608,7 @@ BOOL ZapSig::CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle
     // 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));
@@ -624,6 +626,7 @@ BOOL ZapSig::CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle
         }
     }
     else
+#endif // FEATURE_PREJIT
         return TypeHandle::FromTAddr(fixup) == typeHnd2;
 }
 
@@ -1532,5 +1535,3 @@ void ZapSig::EncodeField(
 }
 
 #endif // DACCESS_COMPILE
-
-#endif // FEATURE_PREJIT
index d09290c..3b537cf 100644 (file)
@@ -78,7 +78,14 @@ public:
           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
 
@@ -94,15 +101,7 @@ public:
     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)
     {
@@ -115,6 +114,7 @@ public:
     }
 
     static BOOL CompareFixupToTypeHandle(Module * pModule, TADDR fixup, TypeHandle handle);
+#endif
 
     static BOOL CompareTypeHandleFieldToTypeHandle(TypeHandle *pTypeHnd, TypeHandle typeHnd2);
 
@@ -127,7 +127,6 @@ private:
     //
     static CorElementType TryEncodeUsingShortcut(/* in  */ MethodTable * pMT);
 
-#endif // FEATURE_PREJIT
 
 private: