Delete dead code related to MDAs (#38825)
authorJan Kotas <jkotas@microsoft.com>
Tue, 7 Jul 2020 15:05:20 +0000 (08:05 -0700)
committerGitHub <noreply@github.com>
Tue, 7 Jul 2020 15:05:20 +0000 (08:05 -0700)
- Unused QCall
- Unused arguments

16 files changed:
src/coreclr/src/System.Private.CoreLib/src/System/StubHelpers.cs
src/coreclr/src/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
src/coreclr/src/vm/appdomain.cpp
src/coreclr/src/vm/comsynchronizable.cpp
src/coreclr/src/vm/comsynchronizable.h
src/coreclr/src/vm/dllimport.cpp
src/coreclr/src/vm/ecalllist.h
src/coreclr/src/vm/finalizerthread.cpp
src/coreclr/src/vm/interoputil.cpp
src/coreclr/src/vm/mscorlib.h
src/coreclr/src/vm/runtimecallablewrapper.cpp
src/coreclr/src/vm/stubhelpers.cpp
src/coreclr/src/vm/stubhelpers.h
src/coreclr/src/vm/threads.cpp
src/coreclr/src/vm/threads.h
src/coreclr/src/vm/win32threadpool.cpp

index f6861b7..c3f54a2 100644 (file)
@@ -1187,9 +1187,6 @@ namespace System.StubHelpers
     internal static class StubHelpers
     {
         [MethodImpl(MethodImplOptions.InternalCall)]
-        internal static extern bool IsQCall(IntPtr pMD);
-
-        [MethodImpl(MethodImplOptions.InternalCall)]
         internal static extern void InitDeclaringType(IntPtr pMD);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
index 3ec662c..29e83fa 100644 (file)
@@ -390,17 +390,10 @@ namespace System.Threading
         /// An unstarted thread can be marked to indicate that it will host a
         /// single-threaded or multi-threaded apartment.
         /// </summary>
-        private bool TrySetApartmentStateUnchecked(ApartmentState state) =>
 #if FEATURE_COMINTEROP_APARTMENT_SUPPORT
-            SetApartmentStateHelper(state, false);
-#else // !FEATURE_COMINTEROP_APARTMENT_SUPPORT
-            state == ApartmentState.Unknown;
-#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
-
-#if FEATURE_COMINTEROP_APARTMENT_SUPPORT
-        internal bool SetApartmentStateHelper(ApartmentState state, bool fireMDAOnMismatch)
+        private bool TrySetApartmentStateUnchecked(ApartmentState state)
         {
-            ApartmentState retState = (ApartmentState)SetApartmentStateNative((int)state, fireMDAOnMismatch);
+            ApartmentState retState = (ApartmentState)SetApartmentStateNative((int)state);
 
             // Special case where we pass in Unknown and get back MTA.
             //  Once we CoUninitialize the thread, the OS will still
@@ -423,7 +416,12 @@ namespace System.Threading
         internal extern int GetApartmentStateNative();
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        internal extern int SetApartmentStateNative(int state, bool fireMDAOnMismatch);
+        internal extern int SetApartmentStateNative(int state);
+#else // FEATURE_COMINTEROP_APARTMENT_SUPPORT
+        private bool TrySetApartmentStateUnchecked(ApartmentState state)
+        {
+            return state == ApartmentState.Unknown;
+        }
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
 
 #if FEATURE_COMINTEROP
index cff1b56..c7c8991 100644 (file)
@@ -1642,13 +1642,13 @@ void SystemDomain::SetThreadAptState (Thread::ApartmentState state)
 
     if(state == Thread::AS_InSTA)
     {
-        Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InSTA, TRUE);
+        Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InSTA);
         _ASSERTE(pState == Thread::AS_InSTA);
     }
     else
     {
         // If an apartment state was not explicitly requested, default to MTA
-        Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InMTA, TRUE);
+        Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InMTA);
         _ASSERTE(pState == Thread::AS_InMTA);
     }
 }
index 51c8c7f..0cad1b9 100644 (file)
@@ -853,7 +853,7 @@ FCIMPLEND
 // Indicate whether the thread will host an STA (this may fail if the thread has
 // already been made part of the MTA, use GetApartmentState or the return state
 // from this routine to check for this).
