Stop compiling fragile NGen support into the runtime (dotnet/coreclr#24625)
authorJan Kotas <jkotas@microsoft.com>
Thu, 23 May 2019 06:42:31 +0000 (23:42 -0700)
committerGitHub <noreply@github.com>
Thu, 23 May 2019 06:42:31 +0000 (23:42 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/451fd23fa2179fa22c831bcf84edd547bfba5cd9

38 files changed:
src/coreclr/clrdefinitions.cmake
src/coreclr/crossgen.cmake
src/coreclr/src/inc/dacvars.h
src/coreclr/src/inc/jithelpers.h
src/coreclr/src/utilcode/pedecoder.cpp
src/coreclr/src/vm/amd64/ExternalMethodFixupThunk.asm
src/coreclr/src/vm/amd64/cgenamd64.cpp
src/coreclr/src/vm/amd64/externalmethodfixupthunk.S
src/coreclr/src/vm/appdomain.cpp
src/coreclr/src/vm/appdomain.hpp
src/coreclr/src/vm/arm/asmhelpers.S
src/coreclr/src/vm/arm/asmhelpers.asm
src/coreclr/src/vm/arm/cgencpu.h
src/coreclr/src/vm/arm64/asmhelpers.S
src/coreclr/src/vm/arm64/asmhelpers.asm
src/coreclr/src/vm/ceeload.cpp
src/coreclr/src/vm/ceeload.h
src/coreclr/src/vm/dataimage.h
src/coreclr/src/vm/domainfile.cpp
src/coreclr/src/vm/fieldmarshaler.h
src/coreclr/src/vm/i386/asmhelpers.S
src/coreclr/src/vm/i386/asmhelpers.asm
src/coreclr/src/vm/i386/cgencpu.h
src/coreclr/src/vm/i386/cgenx86.cpp
src/coreclr/src/vm/i386/stublinkerx86.cpp
src/coreclr/src/vm/i386/stublinkerx86.h
src/coreclr/src/vm/ibclogger.cpp
src/coreclr/src/vm/ibclogger.h
src/coreclr/src/vm/method.cpp
src/coreclr/src/vm/methodtable.cpp
src/coreclr/src/vm/peimagelayout.cpp
src/coreclr/src/vm/peimagelayout.h
src/coreclr/src/vm/perfmap.cpp
src/coreclr/src/vm/siginfo.cpp
src/coreclr/src/vm/stubmgr.cpp
src/coreclr/src/vm/threads.cpp
src/coreclr/src/vm/threads.h
src/coreclr/src/vm/virtualcallstub.h

index b4ccfec..56088dd 100644 (file)
@@ -175,7 +175,6 @@ endif(CLR_CMAKE_PLATFORM_UNIX)
 if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD)
     add_definitions(-DFEATURE_PERFMAP)
 endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD)
-add_definitions(-DFEATURE_PREJIT)
 
 if(NOT CLR_CMAKE_PLATFORM_UNIX)
     add_definitions(-DFEATURE_PROFAPI_ATTACH_DETACH)
index 7bc64a2..1bf84c8 100644 (file)
@@ -1,6 +1,7 @@
 # Contains the crossgen build specific definitions. Included by the leaf crossgen cmake files.
 
 add_definitions(
+    -DFEATURE_PREJIT
     -DCROSSGEN_COMPILE
     -DCROSS_COMPILE
     -DFEATURE_NATIVE_IMAGE_GENERATION
index 520b501..78b1c10 100644 (file)
@@ -121,9 +121,11 @@ DEFINE_DACVAR(ULONG, PTR_GcDacVars, dac__g_gcDacGlobals, g_gcDacGlobals)
 
 DEFINE_DACVAR(ULONG, PTR_AppDomain, AppDomain__m_pTheAppDomain, AppDomain::m_pTheAppDomain)
 DEFINE_DACVAR(ULONG, PTR_SystemDomain, SystemDomain__m_pSystemDomain, SystemDomain::m_pSystemDomain)
+#ifdef FEATURE_PREJIT
 DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceDebug, SystemDomain::s_fForceDebug)
 DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceProfiling, SystemDomain::s_fForceProfiling)
 DEFINE_DACVAR(ULONG, BOOL, SystemDomain__s_fForceInstrument, SystemDomain::s_fForceInstrument)
+#endif
 
 #ifdef FEATURE_INTEROP_DEBUGGING
 DEFINE_DACVAR(ULONG, DWORD, dac__g_debuggerWordTLSIndex, g_debuggerWordTLSIndex)
index d7a8228..d7d501f 100644 (file)
     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)
