Skip to content

Commit

Permalink
Disable CER feature as it is not used (dotnet#8218)
Browse files Browse the repository at this point in the history
Use FEATURE_CER to scope CER code,
and disable CER feature in CoreCLR.
  • Loading branch information
John Chen authored Nov 29, 2016
1 parent c1e15f4 commit e678512
Show file tree
Hide file tree
Showing 27 changed files with 106 additions and 124 deletions.
2 changes: 2 additions & 0 deletions src/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,9 @@ HRESULT ClrDataAccess::EnumMemCLRStatic(IN CLRDataEnumMemoryFlags flags)
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pValueTypeClass.EnumMem(); )
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pEnumClass.EnumMem(); )
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pThreadClass.EnumMem(); )
#ifdef FEATURE_CER
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pCriticalFinalizerObjectClass.EnumMem(); )
#endif
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pFreeObjectMethodTable.EnumMem(); )
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_pObjectCtorMD.EnumMem(); )
CATCH_ALL_EXCEPT_RETHROW_COR_E_OPERATIONCANCELLED( g_fHostConfig.EnumMem(); )
Expand Down
7 changes: 7 additions & 0 deletions src/debug/daccess/nidump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4088,6 +4088,7 @@ void NativeImageDumper::DumpModule( PTR_Module module )
(int)(module->m_maxDynamicEntries
* sizeof(*(module->m_pDynamicStaticsInfo))));

#ifdef FEATURE_CER
DisplayWriteFieldInt( m_dwReliabilityContract,
module->m_dwReliabilityContract, Module, MODULE );

Expand All @@ -4105,6 +4106,7 @@ void NativeImageDumper::DumpModule( PTR_Module module )
offsetof(Module, m_pCerNgenRootTable),
fieldsize(Module, m_pCerNgenRootTable) );
}
#endif


_ASSERTE(module->m_debuggerSpecificData.m_pDynamicILCrst == NULL);
Expand Down Expand Up @@ -4152,6 +4154,7 @@ bool NativeImageDumper::isPrecode(TADDR maybePrecode)
return !!module->IsZappedPrecode(maybePrecode);
}

#ifdef FEATURE_CER
void NativeImageDumper::DumpNgenRootTable( PTR_CerNgenRootTable table,
const char * name, unsigned offset,
unsigned fieldSize )
Expand Down Expand Up @@ -4231,6 +4234,8 @@ void NativeImageDumper::DumpNgenRootTable( PTR_CerNgenRootTable table,

DisplayEndStructure( MODULE ); //CERNgenRootTable
}
#endif // FEATURE_CER

void NativeImageDumper::IterateTypeDefToMTCallback( TADDR mtTarget,
TADDR flags,
PTR_LookupMapBase map,
Expand Down Expand Up @@ -9034,12 +9039,14 @@ NativeImageDumper::DumpEEClassForMethodTable( PTR_MethodTable mt )
DisplayWriteFieldInt( m_cbModuleDynamicID, pClassOptional->m_cbModuleDynamicID,
EEClassOptionalFields, EECLASSES );

#ifdef FEATURE_CER
/* REVISIT_TODO Fri 10/14/2005
* Use the macros from ConstrainedExecutionRegion.cpp on this?
*/
DisplayWriteFieldUInt( m_dwReliabilityContract,
clazz->GetReliabilityContract(),
EEClassOptionalFields, EECLASSES );
#endif

DisplayWriteFieldEnumerated( m_SecProps, clazz->GetSecurityProperties()->dwFlags,
EEClassOptionalFields, s_SecurityProperties, W("|"),
Expand Down
4 changes: 4 additions & 0 deletions src/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pOverlappedDataClass, ::g_pOve
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pValueTypeClass, ::g_pValueTypeClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pEnumClass, ::g_pEnumClass)
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pThreadClass, ::g_pThreadClass)
#ifdef FEATURE_CER
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pCriticalFinalizerObjectClass, ::g_pCriticalFinalizerObjectClass)
#endif
#ifndef FEATURE_CORECLR
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pAsyncFileStream_AsyncResultClass, ::g_pAsyncFileStream_AsyncResultClass)
#endif // !FEATURE_CORECLR
Expand All @@ -251,7 +253,9 @@ DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pBaseRuntimeClass, ::g_pBaseRu
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pICastableInterface, ::g_pICastableInterface)
#endif // FEATURE_ICASTABLE

#ifdef FEATURE_CER
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pPrepareConstrainedRegionsMethod, ::g_pPrepareConstrainedRegionsMethod)
#endif
DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pExecuteBackoutCodeHelperMethod, ::g_pExecuteBackoutCodeHelperMethod)