-FCIMPL3(INT32, ThreadNative::SetApartmentState, ThreadBaseObject* pThisUNSAFE, INT32 iState, CLR_BOOL fireMDAOnMismatch)
+FCIMPL2(INT32, ThreadNative::SetApartmentState, ThreadBaseObject* pThisUNSAFE, INT32 iState)
 {
     FCALL_CONTRACT;
 
@@ -896,7 +896,7 @@ FCIMPL3(INT32, ThreadNative::SetApartmentState, ThreadBaseObject* pThisUNSAFE, I
         {
             EX_TRY
             {
-                state = thread->SetApartment(state, fireMDAOnMismatch == TRUE);
+                state = thread->SetApartment(state);
             }
             EX_CATCH
             {
@@ -1021,7 +1021,7 @@ FCIMPL1(void, ThreadNative::StartupSetApartmentState, ThreadBaseObject* pThisUNS
     Thread::ApartmentState as = thread->GetExplicitApartment();
     if (as == Thread::AS_Unknown)
     {
-        thread->SetApartment(Thread::AS_InMTA, TRUE);
+        thread->SetApartment(Thread::AS_InMTA);
     }
 
     HELPER_METHOD_FRAME_END();
index d0f3bb3..4179f61 100644 (file)
@@ -79,7 +79,7 @@ public:
     static FCDECL1(INT32,   GetThreadContext,  ThreadBaseObject* pThisUNSAFE);
 #ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
     static FCDECL1(INT32,   GetApartmentState, ThreadBaseObject* pThis);
-    static FCDECL3(INT32,   SetApartmentState, ThreadBaseObject* pThisUNSAFE, INT32 iState, CLR_BOOL fireMDAOnMismatch);
+    static FCDECL2(INT32,   SetApartmentState, ThreadBaseObject* pThisUNSAFE, INT32 iState);
     static FCDECL1(void,    StartupSetApartmentState, ThreadBaseObject* pThis);
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
 
index 71cdd55..3887e9e 100644 (file)
@@ -5211,14 +5211,10 @@ MethodDesc* GetStubMethodDescFromInteropMethodDesc(MethodDesc* pMD, DWORD dwStub
 {
     STANDARD_VM_CONTRACT;
 
-    BOOL fGcMdaEnabled = FALSE;
 #ifdef FEATURE_COMINTEROP
     if (SF_IsReverseCOMStub(dwStubFlags))
     {
 #ifdef FEATURE_PREJIT
-        if (fGcMdaEnabled)
-            return NULL;
-
         // reverse COM stubs live in a hash table
         StubMethodHashTable *pHash = pMD->GetLoaderModule()->GetStubMethodHashTable();
         return (pHash == NULL ? NULL : pHash->FindMethodDesc(pMD));
@@ -5231,23 +5227,17 @@ MethodDesc* GetStubMethodDescFromInteropMethodDesc(MethodDesc* pMD, DWORD dwStub
     if (pMD->IsNDirect())
     {
         NDirectMethodDesc* pNMD = (NDirectMethodDesc*)pMD;
-        return ((fGcMdaEnabled && !pNMD->IsQCall()) ? NULL : pNMD->ndirect.m_pStubMD.GetValueMaybeNull());
+        return pNMD->ndirect.m_pStubMD.GetValueMaybeNull();
     }
 #ifdef FEATURE_COMINTEROP
     else if (pMD->IsComPlusCall() || pMD->IsGenericComPlusCall())
     {
-        if (fGcMdaEnabled)
-            return NULL;
-
         ComPlusCallInfo *pComInfo = ComPlusCallInfo::FromMethodDesc(pMD);
         return (pComInfo == NULL ? NULL : pComInfo->m_pStubMD.GetValueMaybeNull());
     }
 #endif // FEATURE_COMINTEROP
     else if (pMD->IsEEImpl())
     {
-        if (fGcMdaEnabled)
-            return NULL;
-
         DelegateEEClass *pClass = (DelegateEEClass *)pMD->GetClass();
         if (SF_IsReverseStub(dwStubFlags))
         {
index 3188f12..871bae4 100644 (file)
@@ -953,7 +953,6 @@ FCFuncStart(gMngdRefCustomMarshalerFuncs)
 FCFuncEnd()
 
 FCFuncStart(gStubHelperFuncs)
-    FCFuncElement("IsQCall", StubHelpers::IsQCall)
     FCFuncElement("InitDeclaringType", StubHelpers::InitDeclaringType)
     FCIntrinsic("GetNDirectTarget", StubHelpers::GetNDirectTarget, CORINFO_INTRINSIC_StubHelpers_GetNDirectTarget)
     FCFuncElement("GetDelegateTarget", StubHelpers::GetDelegateTarget)
index 979f05e..7d605a4 100644 (file)
@@ -379,7 +379,7 @@ DWORD WINAPI FinalizerThread::FinalizerThreadStart(void *args)
 #if defined(FEATURE_COMINTEROP_APARTMENT_SUPPORT) && !defined(FEATURE_COMINTEROP)
     // Make sure the finalizer thread is set to MTA to avoid hitting
     // DevDiv Bugs 180773 - [Stress Failure] AV at CoreCLR!SafeQueryInterfaceHelper
-    GetFinalizerThread()->SetApartment(Thread::AS_InMTA, FALSE);
+    GetFinalizerThread()->SetApartment(Thread::AS_InMTA);
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT && !FEATURE_COMINTEROP
 
     s_FinalizerThreadOK = GetFinalizerThread()->HasStarted();
index be2b589..449d37e 100644 (file)
@@ -1486,7 +1486,7 @@ VOID EnsureComStarted(BOOL fCoInitCurrentThread)
         // COM+ objects are now apartment agile), we only care that a CoInitializeEx
         // has been performed on this thread by us.
         if (fCoInitCurrentThread)
-            GetThread()->SetApartment(Thread::AS_InMTA, FALSE);
+            GetThread()->SetApartment(Thread::AS_InMTA);
 
         // set the finalizer event
         FinalizerThread::EnableFinalization();
index d76d1d4..1f664b7 100644 (file)
@@ -979,7 +979,6 @@ DEFINE_METHOD(BUFFER,               MEMCPY_PTRBYTE_ARRBYTE, Memcpy,
 DEFINE_METHOD(BUFFER,               MEMCPY,                 Memcpy,                 SM_PtrByte_PtrByte_Int_RetVoid)
 
 DEFINE_CLASS(STUBHELPERS,           StubHelpers,            StubHelpers)
-DEFINE_METHOD(STUBHELPERS,          IS_QCALL,               IsQCall,                    SM_IntPtr_RetBool)
 DEFINE_METHOD(STUBHELPERS,          INIT_DECLARING_TYPE,    InitDeclaringType,          SM_IntPtr_RetVoid)
 DEFINE_METHOD(STUBHELPERS,          GET_NDIRECT_TARGET,     GetNDirectTarget,           SM_IntPtr_RetIntPtr)
 DEFINE_METHOD(STUBHELPERS,          GET_DELEGATE_TARGET,    GetDelegateTarget,          SM_Delegate_RefIntPtr_RetIntPtr)
index ea93e64..d33c2e5 100644 (file)
@@ -2225,7 +2225,7 @@ HRESULT RCW::SafeQueryInterfaceRemoteAware(REFIID iid, IUnknown** ppResUnk)
     if (hr == CO_E_OBJNOTCONNECTED || hr == RPC_E_INVALID_OBJECT || hr == RPC_E_INVALID_OBJREF || hr == CO_E_OBJNOTREG)
     {
         // set apartment state
-        GetThread()->SetApartment(Thread::AS_InMTA, FALSE);
+        GetThread()->SetApartment(Thread::AS_InMTA);
 
         // Release the stream of the IUnkEntry to force UnmarshalIUnknownForCurrContext
         // to remarshal to the stream.
index d280318..be4149c 100644 (file)
@@ -496,13 +496,6 @@ FCIMPL0(void, StubHelpers::ClearLastError)
 }
 FCIMPLEND
 
-FCIMPL1(FC_BOOL_RET, StubHelpers::IsQCall, NDirectMethodDesc* pNMD)
-{
-    FCALL_CONTRACT;
-    FC_RETURN_BOOL(pNMD->IsQCall());
-}
-FCIMPLEND
-
 NOINLINE static void InitDeclaringTypeHelper(MethodTable *pMT)
 {
     FC_INNER_PROLOG(StubHelpers::InitDeclaringType);
index 5c047bd..d774941 100644 (file)
@@ -61,7 +61,6 @@ public:
 
     static FCDECL0(void,            SetLastError            );
     static FCDECL0(void,            ClearLastError          );
-    static FCDECL1(FC_BOOL_RET,     IsQCall,                NDirectMethodDesc* pNMD);
     static FCDECL1(void,            InitDeclaringType,      NDirectMethodDesc* pMND);
     static FCDECL1(void*,           GetNDirectTarget,       NDirectMethodDesc* pNMD);
     static FCDECL2(void*,           GetDelegateTarget,      DelegateObject *pThisUNSAFE, UINT_PTR *ppStubArg);
index bdc1734..2e52ab3 100644 (file)
@@ -4722,7 +4722,7 @@ BOOL Thread::PrepareApartmentAndContext()
         FastInterlockAnd ((ULONG *) &m_State, ~TS_InSTA & ~TS_InMTA);
 
         // Attempt to set the requested apartment state.
-        SetApartment(aState, FALSE);
+        SetApartment(aState);
     }
 
     // In the case where we own the thread and we have switched it to a different
@@ -4909,9 +4909,7 @@ VOID Thread::ResetApartment()
 // achieved is returned and may differ from the input state if someone managed
 // to call CoInitializeEx on this thread first (note that calls to SetApartment
 // made before the thread has started are guaranteed to succeed).
-// The fFireMDAOnMismatch indicates if we should fire the apartment state probe
-// on an apartment state mismatch.
-Thread::ApartmentState Thread::SetApartment(ApartmentState state, BOOL fFireMDAOnMismatch)
+Thread::ApartmentState Thread::SetApartment(ApartmentState state)
 {
     CONTRACTL {
         THROWS;
@@ -7240,7 +7238,7 @@ void Thread::DoExtraWorkForFinalizer()
 #ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
     if (RequiresCoInitialize())
     {
-        SetApartment(AS_InMTA, FALSE);
+        SetApartment(AS_InMTA);
     }
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
 
index bb38034..7fad0bd 100644 (file)
@@ -2954,9 +2954,7 @@ public:
     // achieved is returned and may differ from the input state if someone managed to
     // call CoInitializeEx on this thread first (note that calls to SetApartment made
     // before the thread has started are guaranteed to succeed).
-    // The fFireMDAOnMismatch indicates if we should fire the apartment state probe
-    // on an apartment state mismatch.
-    ApartmentState SetApartment(ApartmentState state, BOOL fFireMDAOnMismatch);
+    ApartmentState SetApartment(ApartmentState state);
 
     // when we get apartment tear-down notification,
     // we want reset the apartment state we cache on the thread
index bd9f7e0..d691f79 100644 (file)
@@ -1895,7 +1895,7 @@ Work:
             pThread->ChooseThreadCPUGroupAffinity();
 
             #ifdef FEATURE_COMINTEROP
-            if (pThread->SetApartment(Thread::AS_InMTA, TRUE) != Thread::AS_InMTA)
+            if (pThread->SetApartment(Thread::AS_InMTA) != Thread::AS_InMTA)
             {
                 // counts volatile read paired with CompareExchangeCounts loop set
                 counts = WorkerCounter.DangerousGetDirtyCounts();
@@ -2142,7 +2142,7 @@ Exit:
 
 #ifdef FEATURE_COMINTEROP
     if (pThread) {
-        pThread->SetApartment(Thread::AS_Unknown, TRUE);
+        pThread->SetApartment(Thread::AS_Unknown);
         pThread->CoUninitialize();
     }
 
@@ -3254,7 +3254,7 @@ DWORD WINAPI ThreadpoolMgr::CompletionPortThreadStart(LPVOID lpArgs)
         }
     }
 
-    if (pThread && pThread->SetApartment(Thread::AS_InMTA, TRUE) != Thread::AS_InMTA)
+    if (pThread && pThread->SetApartment(Thread::AS_InMTA) != Thread::AS_InMTA)
     {
         // @todo: should we log the failure
         goto Exit;
@@ -3279,7 +3279,7 @@ Top:
                 pThread->ChooseThreadCPUGroupAffinity();
 
 #ifdef FEATURE_COMINTEROP
-                if (pThread->SetApartment(Thread::AS_InMTA, TRUE) != Thread::AS_InMTA)
+                if (pThread->SetApartment(Thread::AS_InMTA) != Thread::AS_InMTA)
                 {
                     // @todo: should we log the failure
                     goto Exit;
@@ -3617,7 +3617,7 @@ Exit:
 
 #ifdef FEATURE_COMINTEROP
     if (pThread) {
-        pThread->SetApartment(Thread::AS_Unknown, TRUE);
+        pThread->SetApartment(Thread::AS_Unknown);
         pThread->CoUninitialize();
     }
     // Couninit the worker thread
@@ -4517,10 +4517,10 @@ DWORD WINAPI ThreadpoolMgr::TimerThreadStart(LPVOID p)
     LastTickCount = GetTickCount();
 
 #ifdef FEATURE_COMINTEROP
-    if (pThread->SetApartment(Thread::AS_InMTA, TRUE) != Thread::AS_InMTA)
+    if (pThread->SetApartment(Thread::AS_InMTA) != Thread::AS_InMTA)
     {
         // @todo: should we log the failure
-        goto Exit;
+        return 0;
     }
 #endif // FEATURE_COMINTEROP
 
@@ -4536,16 +4536,7 @@ DWORD WINAPI ThreadpoolMgr::TimerThreadStart(LPVOID p)
 #endif
     }
 
-#ifdef FEATURE_COMINTEROP
-// unreachable code
-//    if (pThread) {
-//        pThread->SetApartment(Thread::AS_Unknown, TRUE);
-//    }
-Exit:
-
-    // @todo: replace with host provided ExitThread
-    return 0;
-#endif
+    // unreachable
 }
 
 void ThreadpoolMgr::TimerThreadFire()