+#ifdef FEATURE_PREJIT
     JITHELPER(CORINFO_HELP_EE_VTABLE_FIXUP,     VirtualMethodFixupStub,     CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#else
+    JITHELPER(CORINFO_HELP_EE_VTABLE_FIXUP,     NULL,                       CORINFO_HELP_SIG_NO_ALIGN_STUB)
+#endif
 
     JITHELPER(CORINFO_HELP_EE_REMOTING_THUNK,   NULL,                       CORINFO_HELP_SIG_UNDEF)
 
index 242768e..a3e3b73 100644 (file)
@@ -34,10 +34,6 @@ CHECK PEDecoder::CheckFormat() const
         {
             CHECK(CheckCorHeader());
 
-#if !defined(FEATURE_PREJIT)
-            CHECK(IsILOnly());
-#endif
-
             if (IsILOnly() && !HasReadyToRunHeader())
                 CHECK(CheckILOnly());
 
index 6c43762..677f2e4 100644 (file)
@@ -7,7 +7,10 @@ include AsmConstants.inc
 
     extern  ExternalMethodFixupWorker:proc
     extern  ProcessCLRException:proc
+
+ifdef FEATURE_PREJIT
     extern  VirtualMethodFixupWorker:proc
+endif
 
 ifdef FEATURE_READYTORUN
     extern DynamicHelperWorker:proc
@@ -87,6 +90,7 @@ DYNAMICHELPER <DynamicHelperFrameFlags_ObjectArg OR DynamicHelperFrameFlags_Obje
 
 endif ; FEATURE_READYTORUN
 
+ifdef FEATURE_PREJIT
 ;============================================================================================
 ;; EXTERN_C VOID __stdcall VirtualMethodFixupStub()
 
@@ -103,5 +107,6 @@ PATCH_LABEL VirtualMethodFixupPatchLabel
         TAILJMP_RAX
 
 NESTED_END VirtualMethodFixupStub, _TEXT
+endif ; FEATURE_PREJIT
 
         end
index e0e6a47..2a93fa4 100644 (file)
@@ -820,6 +820,7 @@ DWORD GetOffsetAtEndOfFunction(ULONGLONG           uImageBase,
     return offsetInFunc;
 }
 
+#ifdef FEATURE_PREJIT
 //==========================================================================================
 // In NGen image, virtual slots inherited from cross-module dependencies point to jump thunks.
 // These jump thunk initially point to VirtualMethodFixupStub which transfers control here.
@@ -913,6 +914,7 @@ EXTERN_C PCODE VirtualMethodFixupWorker(TransitionBlock * pTransitionBlock, CORC
     // Ready to return
     return pCode;
 }
+#endif // FEATURE_PREJIT
 
 #ifdef FEATURE_READYTORUN
 
index b5c3780..c092182 100644 (file)
@@ -80,6 +80,7 @@ DYNAMICHELPER (DynamicHelperFrameFlags_ObjectArg | DynamicHelperFrameFlags_Objec
 
 #endif // FEATURE_READYTORUN
 
+#ifdef FEATURE_PREJIT
 //============================================================================================
 // EXTERN_C VOID __stdcall VirtualMethodFixupStub()
 
@@ -96,3 +97,4 @@ PATCH_LABEL VirtualMethodFixupPatchLabel
         TAILJMP_RAX
 
 NESTED_END VirtualMethodFixupStub, _TEXT
+#endif // FEATURE_PREJIT
index f567e78..4e98706 100644 (file)
@@ -98,9 +98,11 @@ static const WCHAR OTHER_DOMAIN_FRIENDLY_NAME_PREFIX[] = W("Domain");
 
 SPTR_IMPL(AppDomain, AppDomain, m_pTheAppDomain);
 SPTR_IMPL(SystemDomain, SystemDomain, m_pSystemDomain);
+#ifdef FEATURE_PREJIT
 SVAL_IMPL(BOOL, SystemDomain, s_fForceDebug);
 SVAL_IMPL(BOOL, SystemDomain, s_fForceProfiling);
 SVAL_IMPL(BOOL, SystemDomain, s_fForceInstrument);
+#endif
 
 #ifndef DACCESS_COMPILE
 
@@ -1587,7 +1589,7 @@ void SystemDomain::operator delete(void *pMem)
     // Do nothing - new() was in-place
 }
 
-
+#ifdef FEATURE_PREJIT
 void    SystemDomain::SetCompilationOverrides(BOOL fForceDebug,
                                               BOOL fForceProfiling,
                                               BOOL fForceInstrument)
@@ -1597,9 +1599,11 @@ void    SystemDomain::SetCompilationOverrides(BOOL fForceDebug,
     s_fForceProfiling = fForceProfiling;
     s_fForceInstrument = fForceInstrument;
 }
+#endif
 
 #endif //!DACCESS_COMPILE
 
+#ifdef FEATURE_PREJIT
 void    SystemDomain::GetCompilationOverrides(BOOL * fForceDebug,
                                               BOOL * fForceProfiling,
                                               BOOL * fForceInstrument)
@@ -1609,6 +1613,7 @@ void    SystemDomain::GetCompilationOverrides(BOOL * fForceDebug,
     *fForceProfiling = s_fForceProfiling;
     *fForceInstrument = s_fForceInstrument;
 }
+#endif
 
 #ifndef DACCESS_COMPILE
 
index 9029454..3d4a732 100644 (file)
@@ -3218,6 +3218,7 @@ private:
     static DWORD        m_dwLowestFreeIndex;
 #endif // DACCESS_COMPILE
 
+#ifdef FEATURE_PREJIT
 protected:
 
     // These flags let the correct native image of mscorlib to be loaded.
@@ -3226,6 +3227,7 @@ protected:
     SVAL_DECL(BOOL, s_fForceDebug);
     SVAL_DECL(BOOL, s_fForceProfiling);
     SVAL_DECL(BOOL, s_fForceInstrument);
+#endif
 
 public:
     static void     SetCompilationOverrides(BOOL fForceDebug,
index feadaa8..034e687 100644 (file)
@@ -831,6 +831,7 @@ LOCAL_LABEL(stackProbe_loop):
     bx lr
     NESTED_END stackProbe, _TEXT
 
+#ifdef FEATURE_PREJIT
 //------------------------------------------------
 // VirtualMethodFixupStub
 //
@@ -886,6 +887,7 @@ LOCAL_LABEL(stackProbe_loop):
     bx r12
 
     NESTED_END VirtualMethodFixupStub, _TEXT
+#endif // FEATURE_PREJIT
 
 //------------------------------------------------
 // ExternalMethodFixupStub
@@ -924,6 +926,7 @@ LOCAL_LABEL(stackProbe_loop):
 
     NESTED_END ExternalMethodFixupStub, _TEXT
 
+#ifdef FEATURE_PREJIT
 //------------------------------------------------
 // StubDispatchFixupStub
 //
@@ -956,6 +959,7 @@ LOCAL_LABEL(stackProbe_loop):
     bx   r12
  
     NESTED_END StubDispatchFixupStub, _TEXT
+#endif // FEATURE_PREJIT
 
 //------------------------------------------------
 // JIT_RareDisableHelper
index 67de4f4..e49910d 100644 (file)
 
     IMPORT GetCurrentSavedRedirectContext
 
-    ;; Imports to support virtual import fixup for ngen images
-    IMPORT VirtualMethodFixupWorker
     ;; Import to support cross-moodule external method invocation in ngen images
     IMPORT ExternalMethodFixupWorker
+
+#ifdef FEATURE_PREJIT
+    ;; Imports to support virtual import fixup for ngen images
+    IMPORT VirtualMethodFixupWorker
     IMPORT StubDispatchFixupWorker
+#endif
 
 #ifdef FEATURE_READYTORUN
     IMPORT DynamicHelperWorker
@@ -1241,6 +1244,7 @@ stackProbe_loop
     EPILOG_RETURN
     NESTED_END
 
+#ifdef FEATURE_PREJIT
 ;------------------------------------------------
 ; VirtualMethodFixupStub
 ;
@@ -1295,6 +1299,7 @@ stackProbe_loop
     EPILOG_BRANCH_REG r12
 
     NESTED_END
+#endif // FEATURE_PREJIT
 
 ;------------------------------------------------
 ; ExternalMethodFixupStub
@@ -1333,6 +1338,7 @@ stackProbe_loop
 
     NESTED_END
 
+#ifdef FEATURE_PREJIT
 ;------------------------------------------------
 ; StubDispatchFixupStub
 ;
@@ -1365,6 +1371,7 @@ stackProbe_loop
     EPILOG_BRANCH_REG   r12
  
     NESTED_END
+#endif // FEATURE_PREJIT
 
 ;------------------------------------------------
 ; JIT_RareDisableHelper
index 360cbe6..c93780a 100644 (file)
@@ -1135,7 +1135,7 @@ struct StubPrecode {
         CONTRACTL
         {
             THROWS;
-            GC_TRIGGERS;
+            GC_NOTRIGGER;
         }
         CONTRACTL_END;
 
@@ -1148,7 +1148,7 @@ struct StubPrecode {
         CONTRACTL
         {
             THROWS;
-            GC_TRIGGERS;
+            GC_NOTRIGGER;
         }
         CONTRACTL_END;
 
index 56ed718..28daf9a 100644 (file)
@@ -474,6 +474,7 @@ LOCAL_LABEL(Exit):
     ret  lr  
 WRITE_BARRIER_END JIT_WriteBarrier
 
+#ifdef FEATURE_PREJIT
 //------------------------------------------------
 // VirtualMethodFixupStub
 //
@@ -520,7 +521,8 @@ NESTED_ENTRY VirtualMethodFixupStub, _TEXT, NoHandler
     // and tailcall to the actual method
     EPILOG_BRANCH_REG x12
 
-NESTED_END VirtualMEthodFixupStub, _TEXT
+NESTED_END VirtualMethodFixupStub, _TEXT
+#endif // FEATURE_PREJIT
 
 //------------------------------------------------
 // ExternalMethodFixupStub
index 400423b..01b49db 100644 (file)
 #include "asmconstants.h"
 #include "asmmacros.h"
 
+#ifdef FEATURE_PREJIT
     IMPORT VirtualMethodFixupWorker
+    IMPORT StubDispatchFixupWorker
+#endif
     IMPORT ExternalMethodFixupWorker
     IMPORT PreStubWorker
     IMPORT NDirectImportWorker
     IMPORT VSD_ResolveWorker
-    IMPORT StubDispatchFixupWorker
     IMPORT JIT_InternalThrow
     IMPORT ComPreStubWorker
     IMPORT COMToCLRWorker
@@ -532,6 +534,7 @@ Exit
         ret      lr
     WRITE_BARRIER_END JIT_WriteBarrier
 
+#ifdef FEATURE_PREJIT
 ;------------------------------------------------
 ; VirtualMethodFixupStub
 ;
@@ -579,6 +582,8 @@ Exit
     EPILOG_BRANCH_REG x12
 
     NESTED_END
+#endif // FEATURE_PREJIT
+
 ;------------------------------------------------
 ; ExternalMethodFixupStub
 ;
index 40b73a0..3d26a0a 100644 (file)
@@ -10424,6 +10424,10 @@ ZapHeader.ImportTable        |                    |         |     non-NULL
 
 #endif // 0
 
+#endif
+#endif
+
+#ifndef DACCESS_COMPILE
 //-----------------------------------------------------------------------------
 
 void Module::RunEagerFixups()
@@ -10507,7 +10511,11 @@ void Module::RunEagerFixups()
         }
     }
 }
+#endif // !DACCESS_COMPILE
 
+#ifdef FEATURE_PREJIT
+
+#ifndef DACCESS_COMPILE
 void Module::LoadTokenTables()
 {
     CONTRACTL
@@ -10701,7 +10709,6 @@ BOOL Module::FixupNativeEntry(CORCOMPILE_IMPORT_SECTION* pSection, SIZE_T fixupI
     return TRUE;
 }
 
-#ifdef FEATURE_PREJIT 
 //
 // Profile data management
 //
@@ -11649,7 +11656,6 @@ ExternalMethodBlobEntry::ExternalMethodBlobEntry(mdToken _nestedClass,
     return static_cast<const ExternalMethodBlobEntry *>(pEntry);
 }
 
-
 static bool GetBasename(LPCWSTR _src, __out_ecount(dstlen) __out_z LPWSTR _dst, int dstlen)
 {
     LIMITED_METHOD_CONTRACT;
@@ -12387,7 +12393,6 @@ void Module::DeleteProfilingData()
     
     // the metadataProfileData is free'ed in destructor of the corresponding MetaDataTracker
 }
-#endif //FEATURE_PREJIT
 
 void Module::SetIsIJWFixedUp()
 {
@@ -12395,7 +12400,6 @@ void Module::SetIsIJWFixedUp()
     FastInterlockOr(&m_dwTransientFlags, IS_IJW_FIXED_UP);
 }
 
-#ifdef FEATURE_PREJIT
 /* static */
 Module::TokenProfileData *Module::TokenProfileData::CreateNoThrow(void)
 {
@@ -12421,8 +12425,6 @@ Module::TokenProfileData *Module::TokenProfileData::CreateNoThrow(void)
     return tpd;
 }
 
-#endif // FEATURE_PREJIT
-
 #endif // !DACCESS_COMPILE
 
 #ifndef DACCESS_COMPILE
@@ -12433,7 +12435,6 @@ void Module::SetBeingUnloaded()
 }
 #endif
 
-#ifdef FEATURE_PREJIT 
 void Module::LogTokenAccess(mdToken token, SectionFormat format, ULONG flagnum)
 {
     CONTRACTL
@@ -12545,10 +12546,8 @@ void Module::LogTokenAccess(mdToken token, ULONG flagNum)
         LogTokenAccess(token, format, flagNum);
     }
 }
-#endif // FEATURE_PREJIT
 
 #ifndef DACCESS_COMPILE
-#ifdef FEATURE_PREJIT
 
 //
 // Encoding callbacks
@@ -12808,7 +12807,6 @@ idMethodSpec Module::LogInstantiatedMethod(const MethodDesc * md, ULONG flagNum)
     RETURN result;
 }
 #endif // DACCESS_COMPILE