DEFINE_DACVAR(ULONG, UNKNOWN_POINTER_TYPE, dac__g_pObjectCtorMD, ::g_pObjectCtorMD)
Expand Down
7 changes: 6 additions & 1 deletion src/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ set(VM_SOURCES_WKS
comthreadpool.cpp
comutilnative.cpp
comwaithandle.cpp
constrainedexecutionregion.cpp
coverage.cpp
customattribute.cpp
custommarshalerinfo.cpp
Expand Down Expand Up @@ -242,6 +241,12 @@ set(VM_SOURCES_WKS
${VM_SOURCES_GDBJIT}
)

if(FEATURE_CER)
list(APPEND VM_SOURCES_WKS
constrainedexecutionregion.cpp
)
endif(FEATURE_CER)

if(FEATURE_EVENT_TRACE)
list(APPEND VM_SOURCES_WKS
eventtrace.cpp
Expand Down
4 changes: 4 additions & 0 deletions src/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2949,6 +2949,7 @@ void SystemDomain::LoadBaseSystemClasses()
g_pExecutionEngineExceptionClass = MscorlibBinder::GetException(kExecutionEngineException);
g_pThreadAbortExceptionClass = MscorlibBinder::GetException(kThreadAbortException);

#ifdef FEATURE_CER
// Used for determining whether a class has a critical finalizer
// To determine whether a class has a critical finalizer, we
// currently will simply see if it's parent class has a critical
Expand All @@ -2957,6 +2958,7 @@ void SystemDomain::LoadBaseSystemClasses()
// here.
g_pCriticalFinalizerObjectClass = MscorlibBinder::GetClass(CLASS__CRITICAL_FINALIZER_OBJECT);
_ASSERTE(g_pCriticalFinalizerObjectClass->HasCriticalFinalizer());
#endif

// used by gc to handle predefined agility checking
g_pThreadClass = MscorlibBinder::GetClass(CLASS__THREAD);
Expand Down Expand Up @@ -2986,7 +2988,9 @@ void SystemDomain::LoadBaseSystemClasses()

// Load a special marker method used to detect Constrained Execution Regions
// at jit time.
#ifdef FEATURE_CER
g_pPrepareConstrainedRegionsMethod = MscorlibBinder::GetMethod(METHOD__RUNTIME_HELPERS__PREPARE_CONSTRAINED_REGIONS);
#endif
g_pExecuteBackoutCodeHelperMethod = MscorlibBinder::GetMethod(METHOD__RUNTIME_HELPERS__EXECUTE_BACKOUT_CODE_HELPER);

// Make sure that FCall mapping for Monitor.Enter is initialized. We need it in case Monitor.Enter is used only as JIT helper.
Expand Down
20 changes: 18 additions & 2 deletions src/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ void Module::Destruct()
m_InstMethodHashTableCrst.Destroy();
m_ISymUnmanagedReaderCrst.Destroy();

#ifdef FEATURE_CER
if (m_pCerPrepInfo)
{
_ASSERTE(m_pCerCrst != NULL);
Expand All @@ -1672,6 +1673,7 @@ void Module::Destruct()
}
if (m_pCerCrst)
delete m_pCerCrst;
#endif // FEATURE_CER

if (m_debuggerSpecificData.m_pDynamicILCrst)
{
Expand Down Expand Up @@ -1702,8 +1704,10 @@ void Module::Destruct()
}

#ifdef FEATURE_PREJIT
#ifdef FEATURE_CER
if (m_pCerNgenRootTable && (m_dwTransientFlags & M_CER_ROOT_TABLE_ON_HEAP))
delete m_pCerNgenRootTable;
#endif

if (HasNativeImage())
{
Expand Down Expand Up @@ -3154,6 +3158,7 @@ BOOL Module::IsPreV4Assembly()
return !!(m_dwPersistedFlags & IS_PRE_V4_ASSEMBLY);
}

#ifdef FEATURE_CER
DWORD Module::GetReliabilityContract()
{
CONTRACTL
Expand All @@ -3180,6 +3185,7 @@ DWORD Module::GetReliabilityContract()

return m_dwReliabilityContract;
}
#endif // FEATURE_CER

ArrayDPTR(FixupPointer<PTR_MethodTable>) ModuleCtorInfo::GetGCStaticMTs(DWORD index)
{
Expand Down Expand Up @@ -9860,10 +9866,12 @@ void Module::PrepareTypesForSave(DataImage *image)
PrepareRemotableMethodInfo(pMT);
#endif // FEATURE_REMOTING

#ifdef FEATURE_CER
// If this module defines any CriticalFinalizerObject derived classes,
// then we'll prepare these types for Constrained Execution Regions (CER) now.
// (Normally they're prepared at object instantiation time, a little too late for ngen).
PrepareCriticalType(pMT);
#endif // FEATURE_CER
}
}

Expand Down Expand Up @@ -9947,7 +9955,9 @@ void Module::Save(DataImage *image)
// Cache values of all persisted flags computed from custom attributes
IsNoStringInterning();
IsRuntimeWrapExceptions();
#ifdef FEATURE_CER
GetReliabilityContract();
#endif
IsPreV4Assembly();

HasDefaultDllImportSearchPathsAttribute();
Expand Down Expand Up @@ -10302,10 +10312,12 @@ void Module::Save(DataImage *image)
m_nPropertyNameSet * sizeof(BYTE),
DataImage::ITEM_PROPERTY_NAME_SET);

