From b3f81350c856cfd5079c52349024a8f55d0c009a Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Mon, 2 Mar 2020 19:45:33 -0800 Subject: [PATCH] Delete AppDomain::IsDefaultDomain (#33073) --- src/coreclr/src/debug/daccess/dacdbiimpl.cpp | 12 ---- src/coreclr/src/debug/daccess/dacdbiimpl.h | 3 - src/coreclr/src/debug/di/process.cpp | 15 +--- src/coreclr/src/debug/ee/debugger.cpp | 75 +------------------- src/coreclr/src/debug/ee/debugger.h | 1 - src/coreclr/src/debug/inc/dacdbiinterface.h | 18 ----- src/coreclr/src/vm/appdomain.hpp | 2 - src/coreclr/src/vm/domainfile.cpp | 8 --- src/coreclr/src/vm/finalizerthread.cpp | 5 -- src/coreclr/src/vm/threadsuspend.cpp | 4 -- src/coreclr/src/vm/virtualcallstub.cpp | 32 ++------- 11 files changed, 13 insertions(+), 162 deletions(-) diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp index 43c0ed6dcc6cb8..8c40921db72899 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.cpp +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.cpp @@ -587,18 +587,6 @@ VMPTR_OBJECTHANDLE DacDbiInterfaceImpl::GetAppDomainObject(VMPTR_AppDomain vmApp } -// Determine if the specified AppDomain is the default domain -BOOL DacDbiInterfaceImpl::IsDefaultDomain(VMPTR_AppDomain vmAppDomain) -{ - DD_ENTER_MAY_THROW; - - AppDomain * pAppDomain = vmAppDomain.GetDacPtr(); - BOOL fDefaultDomain = pAppDomain->IsDefaultDomain(); - - return fDefaultDomain; -} - - // Get the full AD friendly name for the given EE AppDomain. void DacDbiInterfaceImpl::GetAppDomainFullName( VMPTR_AppDomain vmAppDomain, diff --git a/src/coreclr/src/debug/daccess/dacdbiimpl.h b/src/coreclr/src/debug/daccess/dacdbiimpl.h index 5ead4b027f5ac7..6c2a211472c757 100644 --- a/src/coreclr/src/debug/daccess/dacdbiimpl.h +++ b/src/coreclr/src/debug/daccess/dacdbiimpl.h @@ -91,9 +91,6 @@ class DacDbiInterfaceImpl : // Get the managed AppDomain object for an AppDomain. VMPTR_OBJECTHANDLE GetAppDomainObject(VMPTR_AppDomain vmAppDomain); - // Determine if the specified AppDomain is the default domain - BOOL IsDefaultDomain(VMPTR_AppDomain vmAppDomain); - // Get the full AD friendly name for the appdomain. void GetAppDomainFullName( VMPTR_AppDomain vmAppDomain, diff --git a/src/coreclr/src/debug/di/process.cpp b/src/coreclr/src/debug/di/process.cpp index 9c5048eb300fce..d42010a7a1f5f5 100644 --- a/src/coreclr/src/debug/di/process.cpp +++ b/src/coreclr/src/debug/di/process.cpp @@ -8763,18 +8763,9 @@ CordbAppDomain * CordbProcess::CacheAppDomain(VMPTR_AppDomain vmAppDomain) // The cache will take ownership. m_appDomains.AddBaseOrThrow(pAppDomain); - // see if this is the default AppDomain - IDacDbiInterface * pDac = m_pProcess->GetDAC(); - BOOL fIsDefaultDomain = FALSE; - - fIsDefaultDomain = pDac->IsDefaultDomain(vmAppDomain); // throws - - if (fIsDefaultDomain) - { - // If this assert fires, then it likely means the target is corrupted. - TargetConsistencyCheck(m_pDefaultAppDomain == NULL); - m_pDefaultAppDomain = pAppDomain; - } + // If this assert fires, then it likely means the target is corrupted. + TargetConsistencyCheck(m_pDefaultAppDomain == NULL); + m_pDefaultAppDomain = pAppDomain; CordbAppDomain * pReturn = pAppDomain; pAppDomain.ClearAndMarkDontNeuter(); diff --git a/src/coreclr/src/debug/ee/debugger.cpp b/src/coreclr/src/debug/ee/debugger.cpp index 002e87fa951dfa..b7b3125ff140ef 100644 --- a/src/coreclr/src/debug/ee/debugger.cpp +++ b/src/coreclr/src/debug/ee/debugger.cpp @@ -9433,73 +9433,6 @@ void Debugger::SendCreateAppDomainEvent(AppDomain * pRuntimeAppDomain) } - - -// -// SendExitAppDomainEvent is called when an app domain is destroyed. -// -void Debugger::SendExitAppDomainEvent(AppDomain* pRuntimeAppDomain) -{ - CONTRACTL - { - MAY_DO_HELPER_THREAD_DUTY_THROWS_CONTRACT; - MAY_DO_HELPER_THREAD_DUTY_GC_TRIGGERS_CONTRACT; - } - CONTRACTL_END; - - if (CORDBUnrecoverableError(this)) - return; - - LOG((LF_CORDB, LL_INFO100, "D::EAD: Exit AppDomain 0x%08x.\n", - pRuntimeAppDomain)); - - STRESS_LOG2(LF_CORDB, LL_INFO10000, "D::EAD: AppDomain exit:%#08x, %#08x\n", - pRuntimeAppDomain, CORDebuggerAttached()); - - Thread *thread = g_pEEInterface->GetThread(); - // Prevent other Runtime threads from handling events. - SENDIPCEVENT_BEGIN(this, thread); - - if (CORDebuggerAttached()) - { - if (pRuntimeAppDomain->IsDefaultDomain() ) - { - // The Debugger expects to never get an unload event for the default Domain. - // Currently we should never get here because g_fProcessDetach will be true by - // the time this method is called. However, we'd like to know if this ever changes - _ASSERTE(!"Trying to deliver notification of unload for default domain" ); - return; - } - - // Send the exit appdomain event to the Right Side. - DebuggerIPCEvent* ipce = m_pRCThread->GetIPCEventSendBuffer(); - InitIPCEvent(ipce, - DB_IPCE_EXIT_APP_DOMAIN, - thread, - pRuntimeAppDomain); - m_pRCThread->SendIPCEvent(); - - // Delete any left over modules for this appdomain. - // Note that we're doing this under the lock. - if (m_pModules != NULL) - { - DebuggerDataLockHolder ch(this); - m_pModules->RemoveModules(pRuntimeAppDomain); - } - - // Stop all Runtime threads - TrapAllRuntimeThreads(); - } - else - { - LOG((LF_CORDB,LL_INFO1000, "D::EAD: Skipping SendIPCEvent because RS detached.")); - } - - SENDIPCEVENT_END; -} - - - // // LoadAssembly is called when a new Assembly gets loaded. // @@ -14914,11 +14847,9 @@ HRESULT Debugger::RemoveAppDomainFromIPC (AppDomain *pAppDomain) // UnLock the list m_pAppDomainCB->Unlock(); - // send event to debugger if one is attached - if (CORDebuggerAttached()) - { - SendExitAppDomainEvent(pAppDomain); - } + // + // The Debugger expects to never get an unload event for the default AppDomain. + // return hr; } diff --git a/src/coreclr/src/debug/ee/debugger.h b/src/coreclr/src/debug/ee/debugger.h index 478c5bb07e1d1b..54a64bdc7f896f 100644 --- a/src/coreclr/src/debug/ee/debugger.h +++ b/src/coreclr/src/debug/ee/debugger.h @@ -2539,7 +2539,6 @@ class Debugger : public DebugInterface HRESULT UpdateAppDomainEntryInIPC (AppDomain *pAppDomain); void SendCreateAppDomainEvent(AppDomain * pAppDomain); - void SendExitAppDomainEvent (AppDomain *pAppDomain); // Notify the debugger that an assembly has been loaded void LoadAssembly(DomainAssembly * pDomainAssembly); diff --git a/src/coreclr/src/debug/inc/dacdbiinterface.h b/src/coreclr/src/debug/inc/dacdbiinterface.h index 820f179f6590bc..54ee344f850813 100644 --- a/src/coreclr/src/debug/inc/dacdbiinterface.h +++ b/src/coreclr/src/debug/inc/dacdbiinterface.h @@ -309,24 +309,6 @@ class IDacDbiInterface virtual VMPTR_OBJECTHANDLE GetAppDomainObject(VMPTR_AppDomain vmAppDomain) = 0; - // - // Determine if the specified AppDomain is the default domain - // - // Arguments: - // vmAppDomain - VM pointer to the AppDomain ojbect of interest - // - // Return Value: - // TRUE if this is the default appdomain, else FALSE. - // - // Notes: - // The default domain is the only one which cannot be unloaded and exists for the life - // of the process. - // A well behaved target only has 1 default domain. - // - virtual - BOOL IsDefaultDomain(VMPTR_AppDomain vmAppDomain) = 0; - - virtual void GetAssemblyFromDomainAssembly(VMPTR_DomainAssembly vmDomainAssembly, OUT VMPTR_Assembly * vmAssembly) = 0; diff --git a/src/coreclr/src/vm/appdomain.hpp b/src/coreclr/src/vm/appdomain.hpp index c4848cff33eb89..ca52bb27ac6b84 100644 --- a/src/coreclr/src/vm/appdomain.hpp +++ b/src/coreclr/src/vm/appdomain.hpp @@ -955,8 +955,6 @@ class BaseDomain virtual BOOL IsAppDomain() { LIMITED_METHOD_DAC_CONTRACT; return FALSE; } - BOOL IsDefaultDomain() { LIMITED_METHOD_DAC_CONTRACT; return TRUE; } - PTR_LoaderAllocator GetLoaderAllocator(); virtual PTR_AppDomain AsAppDomain() { diff --git a/src/coreclr/src/vm/domainfile.cpp b/src/coreclr/src/vm/domainfile.cpp index 2adb813cf16ef0..4292a440242579 100644 --- a/src/coreclr/src/vm/domainfile.cpp +++ b/src/coreclr/src/vm/domainfile.cpp @@ -825,14 +825,6 @@ void DomainFile::ClearNativeImageStress() if (g_pConfig->RequireZaps() != EEConfig::REQUIRE_ZAPS_NONE) return; - // Its OK to ClearNativeImage even for a shared assembly, as the current PEFile will - // be discarded if we decide to share the assembly. However, we always use the same - // PEFile for the system assembly. So discarding the native image in the current - // AppDomain will actually affect the system assembly in the shared domain, and other - // appdomains may have already committed to using its ngen image. - if (GetFile()->IsSystem() && !this->GetAppDomain()->IsDefaultDomain()) - return; - if (g_IBCLogger.InstrEnabled()) return; diff --git a/src/coreclr/src/vm/finalizerthread.cpp b/src/coreclr/src/vm/finalizerthread.cpp index e313c2ec4eba43..678f849dde8504 100644 --- a/src/coreclr/src/vm/finalizerthread.cpp +++ b/src/coreclr/src/vm/finalizerthread.cpp @@ -347,7 +347,6 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args) } FinalizeAllObjects(0); - _ASSERTE(GetFinalizerThread()->GetDomain()->IsDefaultDomain()); // We may still have the finalizer thread for abort. If so the abort request is for previous finalizer method, not for next one. if (GetFinalizerThread()->IsAbortRequested()) @@ -377,8 +376,6 @@ DWORD WINAPI FinalizerThread::FinalizerThreadStart(void *args) LOG((LF_GC, LL_INFO10, "Finalizer thread starting...\n")); - _ASSERTE(GetFinalizerThread()->GetDomain()->IsDefaultDomain()); - #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 @@ -440,8 +437,6 @@ DWORD WINAPI FinalizerThread::FinalizerThreadStart(void *args) #endif UNINSTALL_UNHANDLED_MANAGED_EXCEPTION_TRAP; } - // finalizer should always park in default domain - _ASSERTE(GetThread()->GetDomain()->IsDefaultDomain()); LOG((LF_GC, LL_INFO10, "Finalizer thread done.")); diff --git a/src/coreclr/src/vm/threadsuspend.cpp b/src/coreclr/src/vm/threadsuspend.cpp index 75fd875b99b2c5..c73ed258deee41 100644 --- a/src/coreclr/src/vm/threadsuspend.cpp +++ b/src/coreclr/src/vm/threadsuspend.cpp @@ -2698,10 +2698,6 @@ void Thread::PreWorkForThreadAbort() ResetUserInterrupted(); if (IsRudeAbort()) { - AppDomain *pDomain = GetAppDomain(); - // Cannot enable the following assertion. - // We may take the lock, but the lock will be released during exception backout. - //_ASSERTE(!pDomain->IsDefaultDomain()); EPolicyAction action = GetEEPolicy()->GetDefaultAction(OPR_ThreadRudeAbortInCriticalRegion, this); switch (action) { diff --git a/src/coreclr/src/vm/virtualcallstub.cpp b/src/coreclr/src/vm/virtualcallstub.cpp index 8b32443f4b777a..3dae78cac01554 100644 --- a/src/coreclr/src/vm/virtualcallstub.cpp +++ b/src/coreclr/src/vm/virtualcallstub.cpp @@ -536,26 +536,13 @@ void VirtualCallStubManager::Init(BaseDomain *pDomain, LoaderAllocator *pLoaderA // in order to minimize the fragmentation of our rangelists // - if (parentDomain->IsDefaultDomain()) - { - indcell_heap_commit_size = 16; indcell_heap_reserve_size = 2000; - cache_entry_heap_commit_size = 16; cache_entry_heap_reserve_size = 800; + indcell_heap_commit_size = 16; indcell_heap_reserve_size = 2000; + cache_entry_heap_commit_size = 16; cache_entry_heap_reserve_size = 800; - lookup_heap_commit_size = 24; lookup_heap_reserve_size = 250; - dispatch_heap_commit_size = 24; dispatch_heap_reserve_size = 600; - resolve_heap_commit_size = 24; resolve_heap_reserve_size = 300; - vtable_heap_commit_size = 24; vtable_heap_reserve_size = 600; - } - else - { - indcell_heap_commit_size = 8; indcell_heap_reserve_size = 8; - cache_entry_heap_commit_size = 8; cache_entry_heap_reserve_size = 8; - - lookup_heap_commit_size = 8; lookup_heap_reserve_size = 8; - dispatch_heap_commit_size = 8; dispatch_heap_reserve_size = 8; - resolve_heap_commit_size = 8; resolve_heap_reserve_size = 8; - vtable_heap_commit_size = 8; vtable_heap_reserve_size = 8; - } + lookup_heap_commit_size = 24; lookup_heap_reserve_size = 250; + dispatch_heap_commit_size = 24; dispatch_heap_reserve_size = 600; + resolve_heap_commit_size = 24; resolve_heap_reserve_size = 300; + vtable_heap_commit_size = 24; vtable_heap_reserve_size = 600; #ifdef HOST_64BIT // If we're on 64-bit, there's a ton of address space, so reserve more space to @@ -1042,7 +1029,7 @@ BOOL VirtualCallStubManager::CheckIsStub_Internal(PCODE stubStartAddress) BOOL fIsOwner = isStub(stubStartAddress); #if defined(TARGET_X86) && defined(FEATURE_PREJIT) - if (!fIsOwner && parentDomain->IsDefaultDomain()) + if (!fIsOwner) { fIsOwner = (stubStartAddress == GetEEFuncEntryPoint(StubDispatchFixupStub)); } @@ -3093,8 +3080,6 @@ void VirtualCallStubManager::LogStats() return; } - BOOL isDefault = parentDomain->IsDefaultDomain(); - // Temp space to use for formatting the output. static const int FMT_STR_SIZE = 160; char szPrintStr[FMT_STR_SIZE]; @@ -3102,9 +3087,6 @@ void VirtualCallStubManager::LogStats() if (g_hStubLogFile && (stats.site_write != 0)) { - sprintf_s(szPrintStr, COUNTOF(szPrintStr), "\r\nStats for %s Manager\r\n", isDefault ? "the Default" : "an Unshared"); - WriteFile (g_hStubLogFile, szPrintStr, (DWORD) strlen(szPrintStr), &dwWriteByte, NULL); - //output counters sprintf_s(szPrintStr, COUNTOF(szPrintStr), OUTPUT_FORMAT_INT, "site_counter", stats.site_counter); WriteFile (g_hStubLogFile, szPrintStr, (DWORD) strlen(szPrintStr), &dwWriteByte, NULL);