-#endif //FEATURE_PREJIT
 
 #ifndef DACCESS_COMPILE
 
index 3aab11d..e547418 100644 (file)
@@ -79,12 +79,12 @@ class DynamicMethodTable;
 class CodeVersionManager;
 class TieredCompilationManager;
 class ProfileEmitter;
+class JITInlineTrackingMap;
 #ifdef FEATURE_PREJIT
 class TypeHandleList;
 class TrackingMap;
 struct MethodInModule;
 class PersistentInlineTrackingMapNGen;
-class JITInlineTrackingMap;
 
 extern VerboseLevel g_CorCompileVerboseLevel;
 #endif
@@ -380,8 +380,10 @@ public:
         WRAPPER_NO_CONTRACT;
 
         _ASSERTE((flag & supportedFlags) == flag);
+#ifdef FEATURE_PREJIT
         _ASSERTE(!MapIsCompressed());
         _ASSERTE(dwNumHotItems == 0);
+#endif // FEATURE_PREJIT
 
         PTR_TADDR pElement = GetElementPtr(rid);
         _ASSERTE(pElement);
@@ -740,9 +742,6 @@ struct ModuleCtorInfo
 };
 
 
-
-#ifdef FEATURE_PREJIT
-
 // For IBC Profiling we collect signature blobs for instantiated types.
 // For such instantiated types and methods we create our own ibc token
 // 