#ifdef FEATURE_CER
// Save Constrained Execution Region (CER) fixup information (used to eagerly fixup trees of methods to avoid any runtime
// induced failures when invoking the tree).
if (m_pCerNgenRootTable != NULL)
m_pCerNgenRootTable->Save(image, profileData);
#endif

// Sort the list of RVA statics in an ascending order wrt the RVA
// and save them.
Expand Down Expand Up @@ -10761,6 +10773,7 @@ void Module::PlaceMethod(DataImage *image, MethodDesc *pMD, DWORD profilingFlags
image->PlaceStructureForAddress(pMD, CORCOMPILE_SECTION_WRITE);
}

#ifdef FEATURE_CER
if (profilingFlags & (1 << ReadCerMethodList))
{
// protect against stale IBC data
Expand All @@ -10771,6 +10784,7 @@ void Module::PlaceMethod(DataImage *image, MethodDesc *pMD, DWORD profilingFlags
image->PlaceStructureForAddress(m_pCerNgenRootTable->GetList(pMD), CORCOMPILE_SECTION_HOT);
}
}
#endif // FEATURE_CER

if (profilingFlags & (1 << WriteMethodPrecode))
{
Expand Down Expand Up @@ -11314,6 +11328,7 @@ void Module::Fixup(DataImage *image)
image->ZeroField(m_FileReferencesMap.pTable, 0,
m_FileReferencesMap.GetSize() * sizeof(void*));

#ifdef FEATURE_CER
//
// Fixup Constrained Execution Regions restoration records.
//
Expand All @@ -11330,6 +11345,7 @@ void Module::Fixup(DataImage *image)
// Zero out fields we always compute at runtime lazily.
image->ZeroField(this, offsetof(Module, m_pCerPrepInfo), sizeof(m_pCerPrepInfo));
image->ZeroField(this, offsetof(Module, m_pCerCrst), sizeof(m_pCerCrst));
#endif // FEATURE_CER

image->ZeroField(this, offsetof(Module, m_debuggerSpecificData), sizeof(m_debuggerSpecificData));

Expand Down Expand Up @@ -15593,7 +15609,7 @@ FieldDesc *Module::LookupFieldDef(mdFieldDef token)
#endif // DACCESS_COMPILE


#ifndef DACCESS_COMPILE
#if !defined(DACCESS_COMPILE) && defined(FEATURE_CER)

// Access to CerPrepInfo, the structure used to track CERs prepared at runtime (as opposed to ngen time). GetCerPrepInfo will
// return the structure associated with the given method desc if it exists or NULL otherwise. CreateCerPrepInfo will get the
Expand Down Expand Up @@ -15745,7 +15761,7 @@ void Module::RestoreCer(MethodDesc *pMD)

#endif // FEATURE_PREJIT

#endif // !DACCESS_COMPILE
#endif // !DACCESS_COMPILE && FEATURE_CER



Expand Down
10 changes: 8 additions & 2 deletions src/vm/ceeload.h
Original file line number Diff line number Diff line change
Expand Up @@ -3394,10 +3394,12 @@ class Module
//-----------------------------------------------------------------------------------------
BOOL IsPreV4Assembly();

#ifdef FEATURE_CER
//-----------------------------------------------------------------------------------------
// Get reliability contract info, see ConstrainedExecutionRegion.cpp for details.
//-----------------------------------------------------------------------------------------
DWORD GetReliabilityContract();
#endif

//-----------------------------------------------------------------------------------------
// Parse/Return NeutralResourcesLanguageAttribute if it exists (updates Module member variables at ngen time)
Expand All @@ -3406,13 +3408,15 @@ class Module

protected:

#ifdef FEATURE_CER
Volatile<DWORD> m_dwReliabilityContract;
#endif

// initialize Crst controlling the Dynamic IL hashtables
void InitializeDynamicILCrst();

#ifndef DACCESS_COMPILE
public:
#if !defined(DACCESS_COMPILE) && defined(FEATURE_CER)

// Support for getting and creating information about Constrained Execution Regions rooted in this module.

Expand Down Expand Up @@ -3443,7 +3447,7 @@ class Module
LIMITED_METHOD_CONTRACT;
return m_pCerCrst;
}
#endif // !DACCESS_COMPILE
#endif // !DACCESS_COMPILE && FEATURE_CER

