From b4a5eb4923b5b9469dc31111d57cb03aeda9fa2f Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Sat, 9 Mar 2024 23:18:51 -0800 Subject: [PATCH] Cleanup ifdefs - Delete unused defines - Fix logic around funclet related ifdefs in a few places --- .../System.Private.CoreLib.csproj | 12 ++++++------ src/coreclr/clr.featuredefines.props | 18 ------------------ src/coreclr/clrdefinitions.cmake | 3 --- src/coreclr/debug/ee/debugger.h | 2 -- src/coreclr/inc/clrnt.h | 3 --- src/coreclr/inc/daccess.h | 3 +-- src/coreclr/unwinder/i386/unwinder.cpp | 5 +---- src/coreclr/vm/.vscode/c_cpp_properties.json | 1 - src/coreclr/vm/codeman.h | 13 ++++++------- src/coreclr/vm/eetwain.cpp | 3 +-- src/coreclr/vm/excep.cpp | 17 +++++------------ src/coreclr/vm/excep.h | 4 ++-- src/coreclr/vm/exinfo.cpp | 4 ++-- src/coreclr/vm/exinfo.h | 4 +--- src/coreclr/vm/i386/asmconstants.h | 2 -- src/coreclr/vm/i386/jithelp.asm | 4 ++++ src/coreclr/vm/rtlfunctions.cpp | 11 +++++------ src/coreclr/vm/rtlfunctions.h | 6 +++--- src/coreclr/vm/threads.h | 2 -- 19 files changed, 37 insertions(+), 80 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj index 8478d5f597c01b..cf303a8f0f6aef 100644 --- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -206,12 +206,12 @@ - - - - - - + + + + + + diff --git a/src/coreclr/clr.featuredefines.props b/src/coreclr/clr.featuredefines.props index dccd5d0f150c14..7905f8a573d738 100644 --- a/src/coreclr/clr.featuredefines.props +++ b/src/coreclr/clr.featuredefines.props @@ -1,37 +1,26 @@ true - true true true true true - true true true - true true - true - true - true true true true - true true true true - true - true - true - true @@ -45,23 +34,16 @@ $(DefineConstants);FEATURE_ARRAYSTUB_AS_IL $(DefineConstants);FEATURE_MULTICASTSTUB_AS_IL - $(DefineConstants);FEATURE_INSTANTIATINGSTUB_AS_IL - $(DefineConstants);FEATURE_STUBS_AS_IL - $(DefineConstants);FEATURE_COLLECTIBLE_ALC $(DefineConstants);FEATURE_COMWRAPPERS $(DefineConstants);FEATURE_COMINTEROP $(DefineConstants);FEATURE_COMINTEROP_APARTMENT_SUPPORT $(DefineConstants);FEATURE_OBJCMARSHAL $(DefineConstants);FEATURE_PERFTRACING $(DefineConstants);FEATURE_EVENTSOURCE_XPLAT - $(DefineConstants);FEATURE_WIN32_REGISTRY $(DefineConstants);FEATURE_TYPEEQUIVALENCE - $(DefineConstants);FEATURE_BASICFREEZE - $(DefineConstants);FEATURE_PORTABLE_SHUFFLE_THUNKS $(DefineConstants);FEATURE_ICASTABLE $(DefineConstants);FEATURE_EH_FUNCLETS $(DefineConstants);PROFILING_SUPPORTED - $(DefineConstants);FEATURE_PROFAPI_ATTACH_DETACH diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index 2097ef5360ef03..2ffcfb00c0c05e 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -203,9 +203,6 @@ if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGE add_definitions(-DFEATURE_MANUALLY_MANAGED_CARD_BUNDLES) endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_LOONGARCH64 OR CLR_CMAKE_TARGET_ARCH_RISCV64) -if(NOT CLR_CMAKE_TARGET_UNIX) - add_definitions(-DFEATURE_WIN32_REGISTRY) -endif(NOT CLR_CMAKE_TARGET_UNIX) add_definitions(-D_SECURE_SCL=0) add_definitions(-DUNICODE) add_definitions(-D_UNICODE) diff --git a/src/coreclr/debug/ee/debugger.h b/src/coreclr/debug/ee/debugger.h index ac2a3218f73569..2b8573e31b3656 100644 --- a/src/coreclr/debug/ee/debugger.h +++ b/src/coreclr/debug/ee/debugger.h @@ -3892,8 +3892,6 @@ HANDLE OpenWin32EventOrThrow( // Returns true if the specified IL offset has a special meaning (eg. prolog, etc.) bool DbgIsSpecialILOffset(DWORD offset); -#if !defined(TARGET_X86) void FixupDispatcherContext(T_DISPATCHER_CONTEXT* pDispatcherContext, T_CONTEXT* pContext, PEXCEPTION_ROUTINE pUnwindPersonalityRoutine = NULL); -#endif #endif /* DEBUGGER_H_ */ diff --git a/src/coreclr/inc/clrnt.h b/src/coreclr/inc/clrnt.h index 13737538628049..fb7d8102545625 100644 --- a/src/coreclr/inc/clrnt.h +++ b/src/coreclr/inc/clrnt.h @@ -223,10 +223,7 @@ RtlpGetFunctionEndAddress ( #define RUNTIME_FUNCTION__SetUnwindInfoAddress(prf, addr) do { (prf)->UnwindData = (addr); } while(0) #ifdef HOST_X86 -EXTERN_C -NTSYSAPI PEXCEPTION_ROUTINE -NTAPI RtlVirtualUnwind ( _In_ DWORD HandlerType, _In_ DWORD ImageBase, diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index ce5dcb8916dd06..fcd5f5bbf1ff18 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -806,7 +806,6 @@ struct COR_ILMETHOD* DacGetIlMethod(TADDR methAddr); struct _UNWIND_INFO * DacGetUnwindInfo(TADDR taUnwindInfo); // virtually unwind a CONTEXT out-of-process -struct _KNONVOLATILE_CONTEXT_POINTERS; BOOL DacUnwindStackFrame(T_CONTEXT * pContext, T_KNONVOLATILE_CONTEXT_POINTERS* pContextPointers); #endif // FEATURE_EH_FUNCLETS @@ -2433,7 +2432,7 @@ typedef DPTR(IMAGE_TLS_DIRECTORY) PTR_IMAGE_TLS_DIRECTORY; #endif #ifndef NATIVEAOT -#if defined(TARGET_X86) && defined(TARGET_UNIX) +#if defined(TARGET_X86) && defined(FEATURE_EH_FUNCLETS) typedef DPTR(struct _UNWIND_INFO) PTR_UNWIND_INFO; #endif diff --git a/src/coreclr/unwinder/i386/unwinder.cpp b/src/coreclr/unwinder/i386/unwinder.cpp index 57d1268a129a0f..d8e7e7355681fa 100644 --- a/src/coreclr/unwinder/i386/unwinder.cpp +++ b/src/coreclr/unwinder/i386/unwinder.cpp @@ -37,7 +37,7 @@ BOOL OOPStackUnwinderX86::Unwind(T_CONTEXT* pContextRecord, T_KNONVOLATILE_CONTE dac_cast(gcInfoToken.Info) + hdrInfoSize, PTR_CBYTE(codeInfo.GetJitManager()->GetFuncletStartAddress(&codeInfo)), codeInfo.IsFunclet(), - UpdateAllRegs)) + true)) { return FALSE; } @@ -193,10 +193,7 @@ BOOL DacUnwindStackFrame(T_CONTEXT* pContextRecord, T_KNONVOLATILE_CONTEXT_POINT // language specific exception handler is returned. Otherwise, NULL is // returned. // -EXTERN_C -NTSYSAPI PEXCEPTION_ROUTINE -NTAPI RtlVirtualUnwind ( _In_ DWORD HandlerType, _In_ DWORD ImageBase, diff --git a/src/coreclr/vm/.vscode/c_cpp_properties.json b/src/coreclr/vm/.vscode/c_cpp_properties.json index a1c7e61d179b48..d8abc20bf0bcbf 100644 --- a/src/coreclr/vm/.vscode/c_cpp_properties.json +++ b/src/coreclr/vm/.vscode/c_cpp_properties.json @@ -71,7 +71,6 @@ "FEATURE_USE_ASM_GC_WRITE_BARRIERS", "FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP", "FEATURE_UTF8STRING=1", - "FEATURE_WIN32_REGISTRY", "TARGET_WINDOWS=1", "PROFILING_SUPPORTED_DATA", "UNICODE", diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 6fe87885da111f..9adec20c01e8cd 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -2619,21 +2619,20 @@ class EECodeInfo PTR_RUNTIME_FUNCTION GetFunctionEntry(); BOOL IsFunclet() { WRAPPER_NO_CONTRACT; return GetJitManager()->IsFunclet(this); } EECodeInfo GetMainFunctionInfo(); - ULONG GetFixedStackSize(); - -#if defined(TARGET_AMD64) - BOOL HasFrameRegister(); -#endif // TARGET_AMD64 +#endif // FEATURE_EH_FUNCLETS -#else // FEATURE_EH_FUNCLETS +#if defined(TARGET_X86) ULONG GetFixedStackSize() { WRAPPER_NO_CONTRACT; return GetCodeManager()->GetFrameSize(GetGCInfoToken()); } -#endif // FEATURE_EH_FUNCLETS +#endif // TARGET_X86 #if defined(TARGET_AMD64) + BOOL HasFrameRegister(); + ULONG GetFixedStackSize(); + void GetOffsetsFromUnwindInfo(ULONG* pRSPOffset, ULONG* pRBPOffset); ULONG GetFrameOffsetFromUnwindInfo(); #if defined(_DEBUG) && defined(HAVE_GCCOVER) diff --git a/src/coreclr/vm/eetwain.cpp b/src/coreclr/vm/eetwain.cpp index 323dec316a8a83..545bdf7f721025 100644 --- a/src/coreclr/vm/eetwain.cpp +++ b/src/coreclr/vm/eetwain.cpp @@ -1650,7 +1650,6 @@ OBJECTREF EECodeManager::GetInstance( PREGDISPLAY pContext, hdrInfo info; unsigned stackDepth; TADDR taArgBase; - unsigned count; /* Extract the necessary information from the info block header */ @@ -1709,7 +1708,7 @@ OBJECTREF EECodeManager::GetInstance( PREGDISPLAY pContext, /* The 'this' pointer can never be located in the untracked table */ /* as we only allow pinned and byrefs in the untracked table */ - count = info.untrackedCnt; + unsigned count = info.untrackedCnt; while (count-- > 0) { fastSkipSigned(table); diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index 6e82507cfb7bfb..0eec20394de4ae 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -8894,11 +8894,9 @@ BOOL IsThrowableThreadAbortException(OBJECTREF oThrowable) #if defined(FEATURE_EH_FUNCLETS) PTR_ExceptionTrackerBase GetEHTrackerForPreallocatedException(OBJECTREF oPreAllocThrowable, PTR_ExceptionTrackerBase pStartingEHTracker) -#elif TARGET_X86 +#else PTR_ExInfo GetEHTrackerForPreallocatedException(OBJECTREF oPreAllocThrowable, PTR_ExInfo pStartingEHTracker) -#else -#error Unsupported platform #endif { CONTRACTL @@ -8916,11 +8914,9 @@ PTR_ExInfo GetEHTrackerForPreallocatedException(OBJECTREF oPreAllocThrowable, // Get the reference to the current exception tracker #if defined(FEATURE_EH_FUNCLETS) PTR_ExceptionTrackerBase pEHTracker = (pStartingEHTracker != NULL) ? pStartingEHTracker : GetThread()->GetExceptionState()->GetCurrentExceptionTracker(); -#elif TARGET_X86 +#else PTR_ExInfo pEHTracker = (pStartingEHTracker != NULL) ? pStartingEHTracker : GetThread()->GetExceptionState()->GetCurrentExceptionTracker(); -#else // !(HOST_64BIT || TARGET_X86) -#error Unsupported platform -#endif // HOST_64BIT +#endif BOOL fFoundTracker = FALSE; @@ -8995,13 +8991,10 @@ PTR_EHWatsonBucketTracker GetWatsonBucketTrackerForPreallocatedException(OBJECTR #if defined(FEATURE_EH_FUNCLETS) PTR_ExceptionTrackerBase pEHTracker = NULL; PTR_ExceptionTrackerBase pPreviousEHTracker = NULL; - -#elif TARGET_X86 +#else PTR_ExInfo pEHTracker = NULL; PTR_ExInfo pPreviousEHTracker = NULL; -#else // !(HOST_64BIT || TARGET_X86) -#error Unsupported platform -#endif // HOST_64BIT +#endif if (fStartSearchFromPreviousTracker) { diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h index 7f267ba2e455f6..0d0217607d9d83 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -520,9 +520,9 @@ EXCEPTION_HANDLER_DECL(COMPlusFrameHandlerRevCom); // Pop off any SEH handlers we have registered below pTargetSP VOID __cdecl PopSEHRecords(LPVOID pTargetSP); -#if defined(TARGET_X86) && defined(DEBUGGING_SUPPORTED) +#ifdef DEBUGGING_SUPPORTED VOID UnwindExceptionTrackerAndResumeInInterceptionFrame(ExInfo* pExInfo, EHContext* context); -#endif // TARGET_X86 && DEBUGGING_SUPPORTED +#endif // DEBUGGING_SUPPORTED BOOL PopNestedExceptionRecords(LPVOID pTargetSP, BOOL bCheckForUnknownHandlers = FALSE); VOID PopNestedExceptionRecords(LPVOID pTargetSP, T_CONTEXT *pCtx, void *pSEH); diff --git a/src/coreclr/vm/exinfo.cpp b/src/coreclr/vm/exinfo.cpp index 83cd50b2fcef07..7728d9bed3fef0 100644 --- a/src/coreclr/vm/exinfo.cpp +++ b/src/coreclr/vm/exinfo.cpp @@ -121,10 +121,10 @@ void ExInfo::Init() m_pTopMostHandlerDuringSO = NULL; -#if defined(TARGET_X86) && defined(DEBUGGING_SUPPORTED) +#ifdef DEBUGGING_SUPPORTED m_InterceptionContext.Init(); m_ValidInterceptionContext = FALSE; -#endif //TARGET_X86 && DEBUGGING_SUPPORTED +#endif // DEBUGGING_SUPPORTED } ExInfo::ExInfo() diff --git a/src/coreclr/vm/exinfo.h b/src/coreclr/vm/exinfo.h index ed88fecb7dd6b9..db6851fc4d5a16 100644 --- a/src/coreclr/vm/exinfo.h +++ b/src/coreclr/vm/exinfo.h @@ -136,7 +136,7 @@ class ExInfo EHClauseInfo m_EHClauseInfo; ExceptionFlags m_ExceptionFlags; -#if defined(TARGET_X86) && defined(DEBUGGING_SUPPORTED) +#ifdef DEBUGGING_SUPPORTED EHContext m_InterceptionContext; BOOL m_ValidInterceptionContext; #endif @@ -155,9 +155,7 @@ class ExInfo ExInfo& operator=(const ExInfo &from); }; -#if defined(TARGET_X86) PTR_ExInfo GetEHTrackerForPreallocatedException(OBJECTREF oPreAllocThrowable, PTR_ExInfo pStartingEHTracker); -#endif // TARGET_X86 #else // !FEATURE_EH_FUNCLETS diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 7de14a6c063184..876925dbb94413 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -231,8 +231,6 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__FrameHandlerExRecord__m_pEntryFrame == offsetof( #define STACK_OVERWRITE_BARRIER_VALUE 0xabcdefab #endif -#define SIZEOF_FrameHandlerExRecordWithBarrier 0x5c -ASMCONSTANTS_C_ASSERT(SIZEOF_FrameHandlerExRecordWithBarrier == sizeof(FrameHandlerExRecordWithBarrier)) #endif diff --git a/src/coreclr/vm/i386/jithelp.asm b/src/coreclr/vm/i386/jithelp.asm index 5f6890b8312e03..0faf7cde0e0b26 100644 --- a/src/coreclr/vm/i386/jithelp.asm +++ b/src/coreclr/vm/i386/jithelp.asm @@ -75,7 +75,9 @@ EXTERN g_GCShadowEnd:DWORD INVALIDGCVALUE equ 0CCCCCCCDh endif +ifndef FEATURE_EH_FUNCLETS EXTERN _COMPlusEndCatch@20:PROC +endif .686P .XMM @@ -1298,6 +1300,7 @@ ret _JIT_PatchedCodeEnd@0 endp +ifndef FEATURE_EH_FUNCLETS ; Note that the debugger skips this entirely when doing SetIP, ; since COMPlusCheckForAbort should always return 0. Excep.cpp:LeaveCatch ; asserts that to be true. If this ends up doing more work, then the @@ -1325,6 +1328,7 @@ JIT_EndCatch PROC stdcall public jmp edx ; eip = new eip JIT_EndCatch ENDP +endif ; The following helper will access ("probe") a word on each page of the stack ; starting with the page right beneath esp down to the one pointed to by eax. diff --git a/src/coreclr/vm/rtlfunctions.cpp b/src/coreclr/vm/rtlfunctions.cpp index f3f80338f3f8ec..0e77e31a02d162 100644 --- a/src/coreclr/vm/rtlfunctions.cpp +++ b/src/coreclr/vm/rtlfunctions.cpp @@ -16,7 +16,7 @@ #include "rtlfunctions.h" -#ifdef TARGET_AMD64 +#ifdef HOST_AMD64 RtlVirtualUnwindFn* RtlVirtualUnwind_Unsafe = NULL; @@ -45,7 +45,7 @@ HRESULT EnsureRtlFunctions() return S_OK; } -#else // TARGET_AMD64 +#else // HOST_AMD64 HRESULT EnsureRtlFunctions() { @@ -53,9 +53,9 @@ HRESULT EnsureRtlFunctions() return S_OK; } -#endif // TARGET_AMD64 +#endif // HOST_AMD64 -#if defined(FEATURE_EH_FUNCLETS) +#ifndef HOST_X86 VOID InstallEEFunctionTable ( PVOID pvTableID, @@ -127,5 +127,4 @@ VOID InstallEEFunctionTable ( } } -#endif // FEATURE_EH_FUNCLETS - +#endif // HOST_X86 diff --git a/src/coreclr/vm/rtlfunctions.h b/src/coreclr/vm/rtlfunctions.h index 6d9ff9689ca4fd..ef0f64cba9dbdf 100644 --- a/src/coreclr/vm/rtlfunctions.h +++ b/src/coreclr/vm/rtlfunctions.h @@ -49,7 +49,7 @@ PVOID DecodeDynamicFunctionTableContext (PVOID pvContext) #endif // FEATURE_EH_FUNCLETS -#if defined(FEATURE_EH_FUNCLETS) && !defined(DACCESS_COMPILE) && !defined(TARGET_UNIX) +#if !defined(DACCESS_COMPILE) && defined(HOST_WINDOWS) && !defined(HOST_X86) // Wrapper for RtlInstallFunctionTableCallback. VOID InstallEEFunctionTable( @@ -67,12 +67,12 @@ VOID DeleteEEFunctionTable( RtlDeleteFunctionTable((PT_RUNTIME_FUNCTION)((ULONG64)pvTableID | 3)); } -#else // FEATURE_EH_FUNCLETS && !DACCESS_COMPILE && !TARGET_UNIX +#else #define InstallEEFunctionTable(pvTableID, pvStartRange, cbRange, pfnGetRuntimeFunctionCallback, pvContext, TableType) do { } while (0) #define DeleteEEFunctionTable(pvTableID) do { } while (0) -#endif // FEATURE_EH_FUNCLETS && !DACCESS_COMPILE && !TARGET_UNIX +#endif #endif // !__RTLFUNCTIONS_H__ diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index f146a97cfecc54..9d304e2662894d 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -6222,9 +6222,7 @@ class StackWalkerWalkingThreadHolder #if defined(TARGET_WINDOWS) && defined(TARGET_AMD64) EXTERN_C void STDCALL ClrRestoreNonvolatileContextWorker(PCONTEXT ContextRecord, DWORD64 ssp); #endif -#if !(defined(TARGET_WINDOWS) && defined(TARGET_X86)) void ClrRestoreNonvolatileContext(PCONTEXT ContextRecord); -#endif #endif // DACCESS_COMPILE #endif //__threads_h__