@@ -1004,7 +1003,7 @@ public:
 typedef SHash<ProfilingBlobTraits> ProfilingBlobTable;
 typedef DPTR(ProfilingBlobTable) PTR_ProfilingBlobTable;
 
-
+#ifdef FEATURE_PREJIT
 #define METHODTABLE_RESTORE_REASON() \
     RESTORE_REASON_FUNC(CanNotPreRestoreHardBindToParentMethodTable) \
     RESTORE_REASON_FUNC(CanNotPreRestoreHardBindToCanonicalMethodTable) \
index 90f3d4c..a9375e7 100644 (file)
@@ -7,15 +7,6 @@
 #ifndef _DATAIMAGE_H_
 #define _DATAIMAGE_H_
 
-#if defined(FEATURE_PREJIT) && !defined(DACCESS_COMPILE)
-
-// All we really need is to pre-declare the PrecodeType enum, but g++ doesn't
-// support enum pre-declaration, so we need to include the declaration itself.
-/*#include "cgensys.h" // needed to include precode.h*/
-#include "precode.h"
-
-typedef BYTE ZapRelocationType; // IMAGE_REL_XXX enum
-
 // IMAGE_REL_BASED_PTR is architecture specific reloc of virtual address
 #ifdef _TARGET_64BIT_
 #define IMAGE_REL_BASED_PTR IMAGE_REL_BASED_DIR64
@@ -26,6 +17,15 @@ typedef BYTE ZapRelocationType; // IMAGE_REL_XXX enum
 // Special NGEN-specific relocation type for relative pointer (used to make NGen relocation section smaller)
 #define IMAGE_REL_BASED_RELPTR            0x7D
 
+#if defined(FEATURE_PREJIT) && !defined(DACCESS_COMPILE)
+
+// All we really need is to pre-declare the PrecodeType enum, but g++ doesn't
+// support enum pre-declaration, so we need to include the declaration itself.
+/*#include "cgensys.h" // needed to include precode.h*/
+#include "precode.h"
+
+typedef BYTE ZapRelocationType; // IMAGE_REL_XXX enum
+
 class CEEPreloader;
 
 class ZapImage;
index a60f8d4..9e3d706 100644 (file)
@@ -1003,14 +1003,6 @@ void DomainFile::PostLoadLibrary()
 void DomainFile::AddDependencies()
 {
     STANDARD_VM_CONTRACT;
-
-#ifdef FEATURE_PREJIT
-
-    //
-    // CoreCLR hard binds to mscorlib.dll only. No need to track hardbound dependencies.
-    //
-
-#endif // FEATURE_PREJIT
 }
 
 void DomainFile::EagerFixups()
@@ -1022,8 +1014,9 @@ void DomainFile::EagerFixups()
     {
         GetCurrentModule()->RunEagerFixups();
     }
-#ifdef FEATURE_READYTORUN
     else