#ifdef FEATURE_CORECLR
void VerifyAllMethods();
Expand All @@ -3456,10 +3460,12 @@ class Module
}

private:
#ifdef FEATURE_CER
EEPtrHashTable *m_pCerPrepInfo; // Root methods prepared for Constrained Execution Regions
Crst *m_pCerCrst; // Mutex protecting update access to both of the above hashes
#ifdef FEATURE_PREJIT
CerNgenRootTable *m_pCerNgenRootTable; // Root methods of CERs found during ngen and requiring runtime restoration
#endif
#endif

// This struct stores the data used by the managed debugging infrastructure. If it turns out that
Expand Down
3 changes: 3 additions & 0 deletions src/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "constrainedexecutionregion.h"
#include "customattribute.h"
#include "encee.h"
#include "typestring.h"

#ifdef FEATURE_COMINTEROP
#include "comcallablewrapper.h"
Expand Down Expand Up @@ -2490,12 +2491,14 @@ MethodTable::GetSubstitutionForParent(

#endif //!DACCESS_COMPILE

#ifdef FEATURE_CER
//*******************************************************************************
DWORD EEClass::GetReliabilityContract()
{
LIMITED_METHOD_CONTRACT;
return HasOptionalFields() ? GetOptionalFields()->m_dwReliabilityContract : RC_NULL;
}
#endif // FEATURE_CER

//*******************************************************************************
#ifdef FEATURE_PREJIT
Expand Down
4 changes: 4 additions & 0 deletions src/vm/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,9 @@ class EEClassOptionalFields
#define MODULE_NON_DYNAMIC_STATICS ((DWORD)-1)
DWORD m_cbModuleDynamicID;

#ifdef FEATURE_CER
DWORD m_dwReliabilityContract;
#endif

SecurityProperties m_SecProps;

Expand Down Expand Up @@ -1768,12 +1770,14 @@ class EEClass // DO NOT CREATE A NEW EEClass USING NEW!
// Cached class level reliability contract info, see ConstrainedExecutionRegion.cpp for details.
DWORD GetReliabilityContract();

#ifdef FEATURE_CER
inline void SetReliabilityContract(DWORD dwValue)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(HasOptionalFields());
GetOptionalFields()->m_dwReliabilityContract = dwValue;
}
#endif

#if defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
// Get number of eightbytes used by a struct passed in registers.
Expand Down
2 changes: 2 additions & 0 deletions src/vm/class.inl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ inline void EEClassOptionalFields::Init()
m_WinRTRedirectedTypeIndex = WinMDAdapter::RedirectedTypeIndex_Invalid;
#endif // FEATURE_COMINTEROP
m_cbModuleDynamicID = MODULE_NON_DYNAMIC_STATICS;
#ifdef FEATURE_CER
m_dwReliabilityContract = RC_NULL;
#endif
m_SecProps = 0;
#if defined(UNIX_AMD64_ABI) && defined(FEATURE_UNIX_AMD64_STRUCT_PASSING)
m_numberEightBytes = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/vm/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6603,7 +6603,9 @@ void CEEPreloader::PrePrepareMethodIfNecessary(CORINFO_METHOD_HANDLE hMethod)
{
STANDARD_VM_CONTRACT;

#ifdef FEATURE_CER
::PrePrepareMethodIfNecessary(hMethod);
#endif
}

static void SetStubMethodDescOnInteropMethodDesc(MethodDesc* pInteropMD, MethodDesc* pStubMD, bool fReverseStub)
Expand Down
5 changes: 0 additions & 5 deletions src/vm/constrainedexecutionregion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,6 @@ void PrepopulateGenericHandleCache(DictionaryLayout *pDictionaryLayout,
MethodDesc *pMD,
MethodTable *pMT)
{
#ifdef FEATURE_CORECLR
// Disable this function in CoreCLR to work around https://github.com/dotnet/corefx/issues/12412.
LIMITED_METHOD_CONTRACT;
#else
CONTRACTL {
THROWS;
GC_TRIGGERS;
Expand All @@ -1772,7 +1768,6 @@ void PrepopulateGenericHandleCache(DictionaryLayout *pDictionaryLayout,
}
pOverflows = pOverflows->GetNextLayout();
}
#endif // FEATURE_CORECLR
}

#ifdef FEATURE_PREJIT
Expand Down
Loading

0 comments on commit e678512

Please sign in to comment.