diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index 7f5964f99295f8..bd0b5f72bd7fb9 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -505,6 +505,10 @@ if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) set(CMAKE_POSITION_INDEPENDENT_CODE ON) else() if(CLR_CMAKE_RUNTIME_CORECLR) + if(NOT CLR_CROSS_COMPONENTS_BUILD) + # CoreCLR does not use throwing exception object destructors. + add_compile_options($<$:-fassume-nothrow-exception-dtor>) + endif() if(CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CROSS_COMPONENTS_BUILD) add_link_options(-fwasm-exceptions) add_link_options(-sWASM_LEGACY_EXCEPTIONS=0) diff --git a/src/coreclr/binder/assemblyname.cpp b/src/coreclr/binder/assemblyname.cpp index 34dc9f423ddc80..e1c43c81ffdbf6 100644 --- a/src/coreclr/binder/assemblyname.cpp +++ b/src/coreclr/binder/assemblyname.cpp @@ -186,7 +186,7 @@ namespace BINDER_SPACE return InterlockedIncrement(&m_cRef); } - ULONG AssemblyName::Release() + ULONG AssemblyName::Release() noexcept { ULONG ulRef = InterlockedDecrement(&m_cRef); if (ulRef == 0) diff --git a/src/coreclr/binder/inc/assemblyname.hpp b/src/coreclr/binder/inc/assemblyname.hpp index 40bb065e4aa12f..bd87628cf91aab 100644 --- a/src/coreclr/binder/inc/assemblyname.hpp +++ b/src/coreclr/binder/inc/assemblyname.hpp @@ -44,7 +44,7 @@ namespace BINDER_SPACE HRESULT Init(const AssemblyNameData &data); ULONG AddRef(); - ULONG Release(); + ULONG Release() noexcept; // Getters/Setters inline const SString &GetSimpleName(); diff --git a/src/coreclr/debug/daccess/reimpl.cpp b/src/coreclr/debug/daccess/reimpl.cpp index fe6f1adddc786e..2fc868f09350f9 100644 --- a/src/coreclr/debug/daccess/reimpl.cpp +++ b/src/coreclr/debug/daccess/reimpl.cpp @@ -63,7 +63,7 @@ DacGetThread(ULONG32 osThread) return NULL; } -Thread* GetThread() +Thread* GetThread() noexcept { // In dac mode it's unlikely that the thread calling dac // is actually the same "current thread" that the runtime cares @@ -75,7 +75,7 @@ Thread* GetThread() return NULL; } -Thread* GetThreadNULLOk() +Thread* GetThreadNULLOk() noexcept { return GetThread(); } diff --git a/src/coreclr/gc/env/volatile.h b/src/coreclr/gc/env/volatile.h index 0b320ebec510f6..23617196359d06 100644 --- a/src/coreclr/gc/env/volatile.h +++ b/src/coreclr/gc/env/volatile.h @@ -190,6 +190,11 @@ T VolatileLoad(T const * pt) template inline T VolatileLoadWithoutBarrier(T const * pt) +#ifndef DACCESS_COMPILE + noexcept(noexcept(T(*(T volatile const*)pt))) +#else + noexcept(noexcept(T(*pt))) +#endif { #ifndef DACCESS_COMPILE T val = *(T volatile const *)pt; @@ -268,6 +273,11 @@ void VolatileStore(T* pt, T val) template inline void VolatileStoreWithoutBarrier(T* pt, T val) +#ifndef DACCESS_COMPILE + noexcept(noexcept(*(T volatile*)pt = val)) +#else + noexcept(noexcept(*pt = val)) +#endif { #ifndef DACCESS_COMPILE *(T volatile *)pt = val; @@ -330,6 +340,9 @@ class Volatile // Loads the value of the volatile variable atomically without erecting the memory barrier. // inline T LoadWithoutBarrier() const +#ifndef DACCESS_COMPILE + noexcept(noexcept(T((volatile T&)m_val))) +#endif { return ((volatile T &)m_val); } @@ -348,6 +361,9 @@ class Volatile // Stores a new value to the volatile variable atomically without erecting the memory barrier. // inline void StoreWithoutBarrier(const T& val) const +#ifndef DACCESS_COMPILE + noexcept(noexcept(((volatile T&)m_val) = val)) +#endif { ((volatile T &)m_val) = val; } diff --git a/src/coreclr/inc/arraylist.h b/src/coreclr/inc/arraylist.h index 9e2a360e210cfe..ee8d5c5b59d5d0 100644 --- a/src/coreclr/inc/arraylist.h +++ b/src/coreclr/inc/arraylist.h @@ -98,7 +98,7 @@ class ArrayListBase enum { NOT_FOUND = -1 }; DWORD FindElement(DWORD start, PTR_VOID element) const; - void Clear(); + void Clear() noexcept; void Init() { @@ -109,7 +109,7 @@ class ArrayListBase m_firstBlock.m_blockSize = ARRAY_BLOCK_SIZE_START; } - void Destroy() + void Destroy() noexcept { WRAPPER_NO_CONTRACT; Clear(); diff --git a/src/coreclr/inc/clrconfig.h b/src/coreclr/inc/clrconfig.h index 213f231cffda3e..0b8d8a1889025c 100644 --- a/src/coreclr/inc/clrconfig.h +++ b/src/coreclr/inc/clrconfig.h @@ -134,7 +134,7 @@ class CLRConfig static BOOL IsConfigOptionSpecified(LPCWSTR name); // Free a string returned by GetConfigValue - static void FreeConfigString(_In_ _In_z_ LPWSTR name); + static void FreeConfigString(_In_ _In_z_ LPWSTR name) noexcept; // Initialize the configuration. static void Initialize(); @@ -154,7 +154,7 @@ struct CLRConfigStringTraits final { using Type = LPWSTR; static constexpr Type Default() { return NULL; } - static void Free(Type value) { CLRConfig::FreeConfigString(value); } + static void Free(Type value) noexcept { CLRConfig::FreeConfigString(value); } }; using CLRConfigStringHolder = LifetimeHolder; diff --git a/src/coreclr/inc/clrhost.h b/src/coreclr/inc/clrhost.h index c6f94eeeac6028..6483841d49bc48 100644 --- a/src/coreclr/inc/clrhost.h +++ b/src/coreclr/inc/clrhost.h @@ -30,12 +30,12 @@ using std::nothrow; struct PreserveLastErrorHolder { - PreserveLastErrorHolder() + PreserveLastErrorHolder() noexcept { m_dwLastError = ::GetLastError(); } - ~PreserveLastErrorHolder() + ~PreserveLastErrorHolder() noexcept { ::SetLastError(m_dwLastError); } @@ -78,7 +78,7 @@ HANDLE ClrGetProcessExecutableHeap(); CRITSEC_COOKIE ClrCreateCriticalSection(CrstType type, CrstFlags flags); void ClrDeleteCriticalSection(CRITSEC_COOKIE cookie); void ClrEnterCriticalSection(CRITSEC_COOKIE cookie); -void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie); +void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) noexcept; // Rather than use the above APIs directly, it is recommended that holder classes // be used. This guarantees that the locks will be vacated when the scope is popped, @@ -150,12 +150,12 @@ extern thread_local size_t t_CantStopCount; // For debugging, we can track arbitrary Can't-Stop regions. // In V1.0, this was on the Thread object, but we need to track this for threads w/o a Thread object. -FORCEINLINE void IncCantStopCount() +FORCEINLINE void IncCantStopCount() noexcept { t_CantStopCount++; } -FORCEINLINE void DecCantStopCount() +FORCEINLINE void DecCantStopCount() noexcept { t_CantStopCount--; } diff --git a/src/coreclr/inc/ex.h b/src/coreclr/inc/ex.h index 48600212713ac9..40c5d1d5860f1d 100644 --- a/src/coreclr/inc/ex.h +++ b/src/coreclr/inc/ex.h @@ -184,7 +184,7 @@ class Exception public: Exception() {LIMITED_METHOD_DAC_CONTRACT; m_innerException = NULL;} - virtual ~Exception() {LIMITED_METHOD_DAC_CONTRACT; if (m_innerException != NULL) Exception::Delete(m_innerException); } + virtual ~Exception() noexcept {LIMITED_METHOD_DAC_CONTRACT; if (m_innerException != NULL) Exception::Delete(m_innerException); } #ifdef DACCESS_COMPILE void * operator new(size_t size); void operator delete(void* ptr); @@ -232,7 +232,7 @@ class Exception HandlerState(); - void CleanupTry(); + void CleanupTry() noexcept; void SetupCatch(INDEBUG_COMMA(_In_z_ const char * szFile) int lineNum); void SucceedCatch(); @@ -258,10 +258,10 @@ class Exception // Preallocated exceptions: If there is a preallocated instance of some // subclass of Exception, override this function and return a correct // value. The default implementation returns constant FALSE - virtual BOOL IsPreallocatedException(); + virtual BOOL IsPreallocatedException() noexcept; BOOL IsPreallocatedOOMException(); - static void Delete(Exception* pvMemory); + static void Delete(Exception* pvMemory) noexcept; protected: @@ -285,7 +285,7 @@ struct ExceptionTraits final { using Type = Exception*; static constexpr Type Default() { return NULL; } - static void Free(Type value) + static void Free(Type value) noexcept { STATIC_CONTRACT_WRAPPER; Exception::Delete(value); @@ -523,7 +523,7 @@ class OutOfMemoryException : public Exception virtual Exception *Clone(); - virtual BOOL IsPreallocatedException() { return bIsPreallocated; } + virtual BOOL IsPreallocatedException() noexcept { return bIsPreallocated; } }; template @@ -546,7 +546,7 @@ class CAutoTryCleanup #endif } - DEBUG_NOINLINE ~CAutoTryCleanup() + DEBUG_NOINLINE ~CAutoTryCleanup() noexcept { WRAPPER_NO_CONTRACT; @@ -1116,7 +1116,7 @@ inline Exception::HandlerState::HandlerState() #endif } -inline void Exception::HandlerState::CleanupTry() +inline void Exception::HandlerState::CleanupTry() noexcept { LIMITED_METHOD_DAC_CONTRACT; } diff --git a/src/coreclr/inc/executableallocator.h b/src/coreclr/inc/executableallocator.h index 93c4758956f579..591ec28bf08e66 100644 --- a/src/coreclr/inc/executableallocator.h +++ b/src/coreclr/inc/executableallocator.h @@ -183,7 +183,7 @@ class ExecutableAllocator static bool IsDoubleMappingEnabled(); // Release memory allocated via DoubleMapping for either templates or normal double mapped data - void ReleaseWorker(void* pRX, bool releaseTemplate); + void ReleaseWorker(void* pRX, bool releaseTemplate) noexcept; // Initialize the allocator instance bool Initialize(); @@ -211,7 +211,7 @@ class ExecutableAllocator #endif // Return the ExecuteAllocator singleton instance - static ExecutableAllocator* Instance(); + static ExecutableAllocator* Instance() noexcept; // Initialize the static members of the Executable allocator and allocate // and initialize the instance of it. @@ -258,13 +258,13 @@ class ExecutableAllocator // Release the executable memory block starting at the passed in address that was allocated // by one of the ReserveXXX methods. - void Release(void* pRX); + void Release(void* pRX) noexcept; // Map the specified block of executable memory as RW void* MapRW(void* pRX, size_t size, CacheableMapping cacheMapping); // Unmap the RW mapping at the specified address - void UnmapRW(void* pRW); + void UnmapRW(void* pRW) noexcept; // Allocate thunks from a template. pTemplate is the return value from CreateTemplate void* AllocateThunksFromTemplate(void *pTemplate, size_t templateSize, void (*dataPageGenerator)(uint8_t* pageBase, size_t size)); @@ -298,7 +298,7 @@ class ExecutableWriterHolder other.m_addressRW = NULL; } - void Unmap() + void Unmap() noexcept { #if defined(HOST_APPLE) && defined(HOST_ARM64) && !defined(DACCESS_COMPILE) if (m_addressRX != NULL) @@ -344,7 +344,7 @@ class ExecutableWriterHolder #endif } - ~ExecutableWriterHolder() + ~ExecutableWriterHolder() noexcept { Unmap(); } diff --git a/src/coreclr/inc/holder.h b/src/coreclr/inc/holder.h index 22cd4c29ee1747..d05899b07cf199 100644 --- a/src/coreclr/inc/holder.h +++ b/src/coreclr/inc/holder.h @@ -996,7 +996,7 @@ struct ReleaseHolderTraits final { using Type = TYPE*; static constexpr Type Default() { return NULL; } - static void Free(Type value) + static void Free(Type value) noexcept { CONTRACTL { @@ -1021,7 +1021,7 @@ struct HandleTraits final { using Type = HANDLE; static Type Default() { return INVALID_HANDLE_VALUE; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; if (h != NULL && h != Default()) @@ -1034,7 +1034,7 @@ struct MapViewTraits final { using Type = void*; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; if (h != NULL) @@ -1049,7 +1049,7 @@ struct LocalAllocTraits final { using Type = T; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; #ifdef HOST_WINDOWS @@ -1068,7 +1068,7 @@ struct HModuleTraits final { using Type = HMODULE; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; if (h != NULL) @@ -1092,7 +1092,7 @@ struct ResetPointerTraits final { using Type = T*; static constexpr Type Default() { return NULL; } - static void Free(Type p) + static void Free(Type p) noexcept { STATIC_CONTRACT_WRAPPER; if (p == NULL) @@ -1121,7 +1121,7 @@ struct CoTaskMemTraits final { using Type = T*; static constexpr Type Default() { return NULL; } - static void Free(Type value) + static void Free(Type value) noexcept { STATIC_CONTRACT_WRAPPER; if (value != NULL) @@ -1176,7 +1176,7 @@ struct HKEYTraits final { using Type = HKEY; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; if (h != NULL) @@ -1192,7 +1192,7 @@ struct BSTRTraits final { using Type = BSTR; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; if (h != NULL) diff --git a/src/coreclr/inc/metadata.h b/src/coreclr/inc/metadata.h index 0ccd84eca08ab9..faac0dada8e582 100644 --- a/src/coreclr/inc/metadata.h +++ b/src/coreclr/inc/metadata.h @@ -151,7 +151,7 @@ struct HENUMInternal // This will only clear the content of enum and will not free the memory of enum static void ClearEnum( - HENUMInternal *pmdEnum); + HENUMInternal *pmdEnum) noexcept; // create a HENUMInternal. This will allocate the memory __checkReturn @@ -293,6 +293,8 @@ EXTERN_GUID(IID_IMDInternalImport, 0x1b119f60, 0xc507, 0x4024, 0xbb, 0x39, 0xf8, #define INTERFACE IMDInternalImport DECLARE_INTERFACE_(IMDInternalImport, IUnknown) { + STDMETHOD_(ULONG, Release)() noexcept PURE; + //***************************************************************************** // return the count of entries of a given kind in a scope // For example, pass in mdtMethodDef will tell you how many MethodDef @@ -403,7 +405,7 @@ DECLARE_INTERFACE_(IMDInternalImport, IUnknown) } // MDInternalRW::EnumReset void EnumClose( - HENUMInternal *phEnum) // [IN] the enumerator to be closed + HENUMInternal *phEnum) noexcept // [IN] the enumerator to be closed { _ASSERTE( phEnum->m_EnumType == MDSimpleEnum || phEnum->m_EnumType == MDDynamicArrayEnum); diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index a22660bc037bde..c605175ef7b62d 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -1046,7 +1046,7 @@ class CStructArray LIMITED_METHOD_CONTRACT; return (m_iCount); } - void Clear(); + void Clear() noexcept; void ClearCount() { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/inc/volatile.h b/src/coreclr/inc/volatile.h index 7cfd30c4d1ca65..4a51d872afe757 100644 --- a/src/coreclr/inc/volatile.h +++ b/src/coreclr/inc/volatile.h @@ -211,6 +211,11 @@ T VolatileLoad(T const * pt) template inline T VolatileLoadWithoutBarrier(T const * pt) +#ifndef DACCESS_COMPILE + noexcept(noexcept(T(*(T volatile const*)pt))) +#else + noexcept(noexcept(T(*pt))) +#endif { STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; @@ -294,6 +299,11 @@ void VolatileStore(T* pt, T val) template inline void VolatileStoreWithoutBarrier(T* pt, T val) +#ifndef DACCESS_COMPILE + noexcept(noexcept(*(T volatile*)pt = val)) +#else + noexcept(noexcept(*pt = val)) +#endif { STATIC_CONTRACT_SUPPORTS_DAC_HOST_ONLY; @@ -385,6 +395,9 @@ class Volatile // Loads the value of the volatile variable atomically without erecting the memory barrier. // inline T LoadWithoutBarrier() const +#ifndef DACCESS_COMPILE + noexcept(noexcept(T((volatile T&)m_val))) +#endif { STATIC_CONTRACT_SUPPORTS_DAC; return ((volatile T &)m_val); @@ -405,6 +418,9 @@ class Volatile // Stores a new value to the volatile variable atomically without erecting the memory barrier. // inline void StoreWithoutBarrier(const T& val) const +#ifndef DACCESS_COMPILE + noexcept(noexcept(((volatile T&)m_val) = val)) +#endif { STATIC_CONTRACT_SUPPORTS_DAC; ((volatile T &)m_val) = val; diff --git a/src/coreclr/md/enc/mdinternalrw.cpp b/src/coreclr/md/enc/mdinternalrw.cpp index 450c7f18c9dde3..6521994003d025 100644 --- a/src/coreclr/md/enc/mdinternalrw.cpp +++ b/src/coreclr/md/enc/mdinternalrw.cpp @@ -183,7 +183,7 @@ struct MDReleaseHolderTraits final { using Type = TYPE*; static constexpr Type Default() { return NULL; } - static void Free(Type value) + static void Free(Type value) noexcept { STATIC_CONTRACT_WRAPPER; @@ -483,7 +483,7 @@ ULONG MDInternalRW::AddRef() return InterlockedIncrement(&m_cRefs); } // MDInternalRW::AddRef -ULONG MDInternalRW::Release() +ULONG MDInternalRW::Release() noexcept { ULONG cRef; diff --git a/src/coreclr/md/enc/rwutil.cpp b/src/coreclr/md/enc/rwutil.cpp index 20bdb830c91fbb..241f2284531355 100644 --- a/src/coreclr/md/enc/rwutil.cpp +++ b/src/coreclr/md/enc/rwutil.cpp @@ -261,7 +261,7 @@ void HENUMInternal::DestroyEnumIfEmpty( void HENUMInternal::ClearEnum( - HENUMInternal *pmdEnum) + HENUMInternal *pmdEnum) noexcept { if (pmdEnum == NULL) return; diff --git a/src/coreclr/md/inc/mdinternalrw.h b/src/coreclr/md/inc/mdinternalrw.h index e50b04bc1e4310..a34bf3370b019b 100644 --- a/src/coreclr/md/inc/mdinternalrw.h +++ b/src/coreclr/md/inc/mdinternalrw.h @@ -33,7 +33,7 @@ class MDInternalRW : public IMDInternalImportENC, public IMDCommon __checkReturn STDMETHODIMP QueryInterface(REFIID riid, void** ppv); STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); + STDMETHODIMP_(ULONG) Release(void) noexcept; __checkReturn STDMETHODIMP TranslateSigWithScope( diff --git a/src/coreclr/md/inc/stgpool.h b/src/coreclr/md/inc/stgpool.h index 544d1e209a9a71..ba8c6dbac2edd8 100644 --- a/src/coreclr/md/inc/stgpool.h +++ b/src/coreclr/md/inc/stgpool.h @@ -162,7 +162,7 @@ friend class MetaData::BlobHeapRO; //***************************************************************************** // Prepare to shut down or reinitialize. //***************************************************************************** - virtual void Uninit(); + virtual void Uninit() noexcept; //***************************************************************************** // Return the size of the pool. @@ -472,7 +472,7 @@ friend struct ::cdac_data; //***************************************************************************** // Clear out this pool. Cannot use until you call InitNew. //***************************************************************************** - virtual void Uninit(); + virtual void Uninit() noexcept; //***************************************************************************** // Called to copy the pool to writable memory, reset the r/o bit. @@ -787,7 +787,7 @@ class StgStringPool : public StgPool //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** - void Uninit(); + void Uninit() noexcept; //***************************************************************************** // Turn hashing off or on. If you turn hashing on, then any existing data is @@ -943,7 +943,7 @@ class StgGuidPool : public StgPool //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** - void Uninit(); + void Uninit() noexcept; //***************************************************************************** // Add a segment to the chain of segments. @@ -1096,7 +1096,7 @@ class StgBlobPool : public StgPool //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** - void Uninit(); + void Uninit() noexcept; //***************************************************************************** // The blob will be added to the pool. The offset of the blob in the pool diff --git a/src/coreclr/md/runtime/mdinternalro.cpp b/src/coreclr/md/runtime/mdinternalro.cpp index 3d9a388b321aa0..99245bf154b153 100644 --- a/src/coreclr/md/runtime/mdinternalro.cpp +++ b/src/coreclr/md/runtime/mdinternalro.cpp @@ -85,7 +85,7 @@ ULONG MDInternalRO::AddRef() return InterlockedIncrement(&m_cRefs); } // MDInternalRO::AddRef -ULONG MDInternalRO::Release() +ULONG MDInternalRO::Release() noexcept { ULONG cRef = InterlockedDecrement(&m_cRefs); if (cRef == 0) diff --git a/src/coreclr/md/runtime/mdinternalro.h b/src/coreclr/md/runtime/mdinternalro.h index 1df15736f147be..8a6d87b24f6a95 100644 --- a/src/coreclr/md/runtime/mdinternalro.h +++ b/src/coreclr/md/runtime/mdinternalro.h @@ -28,7 +28,7 @@ class MDInternalRO : public IMDInternalImport, IMDCommon __checkReturn STDMETHODIMP QueryInterface(REFIID riid, void** ppv); STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); + STDMETHODIMP_(ULONG) Release(void) noexcept; __checkReturn STDMETHODIMP TranslateSigWithScope( diff --git a/src/coreclr/md/runtime/stgpool.cpp b/src/coreclr/md/runtime/stgpool.cpp index 06fa355b47003f..c7a9b8b8059f6e 100644 --- a/src/coreclr/md/runtime/stgpool.cpp +++ b/src/coreclr/md/runtime/stgpool.cpp @@ -154,7 +154,7 @@ StgPool::TakeOwnershipOfInitMem() //***************************************************************************** // Clear out this pool. Cannot use until you call InitNew. //***************************************************************************** -void StgPool::Uninit() +void StgPool::Uninit() noexcept { CONTRACTL { @@ -832,7 +832,7 @@ StgStringPool::InitOnMem( //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** -void StgStringPool::Uninit() +void StgStringPool::Uninit() noexcept { CONTRACTL { @@ -1190,7 +1190,7 @@ StgGuidPool::InitOnMem( //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** -void StgGuidPool::Uninit() +void StgGuidPool::Uninit() noexcept { CONTRACTL { @@ -1495,7 +1495,7 @@ StgBlobPool::InitOnMem( //***************************************************************************** // Clears the hash table then calls the base class. //***************************************************************************** -void StgBlobPool::Uninit() +void StgBlobPool::Uninit() noexcept { CONTRACTL { diff --git a/src/coreclr/md/runtime/stgpoolreadonly.cpp b/src/coreclr/md/runtime/stgpoolreadonly.cpp index ff648fe2ef0453..8f96a7f14c67a0 100644 --- a/src/coreclr/md/runtime/stgpoolreadonly.cpp +++ b/src/coreclr/md/runtime/stgpoolreadonly.cpp @@ -65,7 +65,7 @@ HRESULT StgPoolReadOnly::InitOnMemReadOnly(// Return code. //***************************************************************************** // Prepare to shut down or reinitialize. //***************************************************************************** -void StgPoolReadOnly::Uninit() +void StgPoolReadOnly::Uninit() noexcept { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 5a727b4a398073..c90d2a23f77b6b 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -2226,7 +2226,7 @@ PALIMPORT BOOL PALAPI UnmapViewOfFile( - IN LPCVOID lpBaseAddress); + IN LPCVOID lpBaseAddress) noexcept; PALIMPORT HMODULE @@ -2631,7 +2631,7 @@ PALIMPORT BOOL PALAPI CloseHandle( - IN OUT HANDLE hObject); + IN OUT HANDLE hObject) noexcept; PALIMPORT VOID @@ -3175,13 +3175,13 @@ FormatMessageW( PALIMPORT DWORD PALAPI -GetLastError(); +GetLastError() noexcept; PALIMPORT VOID PALAPI SetLastError( - IN DWORD dwErrCode); + IN DWORD dwErrCode) noexcept; PALIMPORT VOID @@ -3387,7 +3387,7 @@ VOID PALAPI PAL_FreeExceptionRecords( IN EXCEPTION_RECORD *exceptionRecord, - IN CONTEXT *contextRecord); + IN CONTEXT *contextRecord) noexcept; #define EXCEPTION_CONTINUE_SEARCH 0 #define EXCEPTION_EXECUTE_HANDLER 1 diff --git a/src/coreclr/pal/src/arch/wasm/stubs.cpp b/src/coreclr/pal/src/arch/wasm/stubs.cpp index 5cf3a996ddceae..7fe4c2e7bb4aed 100644 --- a/src/coreclr/pal/src/arch/wasm/stubs.cpp +++ b/src/coreclr/pal/src/arch/wasm/stubs.cpp @@ -251,7 +251,7 @@ struct WasiExceptionRecords }; extern "C" PALIMPORT VOID PALAPI -PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) +PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) noexcept { (void)exceptionRecord; // contextRecord is the start of the combined WasiExceptionRecords allocation. diff --git a/src/coreclr/pal/src/exception/seh-unwind.cpp b/src/coreclr/pal/src/exception/seh-unwind.cpp index 06f31cd95307aa..661e60979bc0d0 100644 --- a/src/coreclr/pal/src/exception/seh-unwind.cpp +++ b/src/coreclr/pal/src/exception/seh-unwind.cpp @@ -703,7 +703,7 @@ AllocateExceptionRecords(EXCEPTION_RECORD** exceptionRecord, CONTEXT** contextRe --*/ VOID PALAPI -PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) +PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) noexcept { // Both records are allocated at once and the allocated memory starts at the contextRecord ExceptionRecords* records = (ExceptionRecords*)contextRecord; diff --git a/src/coreclr/pal/src/handlemgr/handleapi.cpp b/src/coreclr/pal/src/handlemgr/handleapi.cpp index adda2aa2110c1e..fbf9ab4781cdf0 100644 --- a/src/coreclr/pal/src/handlemgr/handleapi.cpp +++ b/src/coreclr/pal/src/handlemgr/handleapi.cpp @@ -229,7 +229,7 @@ not required in the PAL, so we'll always return FALSE. BOOL PALAPI CloseHandle( - IN OUT HANDLE hObject) + IN OUT HANDLE hObject) noexcept { CPalThread *pThread; PAL_ERROR palError; diff --git a/src/coreclr/pal/src/map/map.cpp b/src/coreclr/pal/src/map/map.cpp index 81cc8c1bd88de6..c2256c7afd3a9d 100644 --- a/src/coreclr/pal/src/map/map.cpp +++ b/src/coreclr/pal/src/map/map.cpp @@ -811,7 +811,7 @@ See MSDN doc. BOOL PALAPI UnmapViewOfFile( - IN LPCVOID lpBaseAddress) + IN LPCVOID lpBaseAddress) noexcept { PAL_ERROR palError; CPalThread *pThread; diff --git a/src/coreclr/pal/src/misc/error.cpp b/src/coreclr/pal/src/misc/error.cpp index 6b67bf717d52cb..6714bd275b7de4 100644 --- a/src/coreclr/pal/src/misc/error.cpp +++ b/src/coreclr/pal/src/misc/error.cpp @@ -51,7 +51,7 @@ conditions under which the function sets the last-error code. DWORD PALAPI GetLastError( - VOID) + VOID) noexcept { return CPalThread::GetLastError(); } @@ -79,7 +79,7 @@ This function does not return a value. VOID PALAPI SetLastError( - IN DWORD dwErrCode) + IN DWORD dwErrCode) noexcept { CPalThread::SetLastError(dwErrCode); } diff --git a/src/coreclr/runtime/CLREventBase.h b/src/coreclr/runtime/CLREventBase.h index b8be95e78471a1..e0794bebe85fe8 100644 --- a/src/coreclr/runtime/CLREventBase.h +++ b/src/coreclr/runtime/CLREventBase.h @@ -19,7 +19,7 @@ class CLREventBase bool CreateFromOSHandle(void* osHandle); #endif - void CloseEvent(); + void CloseEvent() noexcept; bool IsValid() const; bool Set(); bool Reset(); diff --git a/src/coreclr/runtime/unix/CLREventBase.cpp b/src/coreclr/runtime/unix/CLREventBase.cpp index 2ef54890850fdc..f1b58a6dd0a4a0 100644 --- a/src/coreclr/runtime/unix/CLREventBase.cpp +++ b/src/coreclr/runtime/unix/CLREventBase.cpp @@ -132,7 +132,7 @@ bool CLREventBase::CreateManualEventNoThrow(bool initialState) return CreateEventNoThrow(true, initialState); } -void CLREventBase::CloseEvent() +void CLREventBase::CloseEvent() noexcept { if (IsValid()) { diff --git a/src/coreclr/runtime/windows/CLREventBase.cpp b/src/coreclr/runtime/windows/CLREventBase.cpp index 036975e80371f4..6804fd3a117884 100644 --- a/src/coreclr/runtime/windows/CLREventBase.cpp +++ b/src/coreclr/runtime/windows/CLREventBase.cpp @@ -49,7 +49,7 @@ bool CLREventBase::CreateFromOSHandle(void* osHandle) DUPLICATE_SAME_ACCESS) != FALSE; } -void CLREventBase::CloseEvent() +void CLREventBase::CloseEvent() noexcept { if (IsValid()) { diff --git a/src/coreclr/utilcode/arraylist.cpp b/src/coreclr/utilcode/arraylist.cpp index a6fbc6236b6b50..24da8273af63ea 100644 --- a/src/coreclr/utilcode/arraylist.cpp +++ b/src/coreclr/utilcode/arraylist.cpp @@ -19,7 +19,7 @@ // writers, however.) // -void ArrayListBase::Clear() +void ArrayListBase::Clear() noexcept { CONTRACTL { diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index 57cfab3d0529f4..9e5931a9181f9a 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -600,7 +600,7 @@ BOOL CLRConfig::IsConfigOptionSpecified(LPCWSTR name) // Deallocation function for code:CLRConfig::FreeConfigString // // static -void CLRConfig::FreeConfigString(_In_z_ LPWSTR str) +void CLRConfig::FreeConfigString(_In_z_ LPWSTR str) noexcept { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/utilcode/collections.cpp b/src/coreclr/utilcode/collections.cpp index a4afa95ef3dcc8..05310cd64cd647 100644 --- a/src/coreclr/utilcode/collections.cpp +++ b/src/coreclr/utilcode/collections.cpp @@ -971,7 +971,7 @@ void CStructArray::Grow( //***************************************************************************** // Free the memory for this item. //***************************************************************************** -void CStructArray::Clear() +void CStructArray::Clear() noexcept { CONTRACTL { diff --git a/src/coreclr/utilcode/ex.cpp b/src/coreclr/utilcode/ex.cpp index 83b0f9c65950f3..0134c06452657e 100644 --- a/src/coreclr/utilcode/ex.cpp +++ b/src/coreclr/utilcode/ex.cpp @@ -81,7 +81,7 @@ void Exception::operator delete(void* ptr) #endif //------------------------------------------------------------------------------ -void Exception::Delete(Exception* pvMemory) +void Exception::Delete(Exception* pvMemory) noexcept { CONTRACTL { @@ -213,7 +213,7 @@ BOOL Exception::IsTransient(HRESULT hr) //------------------------------------------------------------------------------ // Functions to manage the preallocated exceptions. // Virtual -BOOL Exception::IsPreallocatedException() +BOOL Exception::IsPreallocatedException() noexcept { // Most exceptions can't be preallocated. If they can be, their class // should provide a virtual override of this function. return FALSE; diff --git a/src/coreclr/utilcode/executableallocator.cpp b/src/coreclr/utilcode/executableallocator.cpp index 02cbb5d423446b..fc772dafb6ebec 100644 --- a/src/coreclr/utilcode/executableallocator.cpp +++ b/src/coreclr/utilcode/executableallocator.cpp @@ -223,7 +223,7 @@ bool ExecutableAllocator::IsPreferredExecutableRange(void * p) return g_preferredRangeMin <= (BYTE *)p && (BYTE *)p < g_preferredRangeMax; } -ExecutableAllocator* ExecutableAllocator::Instance() +ExecutableAllocator* ExecutableAllocator::Instance() noexcept { LIMITED_METHOD_CONTRACT; return g_instance; @@ -503,12 +503,12 @@ void* ExecutableAllocator::Commit(void* pStart, size_t size, bool isExecutable) } } -void ExecutableAllocator::Release(void* pRX) +void ExecutableAllocator::Release(void* pRX) noexcept { ReleaseWorker(pRX, false /* this is the standard Release of normally allocated memory */); } -void ExecutableAllocator::ReleaseWorker(void* pRX, bool releaseTemplate) +void ExecutableAllocator::ReleaseWorker(void* pRX, bool releaseTemplate) noexcept { LIMITED_METHOD_CONTRACT; @@ -945,7 +945,7 @@ void* ExecutableAllocator::MapRW(void* pRX, size_t size, CacheableMapping cacheM // Unmap writeable mapping at the specified address. The address must be an address // returned by the MapRW method. -void ExecutableAllocator::UnmapRW(void* pRW) +void ExecutableAllocator::UnmapRW(void* pRW) noexcept { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/utilcode/hostimpl.cpp b/src/coreclr/utilcode/hostimpl.cpp index 035f8959bae213..89ea29bc1a8b5f 100644 --- a/src/coreclr/utilcode/hostimpl.cpp +++ b/src/coreclr/utilcode/hostimpl.cpp @@ -32,7 +32,7 @@ void ClrEnterCriticalSection(CRITSEC_COOKIE cookie) minipal_mutex_enter((minipal_mutex*)cookie); } -void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) +void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) noexcept { _ASSERTE(cookie); minipal_mutex_leave((minipal_mutex*)cookie); diff --git a/src/coreclr/utilcode/loaderheap_shared.cpp b/src/coreclr/utilcode/loaderheap_shared.cpp index 118753de0ca5d4..ea7c694b2b41ca 100644 --- a/src/coreclr/utilcode/loaderheap_shared.cpp +++ b/src/coreclr/utilcode/loaderheap_shared.cpp @@ -46,7 +46,7 @@ UnlockedLoaderHeapBase::~UnlockedLoaderHeapBase() } -void ReleaseReservedMemory(BYTE* value) +void ReleaseReservedMemory(BYTE* value) noexcept { if (value) { diff --git a/src/coreclr/utilcode/loaderheap_shared.h b/src/coreclr/utilcode/loaderheap_shared.h index ce92376860e5f6..88a745357b4915 100644 --- a/src/coreclr/utilcode/loaderheap_shared.h +++ b/src/coreclr/utilcode/loaderheap_shared.h @@ -4,13 +4,13 @@ #ifndef LOADERHEAP_SHARED #define LOADERHEAP_SHARED -void ReleaseReservedMemory(BYTE* value); +void ReleaseReservedMemory(BYTE* value) noexcept; struct ReservedMemoryTraits final { using Type = BYTE*; static constexpr Type Default() { return NULL; } - static void Free(Type value) + static void Free(Type value) noexcept { STATIC_CONTRACT_WRAPPER; ReleaseReservedMemory(value); diff --git a/src/coreclr/vm/clrex.cpp b/src/coreclr/vm/clrex.cpp index b5bb498d945f5b..7a1dc40dac8eba 100644 --- a/src/coreclr/vm/clrex.cpp +++ b/src/coreclr/vm/clrex.cpp @@ -769,7 +769,7 @@ OBJECTREF CLRException::GetThrowableFromExceptionRecord(EXCEPTION_RECORD *pExcep return NULL; } -void CLRException::HandlerState::CleanupTry() +void CLRException::HandlerState::CleanupTry() noexcept { STATIC_CONTRACT_NOTHROW; STATIC_CONTRACT_GC_NOTRIGGER; diff --git a/src/coreclr/vm/clrex.h b/src/coreclr/vm/clrex.h index 1c62d50a0f6600..7c771515c1b83d 100644 --- a/src/coreclr/vm/clrex.h +++ b/src/coreclr/vm/clrex.h @@ -178,7 +178,7 @@ class CLRException : public Exception HandlerState(Thread * pThread); HandlerState(Thread * pThread, NonNullThread dummy); - void CleanupTry(); + void CleanupTry() noexcept; void SetupCatch(INDEBUG_COMMA(_In_z_ const char * szFile) int lineNum); #ifdef LOGGING // Use parent implementation that inlines into nothing in retail build void SucceedCatch(); diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index f9885ecbb749df..e6ef5a6bca82ab 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -146,8 +146,8 @@ typedef PTR_Object OBJECTREF; typedef DPTR(OBJECTREF) PTR_OBJECTREF; typedef DPTR(PTR_OBJECTREF) PTR_PTR_OBJECTREF; -Thread* GetThread(); -Thread* GetThreadNULLOk(); +Thread* GetThread() noexcept; +Thread* GetThreadNULLOk() noexcept; EXTERN_C Thread* STDCALL GetThreadHelper(); diff --git a/src/coreclr/vm/crst.cpp b/src/coreclr/vm/crst.cpp index e3154ecb491797..48dac49c14e221 100644 --- a/src/coreclr/vm/crst.cpp +++ b/src/coreclr/vm/crst.cpp @@ -106,7 +106,7 @@ void CrstBase::Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag/* = CRST_LEVEL_CH #else // !DACCESS_COMPILE #if defined(FEATURE_MULTITHREADING) || defined(_DEBUG) -void CrstBase::Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag/* = CRST_LEVEL_CHECK*/)) +void CrstBase::Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag/* = CRST_LEVEL_CHECK*/)) noexcept { //------------------------------------------------------------------------------------------- // What, no CONTRACT? @@ -237,7 +237,7 @@ void CrstBase::Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag/* = CRST_LEVEL_CH //----------------------------------------------------------------- // Release the lock. //----------------------------------------------------------------- -void CrstBase::Leave() +void CrstBase::Leave() noexcept { STATIC_CONTRACT_MODE_ANY; STATIC_CONTRACT_NOTHROW; diff --git a/src/coreclr/vm/crst.h b/src/coreclr/vm/crst.h index c4c3b8c1d8cce0..5000df01766776 100644 --- a/src/coreclr/vm/crst.h +++ b/src/coreclr/vm/crst.h @@ -110,7 +110,7 @@ class CrstBase friend class ListLockEntryBase; friend struct SavedExceptionInfo; friend void ClrEnterCriticalSection(CRITSEC_COOKIE cookie); - friend void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie); + friend void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) noexcept; friend class CodeVersionManager; friend class Debugger; @@ -151,20 +151,24 @@ class CrstBase #if !defined(FEATURE_MULTITHREADING) && !defined(_DEBUG) // There is no wait to make GC-safe, no other thread to orphan a shutdown lock, // and no debugger helper thread to exclude. Keep these inline so holders disappear too. - void Enter() { LIMITED_METHOD_CONTRACT; } - void Leave() { LIMITED_METHOD_CONTRACT; } + void Enter() noexcept { LIMITED_METHOD_CONTRACT; } + void Leave() noexcept { LIMITED_METHOD_CONTRACT; } #else +#ifdef DACCESS_COMPILE void Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag = CRST_LEVEL_CHECK)); - void Leave(); +#else + void Enter(INDEBUG(NoLevelCheckFlag noLevelCheckFlag = CRST_LEVEL_CHECK)) noexcept; +#endif + void Leave() noexcept; #endif #ifndef DACCESS_COMPILE - DEBUG_NOINLINE static void AcquireLock(CrstBase *c) { + DEBUG_NOINLINE static void AcquireLock(CrstBase *c) noexcept { WRAPPER_NO_CONTRACT; c->Enter(); } - DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) { + DEBUG_NOINLINE static void ReleaseLock(CrstBase *c) noexcept { WRAPPER_NO_CONTRACT; c->Leave(); } @@ -185,7 +189,7 @@ class CrstBase } }; - static void ReleaseLock(CrstBase *c) + static void ReleaseLock(CrstBase *c) noexcept { SUPPORTS_DAC; }; @@ -339,7 +343,11 @@ class CrstBase CrstBase * m_pCrst; public: +#ifdef DACCESS_COMPILE CrstHolder(CrstBase* pCrst) +#else + CrstHolder(CrstBase* pCrst) noexcept +#endif : m_pCrst{ pCrst } { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/debugdebugger.cpp b/src/coreclr/vm/debugdebugger.cpp index 2f73a86a64b5e4..20bf5c940726e9 100644 --- a/src/coreclr/vm/debugdebugger.cpp +++ b/src/coreclr/vm/debugdebugger.cpp @@ -852,7 +852,7 @@ struct StrongHandleHolderTraits final { using Type = OBJECTHANDLE; static constexpr Type Default() { return NULL; } - static void Free(Type handle) + static void Free(Type handle) noexcept { WRAPPER_NO_CONTRACT; if (handle != NULL) diff --git a/src/coreclr/vm/ebr.cpp b/src/coreclr/vm/ebr.cpp index 9d4ea4976b908f..a8ad7ea308d0c4 100644 --- a/src/coreclr/vm/ebr.cpp +++ b/src/coreclr/vm/ebr.cpp @@ -194,7 +194,7 @@ EbrCollector::EnterCriticalRegion() } void -EbrCollector::ExitCriticalRegion() +EbrCollector::ExitCriticalRegion() noexcept { CONTRACTL { diff --git a/src/coreclr/vm/ebr.h b/src/coreclr/vm/ebr.h index 0ec2677ff05b1f..0217af85316c95 100644 --- a/src/coreclr/vm/ebr.h +++ b/src/coreclr/vm/ebr.h @@ -63,7 +63,7 @@ class EbrCollector final void EnterCriticalRegion(); // Exit a critical region. Must pair with EnterCriticalRegion. - void ExitCriticalRegion(); + void ExitCriticalRegion() noexcept; // Queue an object for deferred deletion. Must be called from within a // critical region. The object will be deleted via pfnDelete once all @@ -136,7 +136,7 @@ class EbrCriticalRegionHolder final m_pCollector->EnterCriticalRegion(); } - ~EbrCriticalRegionHolder() + ~EbrCriticalRegionHolder() noexcept { WRAPPER_NO_CONTRACT; if (m_pCollector != nullptr) diff --git a/src/coreclr/vm/excep.cpp b/src/coreclr/vm/excep.cpp index fe0066078f8714..4fc4845dbec2cf 100644 --- a/src/coreclr/vm/excep.cpp +++ b/src/coreclr/vm/excep.cpp @@ -2705,7 +2705,7 @@ void StackTraceInfo::AppendElement(OBJECTREF pThrowable, UINT_PTR currentIP, UIN GCPROTECT_END(); } -void UnwindFrameChain(Thread* pThread, LPVOID pvLimitSP) +void UnwindFrameChain(Thread* pThread, LPVOID pvLimitSP) noexcept { CONTRACTL { diff --git a/src/coreclr/vm/excep.h b/src/coreclr/vm/excep.h index 010a7e91af28e0..18b104a962e237 100644 --- a/src/coreclr/vm/excep.h +++ b/src/coreclr/vm/excep.h @@ -104,7 +104,7 @@ void TerminateExceptionHandling(); // Prototypes EXTERN_C VOID STDCALL ResetCurrentContext(); -void UnwindFrameChain(Thread *pThread, LPVOID pvLimitSP); +void UnwindFrameChain(Thread *pThread, LPVOID pvLimitSP) noexcept; DWORD MapWin32FaultToCOMPlusException(EXCEPTION_RECORD *pExceptionRecord); DWORD ComputeEnclosingHandlerNestingLevel(IJitManager *pIJM, const METHODTOKEN& mdTok, SIZE_T offsNat); BOOL IsException(MethodTable *pMT); diff --git a/src/coreclr/vm/frames.cpp b/src/coreclr/vm/frames.cpp index 5af329369f7ade..e2f9f26ba277ce 100644 --- a/src/coreclr/vm/frames.cpp +++ b/src/coreclr/vm/frames.cpp @@ -68,7 +68,7 @@ unsigned Frame::GetFrameAttribs() } #ifndef DACCESS_COMPILE -void Frame::ExceptionUnwind() +void Frame::ExceptionUnwind() noexcept { switch (GetFrameIdentifier()) { @@ -583,7 +583,7 @@ VOID Frame::Push(Thread *pThread) pThread->SetFrame(this); } -VOID Frame::Pop() +VOID Frame::Pop() noexcept { CONTRACTL { @@ -596,7 +596,7 @@ VOID Frame::Pop() Pop(GetThread()); } -VOID Frame::Pop(Thread *pThread) +VOID Frame::Pop(Thread *pThread) noexcept { CONTRACTL { @@ -621,7 +621,7 @@ VOID Frame::Pop(Thread *pThread) } #if defined(TARGET_UNIX) && !defined(DACCESS_COMPILE) -void Frame::PopIfChained() +void Frame::PopIfChained() noexcept { CONTRACTL { @@ -1830,7 +1830,7 @@ void InterpreterFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF } #ifndef DACCESS_COMPILE -void InterpreterFrame::ExceptionUnwind_Impl() +void InterpreterFrame::ExceptionUnwind_Impl() noexcept { WRAPPER_NO_CONTRACT; diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 32f23b550109a0..72be52c700f4bd 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -248,7 +248,7 @@ class Frame void GcScanRoots(promote_func *fn, ScanContext* sc); unsigned GetFrameAttribs(); #ifndef DACCESS_COMPILE - void ExceptionUnwind(); + void ExceptionUnwind() noexcept; #endif BOOL NeedsUpdateRegDisplay(); BOOL IsTransitionToNativeFrame(); @@ -312,7 +312,7 @@ class Frame // Performs cleanup on an exception unwind //------------------------------------------------------------------------ #ifndef DACCESS_COMPILE - void ExceptionUnwind_Impl() + void ExceptionUnwind_Impl() noexcept { // Nothing to do here. LIMITED_METHOD_CONTRACT; @@ -521,9 +521,9 @@ class Frame #ifndef DACCESS_COMPILE // Link and Unlink this frame VOID Push(); - VOID Pop(); + VOID Pop() noexcept; VOID Push(Thread *pThread); - VOID Pop(Thread *pThread); + VOID Pop(Thread *pThread) noexcept; #endif // DACCESS_COMPILE #ifdef _DEBUG_IMPL @@ -602,9 +602,9 @@ class Frame #endif // DACCESS_COMPILE #if defined(TARGET_UNIX) && !defined(DACCESS_COMPILE) - ~Frame() { PopIfChained(); } + ~Frame() noexcept { PopIfChained(); } - void PopIfChained(); + void PopIfChained() noexcept; #endif // TARGET_UNIX && !DACCESS_COMPILE friend struct ::cdac_data; @@ -746,7 +746,7 @@ class RedirectedThreadFrame : public ResumableFrame LIMITED_METHOD_CONTRACT; } - void ExceptionUnwind_Impl(); + void ExceptionUnwind_Impl() noexcept; #endif }; @@ -2365,7 +2365,7 @@ class InterpreterFrame : public FramedMethodFrame void UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateFloats = false); #ifndef DACCESS_COMPILE - void ExceptionUnwind_Impl(); + void ExceptionUnwind_Impl() noexcept; #endif #ifndef DACCESS_COMPILE diff --git a/src/coreclr/vm/hosting.cpp b/src/coreclr/vm/hosting.cpp index cd128439cd89d8..5eb5de12e70e99 100644 --- a/src/coreclr/vm/hosting.cpp +++ b/src/coreclr/vm/hosting.cpp @@ -351,7 +351,7 @@ DEBUG_NOINLINE void ClrEnterCriticalSection(CRITSEC_COOKIE cookie) { pCrst->Enter(); } -DEBUG_NOINLINE void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) +DEBUG_NOINLINE void ClrLeaveCriticalSection(CRITSEC_COOKIE cookie) noexcept { CONTRACTL { diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index 3b00bd779955cb..4eb2aef311cbbf 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -749,7 +749,7 @@ ULONG SafeReleasePreemp(IUnknown * pUnk) //-------------------------------------------------------------------------------- // Release helper, enables and disables GC during call-outs -ULONG SafeRelease(IUnknown* pUnk) +ULONG SafeRelease(IUnknown* pUnk) noexcept { CONTRACTL { NOTHROW; diff --git a/src/coreclr/vm/interoputil.h b/src/coreclr/vm/interoputil.h index 2c4e887555c9c0..053b98c58b0614 100644 --- a/src/coreclr/vm/interoputil.h +++ b/src/coreclr/vm/interoputil.h @@ -55,7 +55,7 @@ HRESULT SetupErrorInfo(OBJECTREF pThrownObject); //-------------------------------------------------------------------------------- // Release helper, enables and disables GC during call-outs -ULONG SafeRelease(IUnknown* pUnk); +ULONG SafeRelease(IUnknown* pUnk) noexcept; //-------------------------------------------------------------------------------- // Release helper, must be called in preemptive mode. Only use this variant if diff --git a/src/coreclr/vm/loaderallocator.cpp b/src/coreclr/vm/loaderallocator.cpp index bd4f3cda49cf4c..842f3b2e364f04 100644 --- a/src/coreclr/vm/loaderallocator.cpp +++ b/src/coreclr/vm/loaderallocator.cpp @@ -196,7 +196,7 @@ BOOL LoaderAllocator::AddReferenceIfAlive() //--------------------------------------------------------------------------------------- // -BOOL LoaderAllocator::Release() +BOOL LoaderAllocator::Release() noexcept { CONTRACTL { diff --git a/src/coreclr/vm/loaderallocator.hpp b/src/coreclr/vm/loaderallocator.hpp index e4d2d8601f7a9c..7bcfca4b8f8fc1 100644 --- a/src/coreclr/vm/loaderallocator.hpp +++ b/src/coreclr/vm/loaderallocator.hpp @@ -602,7 +602,7 @@ class LoaderAllocator // Adds reference if the native object is alive - code:#AssemblyPhases. // Returns TRUE if the reference was added. BOOL AddReferenceIfAlive(); - BOOL Release(); + BOOL Release() noexcept; // Checks if the native object is alive - see code:#AssemblyPhases. BOOL IsAlive() { LIMITED_METHOD_DAC_CONTRACT; return (m_cReferences != (UINT32)0); } // Checks if managed scout is alive - see code:#AssemblyPhases. diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index 2cfdf00b40f514..53a9c914dbc307 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -6595,7 +6595,7 @@ InteropMethodTableData *MethodTable::GetComInteropData() #endif // FEATURE_COMINTEROP //========================================================================================== -ULONG MethodTable::MethodData::Release() +ULONG MethodTable::MethodData::Release() noexcept { LIMITED_METHOD_CONTRACT; //@TODO: Must adjust this to use an alternate allocator so that we don't diff --git a/src/coreclr/vm/methodtable.h b/src/coreclr/vm/methodtable.h index 5b0763d3189915..b4562058596e53 100644 --- a/src/coreclr/vm/methodtable.h +++ b/src/coreclr/vm/methodtable.h @@ -3194,13 +3194,13 @@ public : inline ULONG AddRef() { LIMITED_METHOD_CONTRACT; return (ULONG) InterlockedIncrement((LONG*)&m_cRef); } - ULONG Release(); + ULONG Release() noexcept; // Since all methods that return a MethodData already AddRef'd, we do NOT // want to AddRef when putting a holder around it. We only want to release it. static void HolderAcquire(MethodData *pEntry) { LIMITED_METHOD_CONTRACT; return; } - static void HolderRelease(MethodData *pEntry) + static void HolderRelease(MethodData *pEntry) noexcept { WRAPPER_NO_CONTRACT; if (pEntry != NULL) pEntry->Release(); } static void* operator new(size_t size) diff --git a/src/coreclr/vm/peimage.cpp b/src/coreclr/vm/peimage.cpp index b285072b182e09..1a7f80ed3e6526 100644 --- a/src/coreclr/vm/peimage.cpp +++ b/src/coreclr/vm/peimage.cpp @@ -126,7 +126,7 @@ BOOL PEImage::CompareIJWDataBase(UPTR base, UPTR mapping) return (BYTE *)(base << 1) == ((IJWFixupData*)mapping)->GetBase(); } -ULONG PEImage::Release() +ULONG PEImage::Release() noexcept { CONTRACTL { diff --git a/src/coreclr/vm/peimage.h b/src/coreclr/vm/peimage.h index 94fdcec15f121b..dc9298d9bb20d5 100644 --- a/src/coreclr/vm/peimage.h +++ b/src/coreclr/vm/peimage.h @@ -110,7 +110,7 @@ class PEImage final BOOL Equals(PEImage* pImage); ULONG AddRef(); - ULONG Release(); + ULONG Release() noexcept; #ifndef DACCESS_COMPILE static PTR_PEImage CreateFromByteArray(const BYTE* array, COUNT_T size); @@ -336,7 +336,7 @@ struct PEImageHolderTraits final { using Type = PEImage*; static constexpr Type Default() { return NULL; } - static void Free(Type i) + static void Free(Type i) noexcept { WRAPPER_NO_CONTRACT; if (i != NULL) diff --git a/src/coreclr/vm/stringliteralmap.h b/src/coreclr/vm/stringliteralmap.h index 03bf02c84263bb..26fb2d577c2837 100644 --- a/src/coreclr/vm/stringliteralmap.h +++ b/src/coreclr/vm/stringliteralmap.h @@ -324,7 +324,7 @@ struct StringLiteralEntryTraits final { using Type = StringLiteralEntry*; static constexpr Type Default() { return NULL; } - static void Free(Type pEntry) + static void Free(Type pEntry) noexcept { STATIC_CONTRACT_WRAPPER; if (pEntry != NULL) diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index 57080b81660679..d48fddc55ca2b2 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -4003,7 +4003,7 @@ DEBUG_NOINLINE void ThreadStore::Enter() m_Crst.Enter(); } -DEBUG_NOINLINE void ThreadStore::Leave() +DEBUG_NOINLINE void ThreadStore::Leave() noexcept { CONTRACTL { NOTHROW; @@ -4024,7 +4024,7 @@ void ThreadStore::LockThreadStore() ThreadSuspend::LockThreadStore(ThreadSuspend::SUSPEND_OTHER); } -void ThreadStore::UnlockThreadStore() +void ThreadStore::UnlockThreadStore() noexcept { WRAPPER_NO_CONTRACT; @@ -6261,7 +6261,7 @@ TADDR Thread::GetStaticFieldAddrNoCreate(FieldDesc *pFD) // frame's ExceptionUnwind method. It will return the first // Frame that is above pvLimitSP. // -Frame * Thread::NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvLimitSP) +Frame * Thread::NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvLimitSP) noexcept { CONTRACTL { diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 5a3e1638b37118..80e8d5ff092898 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -922,7 +922,7 @@ class Thread DWORD m_ThreadId; #ifndef DACCESS_COMPILE - Frame* NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvLimitSP); + Frame* NotifyFrameChainOfExceptionUnwind(Frame* pStartFrame, LPVOID pvLimitSP) noexcept; #endif // DACCESS_COMPILE // Lock thread is trying to acquire @@ -1223,7 +1223,7 @@ class Thread //-------------------------------------------------------------- // Enter cooperative GC mode. NOT NESTABLE. //-------------------------------------------------------------- - FORCEINLINE_NONDEBUG void DisablePreemptiveGC() + FORCEINLINE_NONDEBUG void DisablePreemptiveGC() noexcept { #ifndef DACCESS_COMPILE WRAPPER_NO_CONTRACT; @@ -1273,7 +1273,7 @@ class Thread #endif } - NOINLINE void RareDisablePreemptiveGC(); + NOINLINE void RareDisablePreemptiveGC() noexcept; void HandleThreadAbort(); @@ -1286,7 +1286,7 @@ class Thread //-------------------------------------------------------------- // Leave cooperative GC mode. NOT NESTABLE. //-------------------------------------------------------------- - FORCEINLINE_NONDEBUG void EnablePreemptiveGC() + FORCEINLINE_NONDEBUG void EnablePreemptiveGC() noexcept { LIMITED_METHOD_CONTRACT; @@ -1320,7 +1320,7 @@ class Thread //-------------------------------------------------------------- // Query mode //-------------------------------------------------------------- - BOOL PreemptiveGCDisabled() + BOOL PreemptiveGCDisabled() noexcept { WRAPPER_NO_CONTRACT; _ASSERTE(this == GetThread()); @@ -3864,7 +3864,7 @@ class ThreadStore static void InitThreadStore(); static void LockThreadStore(); - static void UnlockThreadStore(); + static void UnlockThreadStore() noexcept; // Add a Thread to the ThreadStore static void AddThread(Thread *newThread); @@ -3918,7 +3918,7 @@ class ThreadStore // Enter and leave the critical section around the thread store. Clients should // use LockThreadStore and UnlockThreadStore. void Enter(); - void Leave(); + void Leave() noexcept; // Critical section for adding and removing threads to the store Crst m_Crst; diff --git a/src/coreclr/vm/threads.inl b/src/coreclr/vm/threads.inl index 6f76410a0e1c75..b27df1b0fd98eb 100644 --- a/src/coreclr/vm/threads.inl +++ b/src/coreclr/vm/threads.inl @@ -33,12 +33,12 @@ EXTERN_C #endif PLATFORM_THREAD_LOCAL ThreadLocalInfo t_CurrentThreadInfo; -inline Thread* GetThreadNULLOk() +inline Thread* GetThreadNULLOk() noexcept { return t_CurrentThreadInfo.m_pThread; } -inline Thread* GetThread() +inline Thread* GetThread() noexcept { Thread* pThread = t_CurrentThreadInfo.m_pThread; _ASSERTE(pThread); diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 2b9fdeb2f9fdc8..9d2933f1a3b942 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -1860,7 +1860,7 @@ void ThreadSuspend::LockThreadStore(ThreadSuspend::SUSPEND_REASON reason) #endif } -void ThreadSuspend::UnlockThreadStore(BOOL bThreadDestroyed, ThreadSuspend::SUSPEND_REASON reason) +void ThreadSuspend::UnlockThreadStore(BOOL bThreadDestroyed, ThreadSuspend::SUSPEND_REASON reason) noexcept { CONTRACTL { NOTHROW; @@ -2050,7 +2050,7 @@ extern void WaitForEndOfShutdown(); // currently in progress. This is the situation when returning back into // the EE from outside. See the comments in DisablePreemptiveGC() to understand // why we Enable GC here! -void Thread::RareDisablePreemptiveGC() +void Thread::RareDisablePreemptiveGC() noexcept { PreserveLastErrorHolder preserveLastError; @@ -2450,7 +2450,7 @@ bool ThreadStore::IsTrappingThreadsForSuspension() #ifdef FEATURE_HIJACK -void RedirectedThreadFrame::ExceptionUnwind_Impl() +void RedirectedThreadFrame::ExceptionUnwind_Impl() noexcept { CONTRACTL { diff --git a/src/coreclr/vm/threadsuspend.h b/src/coreclr/vm/threadsuspend.h index 6c45f006049765..29c3165c9c0aaf 100644 --- a/src/coreclr/vm/threadsuspend.h +++ b/src/coreclr/vm/threadsuspend.h @@ -239,7 +239,7 @@ class ThreadSuspend static void LockThreadStore(ThreadSuspend::SUSPEND_REASON reason); static void UnlockThreadStore(BOOL bThreadDestroyed = FALSE, - ThreadSuspend::SUSPEND_REASON reason = ThreadSuspend::SUSPEND_OTHER); + ThreadSuspend::SUSPEND_REASON reason = ThreadSuspend::SUSPEND_OTHER) noexcept; static Thread * GetSuspensionThread() { diff --git a/src/coreclr/vm/util.cpp b/src/coreclr/vm/util.cpp index 55be0fd1b78c96..2ebf1210d4f086 100644 --- a/src/coreclr/vm/util.cpp +++ b/src/coreclr/vm/util.cpp @@ -880,7 +880,7 @@ CLRMapViewOfFile( BOOL CLRUnmapViewOfFile( IN LPVOID lpBaseAddress - ) + ) noexcept { STATIC_CONTRACT_ENTRY_POINT; diff --git a/src/coreclr/vm/util.hpp b/src/coreclr/vm/util.hpp index a372f8c002c6d5..c3756afa02b880 100644 --- a/src/coreclr/vm/util.hpp +++ b/src/coreclr/vm/util.hpp @@ -513,7 +513,7 @@ class EEThreadId return m_FiberPtrId == UNKNOWN_ID; } #endif - void Clear() + void Clear() noexcept { LIMITED_METHOD_CONTRACT; m_FiberPtrId = UNKNOWN_ID; @@ -540,13 +540,13 @@ CLRMapViewOfFile( BOOL CLRUnmapViewOfFile( IN LPVOID lpBaseAddress - ); + ) noexcept; struct CLRMapViewTraits final { using Type = void*; static constexpr Type Default() { return NULL; } - static void Free(Type ptr) + static void Free(Type ptr) noexcept { STATIC_CONTRACT_WRAPPER; #ifndef DACCESS_COMPILE @@ -564,7 +564,7 @@ struct PALPEFileTraits final { using Type = void*; static constexpr Type Default() { return NULL; } - static void Free(Type ptr) + static void Free(Type ptr) noexcept { STATIC_CONTRACT_WRAPPER; #ifndef DACCESS_COMPILE @@ -593,7 +593,7 @@ struct NativeLibraryHandleTraits final { using Type = NATIVE_LIBRARY_HANDLE; static constexpr Type Default() { return NULL; } - static void Free(Type h) + static void Free(Type h) noexcept { STATIC_CONTRACT_WRAPPER; diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index b250a23ef27e5c..49334c9953d73e 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -493,7 +493,7 @@ EXTERN PRTLDLLSHUTDOWNINPROGRESS g_pfnRtlDllShutdownInProgress; // Indicates whether we're executing shut down as a result of DllMain // (DLL_PROCESS_DETACH). See comments at code:EEShutDown for details. -inline bool IsAtProcessExit() +inline bool IsAtProcessExit() noexcept { SUPPORTS_DAC; #if defined(DACCESS_COMPILE) || !defined(HOST_WINDOWS) diff --git a/src/native/minipal/mutex.h b/src/native/minipal/mutex.h index cc7002cd509bb4..d81873ae1ff1b5 100644 --- a/src/native/minipal/mutex.h +++ b/src/native/minipal/mutex.h @@ -6,6 +6,12 @@ #include +#ifdef __cplusplus +#define MINIPAL_MUTEX_NOEXCEPT noexcept +#else +#define MINIPAL_MUTEX_NOEXCEPT +#endif + #ifdef HOST_WINDOWS #include typedef CRITICAL_SECTION MINIPAL_MUTEX_IMPL; @@ -32,29 +38,29 @@ typedef struct _minipal_nonrecursive_mutex } minipal_nonrecursive_mutex; // Initialize the mutex. -bool minipal_mutex_init(minipal_mutex* mt); +bool minipal_mutex_init(minipal_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Initialize a non-recursive mutex. -bool minipal_nonrecursive_mutex_init(minipal_nonrecursive_mutex* mt); +bool minipal_nonrecursive_mutex_init(minipal_nonrecursive_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Destroy the mutex. -void minipal_mutex_destroy(minipal_mutex* mt); +void minipal_mutex_destroy(minipal_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Destroy the non-recursive mutex. -void minipal_nonrecursive_mutex_destroy(minipal_nonrecursive_mutex* mt); +void minipal_nonrecursive_mutex_destroy(minipal_nonrecursive_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Enter the mutex. Blocks until the mutex can be entered. // Recursive enters are allowed. -void minipal_mutex_enter(minipal_mutex* mt); +void minipal_mutex_enter(minipal_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Enter the non-recursive mutex. Blocks until the mutex can be entered. -void minipal_nonrecursive_mutex_enter(minipal_nonrecursive_mutex* mt); +void minipal_nonrecursive_mutex_enter(minipal_nonrecursive_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Leave the mutex. -void minipal_mutex_leave(minipal_mutex* mt); +void minipal_mutex_leave(minipal_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; // Leave the non-recursive mutex. -void minipal_nonrecursive_mutex_leave(minipal_nonrecursive_mutex* mt); +void minipal_nonrecursive_mutex_leave(minipal_nonrecursive_mutex* mt) MINIPAL_MUTEX_NOEXCEPT; #ifdef __cplusplus } @@ -68,7 +74,7 @@ namespace minipal minipal_mutex& _mtx; public: - explicit MutexHolder(minipal_mutex& mtx) + explicit MutexHolder(minipal_mutex& mtx) noexcept : _mtx{ mtx } { minipal_mutex_enter(&_mtx); @@ -88,4 +94,6 @@ namespace minipal } #endif // __cplusplus +#undef MINIPAL_MUTEX_NOEXCEPT + #endif // HAVE_MINIPAL_MUTEX_H diff --git a/src/native/minipal/rwlock.h b/src/native/minipal/rwlock.h index b6abd0b6997506..56ac4d7358b41f 100644 --- a/src/native/minipal/rwlock.h +++ b/src/native/minipal/rwlock.h @@ -6,6 +6,12 @@ #include +#ifdef __cplusplus +#define MINIPAL_RWLOCK_NOEXCEPT noexcept +#else +#define MINIPAL_RWLOCK_NOEXCEPT +#endif + #ifdef HOST_WINDOWS #include typedef SRWLOCK MINIPAL_RWLOCK_IMPL; @@ -25,25 +31,27 @@ typedef struct _minipal_rwlock } minipal_rwlock; // Initialize the read-write lock. -bool minipal_rwlock_init(minipal_rwlock* rwlock); +bool minipal_rwlock_init(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; // Destroy the read-write lock. -void minipal_rwlock_destroy(minipal_rwlock* rwlock); +void minipal_rwlock_destroy(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; // Enter the read-write lock in shared mode. Blocks until the lock can be entered. -bool minipal_rwlock_enter_read(minipal_rwlock* rwlock); +bool minipal_rwlock_enter_read(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; // Leave the read-write lock from shared mode. -void minipal_rwlock_leave_read(minipal_rwlock* rwlock); +void minipal_rwlock_leave_read(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; // Enter the read-write lock in exclusive mode. Blocks until the lock can be entered. -bool minipal_rwlock_enter_write(minipal_rwlock* rwlock); +bool minipal_rwlock_enter_write(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; // Leave the read-write lock from exclusive mode. -void minipal_rwlock_leave_write(minipal_rwlock* rwlock); +void minipal_rwlock_leave_write(minipal_rwlock* rwlock) MINIPAL_RWLOCK_NOEXCEPT; #ifdef __cplusplus } #endif // __cplusplus +#undef MINIPAL_RWLOCK_NOEXCEPT + #endif // HAVE_MINIPAL_RWLOCK_H