+#endif // FEATURE_PREJIT
+#ifdef FEATURE_READYTORUN
     if (GetCurrentModule()->IsReadyToRun())
     {
 #ifndef CROSSGEN_COMPILE
@@ -1040,8 +1033,6 @@ void DomainFile::EagerFixups()
                                          GetCurrentModule() /* (void *)pLayout */);
     }
 #endif // FEATURE_READYTORUN
-
-#endif // FEATURE_PREJIT
 }
 
 void DomainFile::VtableFixups()
index 9e393b7..1718bd3 100644 (file)
@@ -1117,7 +1117,8 @@ public:
 #ifdef FEATURE_PREJIT
         return !m_arrayType.IsTagged() && (m_arrayType.IsNull() || m_arrayType.GetValue().IsRestored());
 #else // FEATURE_PREJIT
-        return m_arrayType.IsNull() || m_arrayType.GetValue().IsFullyLoaded();
+        // putting the IsFullyLoaded check here is tempting but incorrect
+        return TRUE;
 #endif // FEATURE_PREJIT
     }
 #endif
index 09fb502..0afc576 100644 (file)
@@ -725,7 +725,6 @@ LOCAL_LABEL(GoCallCalliWorker):
 LEAF_END GenericPInvokeCalliHelper, _TEXT
 
 #ifdef FEATURE_PREJIT
-
 // =========================================================================
 NESTED_ENTRY StubDispatchFixupStub, _TEXT, NoHandler
     STUB_PROLOG
@@ -755,6 +754,7 @@ PATCH_LABEL StubDispatchFixupPatchLabel
     // which disassembles the epilog to unwind the stack.
     ret
 NESTED_END StubDispatchFixupStub, _TEXT
+#endif // FEATURE_PREJIT
 
 // ==========================================================================
 NESTED_ENTRY ExternalMethodFixupStub, _TEXT_ NoHandler
@@ -842,6 +842,7 @@ NESTED_END DelayLoad_MethodCall, _TEXT
 
 #endif // FEATURE_READYTORUN
 
+#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
@@ -891,7 +892,6 @@ PATCH_LABEL VirtualMethodFixupPatchLabel
     // which disassembles the epilog to unwind the stack.
     ret
 NESTED_END VirtualMethodFixupStub, _TEXT
-
 #endif // FEATURE_PREJIT
 
 NESTED_ENTRY ThePreStub, _TEXT, NoHandler
index 19697a4..acaf31b 100644 (file)
@@ -61,8 +61,9 @@ ifdef FEATURE_COMINTEROP
 EXTERN _CLRToCOMWorker@8:PROC
 endif
 
-ifdef FEATURE_PREJIT
 EXTERN _ExternalMethodFixupWorker@16:PROC
+
+ifdef FEATURE_PREJIT
 EXTERN _VirtualMethodFixupWorker@8:PROC
 EXTERN _StubDispatchFixupWorker@16:PROC
 endif
@@ -1523,7 +1524,6 @@ _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
@@ -1564,8 +1564,7 @@ public _VirtualMethodFixupPatchLabel@0
         ret
 
 _VirtualMethodFixupStub@0 endp
-
-endif ; FEATURE_PREJIT
+endif
 
 ;==========================================================================
 ; The prestub
index b42e422..48b24b3 100644 (file)
@@ -85,10 +85,8 @@ EXTERN_C void SinglecastDelegateInvokeStub();
 // Needed for PInvoke inlining in ngened images
 #define HAS_NDIRECT_IMPORT_PRECODE              1
 
-#ifdef FEATURE_PREJIT
 #define HAS_FIXUP_PRECODE                       1
 #define HAS_FIXUP_PRECODE_CHUNKS                1
-#endif
 
 // ThisPtrRetBufPrecode one is necessary for closed delegates over static methods with return buffer
 #define HAS_THISPTR_RETBUF_PRECODE              1
index df265f2..a5a85b0 100644 (file)
@@ -1363,6 +1363,7 @@ BOOL DoesSlotCallPrestub(PCODE pCode)
     return pCode == GetPreStubEntryPoint();
 }
 
+#ifdef FEATURE_PREJIT
 //==========================================================================================
 // In NGen image, virtual slots inherited from cross-module dependencies point to jump thunks.
 // These jump thunk initially point to VirtualMethodFixupStub which transfers control here.
@@ -1430,7 +1431,7 @@ EXTERN_C PVOID STDCALL VirtualMethodFixupWorker(Object * pThisPtr,  CORCOMPILE_V
 
     return PVOID(pCode);
 }
-
+#endif // FEATURE_PREJIT
 
 #ifdef FEATURE_READYTORUN
 
index f46f506..7020e40 100644 (file)
@@ -6485,7 +6485,7 @@ void rel32SetInterlocked(/*PINT32*/ PVOID pRel32, TADDR target, MethodDesc* pMD)
     CONTRACTL
     {
         THROWS;         // Creating a JumpStub could throw OutOfMemory
-        GC_TRIGGERS;
+        GC_NOTRIGGER;
     }
     CONTRACTL_END;
 
