From 6709294af76f6643998c3739a4a300fa353023a2 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Fri, 27 Sep 2019 16:01:08 -0700 Subject: [PATCH] Delete dead code (dotnet/coreclr#26926) Commit migrated from https://github.com/dotnet/coreclr/commit/8f8528c5af2bbaf1fef5147398c08c8d14e417b2 --- .../src/System/Reflection/RuntimeAssembly.cs | 19 ++--------- src/coreclr/src/vm/comcache.cpp | 4 +-- src/coreclr/src/vm/common.h | 37 ---------------------- src/coreclr/src/vm/excep.cpp | 19 ----------- src/coreclr/src/vm/excep.h | 1 - src/coreclr/src/vm/mscorlib.h | 3 -- src/coreclr/src/vm/object.cpp | 12 +++---- src/coreclr/src/vm/simplerwlock.cpp | 4 +-- src/coreclr/src/vm/simplerwlock.hpp | 2 -- src/coreclr/src/vm/spinlock.cpp | 18 +++++------ src/coreclr/src/vm/spinlock.h | 22 ++++++------- src/coreclr/src/vm/threads.h | 12 ------- 12 files changed, 29 insertions(+), 124 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 976e637..d2b47a0 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -21,7 +21,9 @@ namespace System.Reflection internal RuntimeAssembly() { throw new NotSupportedException(); } #region private data members +#pragma warning disable 67 // events are declared but not used private event ModuleResolveEventHandler? _ModuleResolve; +#pragma warning restore 67 private string? m_fullname; private object? m_syncRoot; // Used to keep collectible types alive and as the syncroot for reflection.emit #pragma warning disable 169 @@ -568,23 +570,6 @@ namespace System.Reflection return publicKey; } - // This method is called by the VM. - private RuntimeModule? OnModuleResolveEvent(string moduleName) - { - ModuleResolveEventHandler? moduleResolve = _ModuleResolve; - if (moduleResolve == null) - return null; - - foreach (ModuleResolveEventHandler handler in moduleResolve.GetInvocationList()) - { - RuntimeModule ret = (RuntimeModule)handler(this, new ResolveEventArgs(moduleName, this)); - if (ret != null) - return ret; - } - - return null; - } - public override Assembly GetSatelliteAssembly(CultureInfo culture) { return GetSatelliteAssembly(culture, null); diff --git a/src/coreclr/src/vm/comcache.cpp b/src/coreclr/src/vm/comcache.cpp index b5efbb7..ecb10cb 100644 --- a/src/coreclr/src/vm/comcache.cpp +++ b/src/coreclr/src/vm/comcache.cpp @@ -378,7 +378,7 @@ CtxEntry* CtxEntryCache::FindCtxEntry(LPVOID pCtxCookie, Thread *pThread) ASSERT (GetThread ()); BOOL bFound = FALSE; - ACQUIRE_SPINLOCK_NO_HOLDER(&m_Lock, pThread); + ACQUIRE_SPINLOCK_NO_HOLDER(&m_Lock); { // Try to find a context entry for the context cookie. pCtxEntry = m_CtxEntryHash.Lookup(pCtxCookie); @@ -390,7 +390,7 @@ CtxEntry* CtxEntryCache::FindCtxEntry(LPVOID pCtxCookie, Thread *pThread) bFound = TRUE; } } - RELEASE_SPINLOCK_NO_HOLDER(&m_Lock, pThread); + RELEASE_SPINLOCK_NO_HOLDER(&m_Lock); if (!bFound) { diff --git a/src/coreclr/src/vm/common.h b/src/coreclr/src/vm/common.h index 6abe996..b855860 100644 --- a/src/coreclr/src/vm/common.h +++ b/src/coreclr/src/vm/common.h @@ -374,43 +374,6 @@ namespace Loader #include "gcstress.h" -#ifndef DACCESS_COMPILE - -inline VOID UnsafeEEEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_CAN_TAKE_LOCK; - - EnterCriticalSection(lpCriticalSection); - INCTHREADLOCKCOUNT(); -} - -inline VOID UnsafeEELeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - - LeaveCriticalSection(lpCriticalSection); - DECTHREADLOCKCOUNT(); -} - -inline BOOL UnsafeEETryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection) -{ - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_CAN_TAKE_LOCK; - - BOOL fEnteredCriticalSection = TryEnterCriticalSection(lpCriticalSection); - if(fEnteredCriticalSection) - { - INCTHREADLOCKCOUNT(); - } - return fEnteredCriticalSection; -} - -#endif // !DACCESS_COMPILE - HRESULT EnsureRtlFunctions(); HINSTANCE GetModuleInst(); diff --git a/src/coreclr/src/vm/excep.cpp b/src/coreclr/src/vm/excep.cpp index d3aef5f..d180091 100644 --- a/src/coreclr/src/vm/excep.cpp +++ b/src/coreclr/src/vm/excep.cpp @@ -3120,25 +3120,6 @@ void ResMgrGetString(LPCWSTR wszResourceName, STRINGREF * ppMessage) } } -// GetResourceFromDefault -// transition to the default domain and get a resource there -FCIMPL1(Object*, GetResourceFromDefault, StringObject* keyUnsafe) -{ - FCALL_CONTRACT; - - STRINGREF ret = NULL; - STRINGREF key = (STRINGREF)keyUnsafe; - - HELPER_METHOD_FRAME_BEGIN_RET_2(ret, key); - - ret = GetResourceStringFromManaged(key); - - HELPER_METHOD_FRAME_END(); - - return OBJECTREFToObject(ret); -} -FCIMPLEND - void FreeExceptionData(ExceptionData *pedata) { CONTRACTL diff --git a/src/coreclr/src/vm/excep.h b/src/coreclr/src/vm/excep.h index 91ee1c8..cea16de 100644 --- a/src/coreclr/src/vm/excep.h +++ b/src/coreclr/src/vm/excep.h @@ -599,7 +599,6 @@ VOID DECLSPEC_NORETURN ThrowFieldLayoutError(mdTypeDef cl, // cl UINT GetResourceIDForFileLoadExceptionHR(HRESULT hr); FCDECL1(Object*, MissingMemberException_FormatSignature, I1Array* pPersistedSigUNSAFE); -FCDECL1(Object*, GetResourceFromDefault, StringObject* key); #define EXCEPTION_NONCONTINUABLE 0x1 // Noncontinuable exception #define EXCEPTION_UNWINDING 0x2 // Unwind is in progress diff --git a/src/coreclr/src/vm/mscorlib.h b/src/coreclr/src/vm/mscorlib.h index eb5e13c..1e743ba 100644 --- a/src/coreclr/src/vm/mscorlib.h +++ b/src/coreclr/src/vm/mscorlib.h @@ -147,9 +147,6 @@ DEFINE_FIELD_U(m_fullname, AssemblyBaseObject, m_fullname) DEFINE_FIELD_U(m_syncRoot, AssemblyBaseObject, m_pSyncRoot) DEFINE_FIELD_U(m_assembly, AssemblyBaseObject, m_pAssembly) DEFINE_CLASS(ASSEMBLY, Reflection, RuntimeAssembly) -DEFINE_FIELD(ASSEMBLY, HANDLE, m_assembly) -DEFINE_METHOD(ASSEMBLY, GET_NAME, GetName, IM_RetAssemblyName) -DEFINE_METHOD(ASSEMBLY, ON_MODULE_RESOLVE, OnModuleResolveEvent, IM_Str_RetModule) DEFINE_CLASS(ASYNCCALLBACK, System, AsyncCallback) diff --git a/src/coreclr/src/vm/object.cpp b/src/coreclr/src/vm/object.cpp index 756a5c6..387fe22 100644 --- a/src/coreclr/src/vm/object.cpp +++ b/src/coreclr/src/vm/object.cpp @@ -1983,12 +1983,12 @@ void ExceptionObject::SetStackTrace(StackTraceArray const & stackTrace, PTRARRAY CONTRACTL_END; Thread *m_pThread = GetThread(); - SpinLock::AcquireLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::AcquireLock(&g_StackTraceArrayLock); SetObjectReference((OBJECTREF*)&_stackTrace, (OBJECTREF)stackTrace.Get()); SetObjectReference((OBJECTREF*)&_dynamicMethods, (OBJECTREF)dynamicMethodArray); - SpinLock::ReleaseLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::ReleaseLock(&g_StackTraceArrayLock); } @@ -2003,7 +2003,7 @@ void ExceptionObject::SetNullStackTrace() CONTRACTL_END; Thread *m_pThread = GetThread(); - SpinLock::AcquireLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::AcquireLock(&g_StackTraceArrayLock); I1ARRAYREF stackTraceArray = NULL; PTRARRAYREF dynamicMethodArray = NULL; @@ -2011,7 +2011,7 @@ void ExceptionObject::SetNullStackTrace() SetObjectReference((OBJECTREF*)&_stackTrace, (OBJECTREF)stackTraceArray); SetObjectReference((OBJECTREF*)&_dynamicMethods, (OBJECTREF)dynamicMethodArray); - SpinLock::ReleaseLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::ReleaseLock(&g_StackTraceArrayLock); } #endif // !defined(DACCESS_COMPILE) @@ -2028,7 +2028,7 @@ void ExceptionObject::GetStackTrace(StackTraceArray & stackTrace, PTRARRAYREF * #if !defined(DACCESS_COMPILE) Thread *m_pThread = GetThread(); - SpinLock::AcquireLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::AcquireLock(&g_StackTraceArrayLock); #endif // !defined(DACCESS_COMPILE) StackTraceArray temp(_stackTrace); @@ -2040,7 +2040,7 @@ void ExceptionObject::GetStackTrace(StackTraceArray & stackTrace, PTRARRAYREF * } #if !defined(DACCESS_COMPILE) - SpinLock::ReleaseLock(&g_StackTraceArrayLock, SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + SpinLock::ReleaseLock(&g_StackTraceArrayLock); #endif // !defined(DACCESS_COMPILE) } diff --git a/src/coreclr/src/vm/simplerwlock.cpp b/src/coreclr/src/vm/simplerwlock.cpp index a4d4fc9..d3a5624 100644 --- a/src/coreclr/src/vm/simplerwlock.cpp +++ b/src/coreclr/src/vm/simplerwlock.cpp @@ -25,7 +25,6 @@ BOOL SimpleRWLock::TryEnterRead() _ASSERTE (RWLock >= 0); } while( RWLock != InterlockedCompareExchange( &m_RWLock, RWLock+1, RWLock )); - INCTHREADLOCKCOUNT(); EE_LOCK_TAKEN(this); #ifdef _DEBUG @@ -114,8 +113,7 @@ BOOL SimpleRWLock::TryEnterWrite() if( RWLock ) { return FALSE; } - - INCTHREADLOCKCOUNT(); + EE_LOCK_TAKEN(this); #ifdef _DEBUG diff --git a/src/coreclr/src/vm/simplerwlock.hpp b/src/coreclr/src/vm/simplerwlock.hpp index c609a38..858e680 100644 --- a/src/coreclr/src/vm/simplerwlock.hpp +++ b/src/coreclr/src/vm/simplerwlock.hpp @@ -184,7 +184,6 @@ public: LONG RWLock; RWLock = InterlockedDecrement(&m_RWLock); _ASSERTE (RWLock >= 0); - DECTHREADLOCKCOUNT(); EE_LOCK_RELEASED(this); } @@ -198,7 +197,6 @@ public: LONG RWLock; RWLock = InterlockedExchange (&m_RWLock, 0); _ASSERTE(RWLock == -1); - DECTHREADLOCKCOUNT(); EE_LOCK_RELEASED(this); } diff --git a/src/coreclr/src/vm/spinlock.cpp b/src/coreclr/src/vm/spinlock.cpp index c41cd29..e5b0a5e 100644 --- a/src/coreclr/src/vm/spinlock.cpp +++ b/src/coreclr/src/vm/spinlock.cpp @@ -116,23 +116,23 @@ BOOL SpinLock::OwnedByCurrentThread() } #endif -DEBUG_NOINLINE void SpinLock::AcquireLock(SpinLock *s, Thread * pThread) +DEBUG_NOINLINE void SpinLock::AcquireLock(SpinLock *s) { SCAN_SCOPE_BEGIN; STATIC_CONTRACT_GC_NOTRIGGER; - s->GetLock(pThread); + s->GetLock(); } -DEBUG_NOINLINE void SpinLock::ReleaseLock(SpinLock *s, Thread * pThread) -{ +DEBUG_NOINLINE void SpinLock::ReleaseLock(SpinLock *s) +{ SCAN_SCOPE_END; - s->FreeLock(pThread); + s->FreeLock(); } -void SpinLock::GetLock(Thread* pThread) +void SpinLock::GetLock() { CONTRACTL { @@ -158,7 +158,6 @@ void SpinLock::GetLock(Thread* pThread) } } - INCTHREADLOCKCOUNTTHREAD(pThread); #ifdef _DEBUG m_holdingThreadId.SetToCurrentThread(); dbg_EnterLock(); @@ -193,7 +192,7 @@ BOOL SpinLock::GetLockNoWait() // SpinLock::FreeLock // Release the spinlock // -void SpinLock::FreeLock(Thread* pThread) +void SpinLock::FreeLock() { CONTRACTL { @@ -202,7 +201,7 @@ void SpinLock::FreeLock(Thread* pThread) } CONTRACTL_END; - _ASSERTE(m_Initialized == Initialized); + _ASSERTE(m_Initialized == Initialized); #ifdef _DEBUG _ASSERTE(OwnedByCurrentThread()); @@ -214,7 +213,6 @@ void SpinLock::FreeLock(Thread* pThread) VolatileStore(&m_lock, (LONG)0); } - DECTHREADLOCKCOUNTTHREAD(pThread); EE_LOCK_RELEASED(this); } // SpinLock::FreeLock () diff --git a/src/coreclr/src/vm/spinlock.h b/src/coreclr/src/vm/spinlock.h index f576f6c..ae0353d 100644 --- a/src/coreclr/src/vm/spinlock.h +++ b/src/coreclr/src/vm/spinlock.h @@ -199,15 +199,13 @@ private: // The following 5 APIs must remain private. We want all entry/exit code to // occur via holders, so that exceptions will be sure to release the lock. private: - void GetLock(Thread * pThread); // Acquire lock, blocks if unsuccessful + void GetLock(); // Acquire lock, blocks if unsuccessful BOOL GetLockNoWait(); // Acquire lock, fail-fast - void FreeLock(Thread * pThread); // Release lock + void FreeLock(); // Release lock public: - static void AcquireLock(SpinLock *s, Thread * pThread); - static void ReleaseLock(SpinLock *s, Thread * pThread); - -#define SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS NULL + static void AcquireLock(SpinLock *s); + static void ReleaseLock(SpinLock *s); class Holder { @@ -219,14 +217,14 @@ public: SCAN_SCOPE_BEGIN; STATIC_CONTRACT_GC_NOTRIGGER; - m_pSpinLock->GetLock(SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + m_pSpinLock->GetLock(); } ~Holder() { SCAN_SCOPE_END; - m_pSpinLock->FreeLock(SPINLOCK_THREAD_PARAM_ONLY_IN_SOME_BUILDS); + m_pSpinLock->FreeLock(); } }; }; @@ -237,16 +235,16 @@ typedef SpinLock::Holder SpinLockHolder; SpinLockHolder __spinLockHolder(lock);\ GCX_NOTRIGGER (); -#define ACQUIRE_SPINLOCK_NO_HOLDER(lock, thread)\ +#define ACQUIRE_SPINLOCK_NO_HOLDER(lock) \ { \ - SpinLock::AcquireLock(lock, thread); \ + SpinLock::AcquireLock(lock); \ GCX_NOTRIGGER(); \ CANNOTTHROWCOMPLUSEXCEPTION(); \ STATIC_CONTRACT_NOTHROW; \ -#define RELEASE_SPINLOCK_NO_HOLDER(lock, thread)\ - SpinLock::ReleaseLock(lock, thread); \ +#define RELEASE_SPINLOCK_NO_HOLDER(lock) \ + SpinLock::ReleaseLock(lock); \ } \ __inline BOOL IsOwnerOfSpinLock (LPVOID lock) diff --git a/src/coreclr/src/vm/threads.h b/src/coreclr/src/vm/threads.h index c8e0f9b..9a6466c 100644 --- a/src/coreclr/src/vm/threads.h +++ b/src/coreclr/src/vm/threads.h @@ -429,11 +429,6 @@ public: inline BOOL dbgOnly_IsSpecialEEThread() { return FALSE; } -#define INCTHREADLOCKCOUNT() { } -#define DECTHREADLOCKCOUNT() { } -#define INCTHREADLOCKCOUNTTHREAD(thread) { } -#define DECTHREADLOCKCOUNTTHREAD(thread) { } - #define FORBIDGC_LOADER_USE_ENABLED() false #define ENABLE_FORBID_GC_LOADER_USE_IN_THIS_SCOPE() ; @@ -5550,13 +5545,6 @@ struct PendingSync void Restore(BOOL bRemoveFromSB); }; - -#define INCTHREADLOCKCOUNT() { } -#define DECTHREADLOCKCOUNT() { } -#define INCTHREADLOCKCOUNTTHREAD(thread) { } -#define DECTHREADLOCKCOUNTTHREAD(thread) { } - - // -------------------------------------------------------------------------------- // GCHolder is used to implement the normal GCX_ macros. // -- 2.7.4