@@ -6500,7 +6500,7 @@ BOOL rel32SetInterlocked(/*PINT32*/ PVOID pRel32, TADDR target, TADDR expected,
     CONTRACTL
     {
         THROWS;         // Creating a JumpStub could throw OutOfMemory
-        GC_TRIGGERS;
+        GC_NOTRIGGER;
     }
     CONTRACTL_END;
 
index 31bc104..3d79b51 100644 (file)
@@ -542,7 +542,7 @@ struct StubPrecode {
         CONTRACTL
         {
             THROWS;
-            GC_TRIGGERS;
+            GC_NOTRIGGER;
         }
         CONTRACTL_END;
 
@@ -555,7 +555,7 @@ struct StubPrecode {
         CONTRACTL
         {
             THROWS;
-            GC_TRIGGERS;
+            GC_NOTRIGGER;
         }
         CONTRACTL_END;
 
index 991f936..01ffa38 100644 (file)
@@ -523,7 +523,9 @@ void IBCLogger::LogMethodAccessHelper(const MethodDesc* pMD, ULONG flagNum)
         if (!pMT->IsRestored_NoLogging())
             goto DelayCallback;
 
+#ifdef FEATURE_PREJIT
         LogMethodTableAccessHelper(pMT);
+#endif
 
         Module *pModule = pMT->GetModule();
 
@@ -554,12 +556,14 @@ void IBCLogger::LogMethodAccessHelper(const MethodDesc* pMD, ULONG flagNum)
                         goto DelayCallback;
                 }
 
+#ifdef FEATURE_PREJIT
                 Module *pPZModule = Module::GetPreferredZapModuleForMethodDesc(pMD);
                 token = pPZModule->LogInstantiatedMethod(pMD, flagNum);
                 if (!IsNilToken(token))
                 {
                     pPZModule->LogTokenAccess(token, MethodProfilingData, flagNum);
                 }
+#endif
             }
             else
             {
@@ -579,7 +583,33 @@ void IBCLogger::LogMethodAccessWrapper(IBCLogger* pLogger, const void * pValue1,
     WRAPPER_NO_CONTRACT;
     pLogger->LogMethodAccessHelper((MethodDesc *)pValue1, (ULONG)(SIZE_T)pValue2);
 }
+// Log access to method code or method header
+void IBCLogger::LogMethodCodeAccessHelper(MethodDesc *pMD)
+{
+    CONTRACTL
+    {
+        NOTHROW;
+        GC_NOTRIGGER;
+        MODE_ANY;
+        PRECONDITION(g_IBCLogger.InstrEnabled());
+    }
+    CONTRACTL_END;
+
+    LogMethodAccessHelper(pMD, ReadMethodCode);
+}
+
+// Log access to method gc info
+void IBCLogger::LogMethodGCInfoAccessHelper(MethodDesc* pMD)
+{
+    WRAPPER_NO_CONTRACT;
+
+    _ASSERTE(InstrEnabled());
+
+    LogMethodAccessHelper(pMD, ReadGCInfo);
+    LogMethodAccessHelper(pMD, CommonReadGCInfo);
+}
 
+#ifdef FEATURE_PREJIT
 void IBCLogger::LogMethodDescAccessHelper(const MethodDesc *pMD)
 {
     WRAPPER_NO_CONTRACT;
@@ -610,21 +640,6 @@ void IBCLogger::LogMethodPrecodeWriteAccessHelper(MethodDesc *pMD)
     LogMethodAccessHelper(pMD, WriteMethodPrecode);
 }
 
-// Log access to method code or method header
-void IBCLogger::LogMethodCodeAccessHelper(MethodDesc *pMD)
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-        PRECONDITION(g_IBCLogger.InstrEnabled());
-    }
-    CONTRACTL_END;
-
-    LogMethodAccessHelper(pMD, ReadMethodCode);
-}
-
 // Log access to the method code and method header for NDirect calls
 void IBCLogger::LogNDirectCodeAccessHelper(MethodDesc *pMD) 
 {
@@ -641,18 +656,6 @@ void IBCLogger::LogNDirectCodeAccessHelper(MethodDesc *pMD)
     LogMethodAccessHelper(pMD, ReadMethodCode);
 }
 
-
-// Log access to method gc info
-void IBCLogger::LogMethodGCInfoAccessHelper(MethodDesc *pMD)
-{
-    WRAPPER_NO_CONTRACT;
-
-    _ASSERTE(InstrEnabled());
-
-    LogMethodAccessHelper(pMD, ReadGCInfo);
-    LogMethodAccessHelper(pMD, CommonReadGCInfo);
-}
-
 // Log access to method table
 void IBCLogger::LogMethodTableAccessHelper(MethodTable const * pMT) 
 {
@@ -1096,6 +1099,7 @@ DelayCallback:
     DelayedCallbackPtr(LogRVADataAccessWrapper, pFD);
 }
 
+#endif // FEATURE_PREJIT
 
 #define LOADORDER_INSTR                 0x00000001
 #define RID_ACCESSORDER_INSTR           0x00000002
index 740637b..6aba244 100644 (file)
@@ -40,7 +40,7 @@ typedef PTR_VOID HashDatum;
 
 typedef Pair< Module*, mdToken > RidMapLogData;
 
-#if defined(FEATURE_PREJIT) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
+#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
 #define IBCLOGGER_ENABLED
 #endif
 
@@ -445,7 +445,7 @@ private:
 
     void DelayedCallbackPtr(pfnIBCAccessCallback callback, const void * pValue1, const void * pValue2 = NULL);
 
-#else // FEATURE_PREJIT && !DACCESS_COMPILE
+#else // IBCLOGGER_ENABLED
 
 #define LOGACCESS_PTR(name,type)                        \
 public:                                                 \
@@ -455,16 +455,36 @@ public:                                                 \
 public:                                                 \
     void Log##name##Access(type p) { SUPPORTS_DAC; }    \
 
-#endif // FEATURE_PREJIT && !DACCESS_COMPILE
-
-    // Log access to method desc (which adds the method desc to the required list)
-    // Implemented by : code:IBCLogger.LogMethodDescAccessHelper
-    LOGACCESS_PTR(MethodDesc, const MethodDesc)
+#endif // IBCLOGGER_ENABLED
 
     // Log access to method code or method header
     // Implemented by : code:IBCLogger.LogMethodCodeAccessHelper
     LOGACCESS_PTR(MethodCode, MethodDesc)
 
+    // Log access to gc info
+    // Implemented by : code:IBCLogger.LogMethodGCInfoAccessHelper
+    LOGACCESS_PTR(MethodGCInfo, MethodDesc)
+
+// The accesses to individual datastructures matter for fragile NGen only
+#ifndef FEATURE_PREJIT
+
+#undef LOGACCESS_PTR
+#undef LOGACCESS_VALUE
+
+#define LOGACCESS_PTR(name,type)                        \
+public:                                                 \
+    void Log##name##Access(type* p) { SUPPORTS_DAC; }   \
+
+#define LOGACCESS_VALUE(name, type)                     \
+public:                                                 \
+    void Log##name##Access(type p) { SUPPORTS_DAC; }    \
+
+#endif // FEATURE_PREJIT
+
+    // Log access to method desc (which adds the method desc to the required list)
+    // Implemented by : code:IBCLogger.LogMethodDescAccessHelper
+    LOGACCESS_PTR(MethodDesc, const MethodDesc)
+
     // Log access to the NDirect data stored for a MethodDesc
     // also implies that the IL_STUB for the NDirect method is executed
     // Implemented by : code:IBCLogger.LogNDirectCodeAccessHelper
@@ -482,10 +502,6 @@ public:                                                 \
     // Implemented by : code:IBCLogger.LogMethodPrecodeWriteAccessHelper
     LOGACCESS_PTR(MethodPrecodeWrite,MethodDesc)
 
-    // Log access to gc info
-    // Implemented by : code:IBCLogger.LogMethodGCInfoAccessHelper
-    LOGACCESS_PTR(MethodGCInfo, MethodDesc)
-
     // Log access to method table
     // Implemented by : code:IBCLogger.LogMethodTableAccessHelper
     LOGACCESS_PTR(MethodTable, MethodTable const)
index cdbd443..d8688e1 100644 (file)
@@ -3169,6 +3169,10 @@ void DynamicMethodDesc::Restore()
         RestoreSignatureContainingInternalTypes(pSig, cSigLen);
     }
 }
+#else // FEATURE_PREJIT
+void DynamicMethodDesc::Restore()
+{
+}
 #endif // FEATURE_PREJIT
 
 #ifdef FEATURE_NATIVE_IMAGE_GENERATION
@@ -3912,7 +3916,6 @@ void ComPlusCallInfo::Fixup(DataImage *image)
 
 #endif // !DACCESS_COMPILE
 
-#ifdef FEATURE_PREJIT
 //*******************************************************************************
 void MethodDesc::CheckRestore(ClassLoadLevel level)
 {
@@ -3932,11 +3935,11 @@ void MethodDesc::CheckRestore(ClassLoadLevel level)
 
             // First restore method table pointer in singleton chunk;
             // it might be out-of-module
+#ifdef FEATURE_PREJIT
             GetMethodDescChunk()->RestoreMTPointer(level);
 #ifdef _DEBUG
             Module::RestoreMethodTablePointer(&m_pDebugMethodTable, NULL, level);
 #endif
-
             // Now restore wrapped method desc if present; we need this for the dictionary layout too
             if (pIMD->IMD_IsWrapperStubWithInstantiations())
                 Module::RestoreMethodDescPointer(&pIMD->m_pWrappedMethodDesc);
@@ -3946,6 +3949,9 @@ void MethodDesc::CheckRestore(ClassLoadLevel level)
             {
                 GetMethodDictionary()->Restore(GetNumGenericMethodArgs(), level);
             }
+#else
+            ClassLoader::EnsureLoaded(TypeHandle(GetMethodTable()), level);
+#endif
 
             g_IBCLogger.LogMethodDescWriteAccess(this);
 
@@ -3992,13 +3998,6 @@ void MethodDesc::CheckRestore(ClassLoadLevel level)
         }
     }
 }
-#else // FEATURE_PREJIT
-//*******************************************************************************
-void MethodDesc::CheckRestore(ClassLoadLevel level)
-{
-    LIMITED_METHOD_CONTRACT;
-}
-#endif // !FEATURE_PREJIT
 
 // static
 MethodDesc* MethodDesc::GetMethodDescFromStubAddr(PCODE addr, BOOL fSpeculative /*=FALSE*/)
index 2782c9b..d0dd136 100644 (file)
@@ -5262,8 +5262,6 @@ void MethodTableWriteableData::Fixup(DataImage *image, MethodTable *pMT, BOOL ne
 
 #endif // FEATURE_NATIVE_IMAGE_GENERATION
 
-#ifdef FEATURE_PREJIT
-
 //==========================================================================================
 void MethodTable::CheckRestore()
 {
@@ -5283,15 +5281,6 @@ void MethodTable::CheckRestore()
     g_IBCLogger.LogMethodTableAccess(this);
 }
 
-#else // !FEATURE_PREJIT
-//==========================================================================================
-void MethodTable::CheckRestore()
-{
-    LIMITED_METHOD_CONTRACT;
-}
-#endif // !FEATURE_PREJIT
-
-
 #ifndef DACCESS_COMPILE
 
 BOOL SatisfiesClassConstraints(TypeHandle instanceTypeHnd, TypeHandle typicalTypeHnd,
index e839e8f..c965c61 100644 (file)
@@ -8,6 +8,7 @@
 #include "common.h"
 #include "peimagelayout.h"
 #include "peimagelayout.inl"
+#include "dataimage.h"
 
 #if defined(PLATFORM_WINDOWS) && !defined(CROSSGEN_COMPILE)
 #include "amsi.h"
@@ -88,8 +89,6 @@ PEImageLayout* PEImageLayout::Map(HANDLE hFile, PEImage* pOwner)
     RETURN pAlloc.Extract();
 }
 
-#ifdef FEATURE_PREJIT
-
 #ifdef FEATURE_PAL
 DWORD SectionCharacteristicsToPageProtection(UINT characteristics)
 {
@@ -293,7 +292,6 @@ void PEImageLayout::ApplyBaseRelocations()
         ClrFlushInstructionCache(pFlushRegion, cbFlushRegion);
     }
 }
-#endif // FEATURE_PREJIT
 
 
 RawImageLayout::RawImageLayout(const void *flat, COUNT_T size, PEImage* pOwner)
index 8ddb577..17254bc 100644 (file)
@@ -68,9 +68,7 @@ public:
     ULONG Release();
     const SString& GetPath();
 
-#ifdef FEATURE_PREJIT
     void ApplyBaseRelocations();
-#endif
 
 public:
 #ifdef DACCESS_COMPILE
index ba99900..593ab8d 100644 (file)
@@ -324,28 +324,27 @@ void NativeImagePerfMap::LogDataForModule(Module * pModule)
 
     SIZE_T baseAddr = (SIZE_T)pLoadedLayout->GetBase();
 
-#ifdef FEATURE_READYTORUN_COMPILER
-    if (pLoadedLayout->HasReadyToRunHeader())
+#ifdef FEATURE_PREJIT
+    if (!pLoadedLayout->HasReadyToRunHeader())
     {
-        ReadyToRunInfo::MethodIterator mi(pModule->GetReadyToRunInfo());
+        MethodIterator mi((PTR_Module)pModule);
         while (mi.Next())
         {
             MethodDesc *hotDesc = mi.GetMethodDesc();
+            hotDesc->CheckRestore();
 
             LogPreCompiledMethod(hotDesc, mi.GetMethodStartAddress(), baseAddr);
         }
+        return;
     }
-    else
-#endif // FEATURE_READYTORUN_COMPILER
+#endif
+
+    ReadyToRunInfo::MethodIterator mi(pModule->GetReadyToRunInfo());
+    while (mi.Next())
     {
-        MethodIterator mi((PTR_Module)pModule);
-        while (mi.Next())
-        {
-            MethodDesc *hotDesc = mi.GetMethodDesc();
-            hotDesc->CheckRestore();
+        MethodDesc* hotDesc = mi.GetMethodDesc();
 
-            LogPreCompiledMethod(hotDesc, mi.GetMethodStartAddress(), baseAddr);
-        }
+        LogPreCompiledMethod(hotDesc, mi.GetMethodStartAddress(), baseAddr);
     }
 }
 
index 8dfb1cd..e20f492 100644 (file)
@@ -1125,7 +1125,6 @@ TypeHandle SigPointer::GetTypeHandleThrowing(
             break;
         }
 
-#ifdef FEATURE_PREJIT
         case ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG:
         {
 #ifndef DACCESS_COMPILE
@@ -1258,7 +1257,6 @@ TypeHandle SigPointer::GetTypeHandleThrowing(
 #endif
             break;
         }
-#endif // FEATURE_PREJIT
 
         case ELEMENT_TYPE_VAR:
         {
index a18792d..27ab5cf 100644 (file)
@@ -1511,10 +1511,14 @@ BOOL RangeSectionStubManager::TraceManager(Thread *thread,
     }
     CONTRACTL_END;
 
+#ifdef FEATURE_PREJIT
     // Both virtual and external import thunks have the same structure. We can use
     // common code to handle them.
     _ASSERTE(GetIP(pContext) == GetEEFuncEntryPoint(VirtualMethodFixupPatchLabel) 
          || GetIP(pContext) == GetEEFuncEntryPoint(ExternalMethodFixupPatchLabel));
+#else
+    _ASSERTE(GetIP(pContext) == GetEEFuncEntryPoint(ExternalMethodFixupPatchLabel));
+#endif
 
     *pRetAddr = (BYTE *)StubManagerHelpers::GetReturnAddress(pContext);
 
index 40e846b..dcd95f8 100644 (file)
@@ -1464,9 +1464,7 @@ Thread::Thread()
 
     m_pPendingTypeLoad = NULL;
 
-#ifdef FEATURE_PREJIT
     m_pIBCInfo = NULL;
-#endif
 
     m_dwAVInRuntimeImplOkayCount = 0;
 
@@ -2630,11 +2628,9 @@ Thread::~Thread()
 
     g_pThinLockThreadIdDispenser->DisposeId(GetThreadId());
 
-#ifdef FEATURE_PREJIT
     if (m_pIBCInfo) {
         delete m_pIBCInfo;
     }
-#endif
 
 #ifdef FEATURE_EVENT_TRACE
     // Destruct the thread local type cache for allocation sampling
index 2cbf0e0..3a521c0 100644 (file)
@@ -2953,8 +2953,6 @@ public:
     }
 #endif
 
-#ifdef FEATURE_PREJIT
-
     private:
 
     ThreadLocalIBCInfo* m_pIBCInfo;
@@ -2986,8 +2984,6 @@ public:
 
 #endif // #ifndef DACCESS_COMPILE
 
-#endif // #ifdef FEATURE_PREJIT
-
     // Indicate whether this thread should run in the background.  Background threads
     // don't interfere with the EE shutting down.  Whereas a running non-background
     // thread prevents us from shutting down (except through System.Exit(), of course)
index 66cbc5f..3cf096a 100644 (file)
@@ -44,10 +44,12 @@ struct VTableCallHolder;
 // Forward function declarations
 extern "C" void InContextTPQuickDispatchAsmStub();
 
+#ifdef FEATURE_PREJIT
 extern "C" PCODE STDCALL StubDispatchFixupWorker(TransitionBlock * pTransitionBlock, 
                                                  TADDR siteAddrForRegisterIndirect,
                                                  DWORD sectionIndex, 
                                                  Module * pModule);
+#endif
 
 extern "C" PCODE STDCALL VSD_ResolveWorker(TransitionBlock * pTransitionBlock,
                                            TADDR siteAddrForRegisterIndirect,