summaryrefslogtreecommitdiff
path: root/src/vm/appdomain.hpp
diff options
context:
space:
mode:
authorDavid Wrighton <davidwr@microsoft.com>2019-04-03 15:54:05 -0700
committerGitHub <noreply@github.com>2019-04-03 15:54:05 -0700
commitd3e39bc2f81e3dbf9e4b96347f62b49d8700336c (patch)
tree78b72499a0f38e9dbf6ae4d6d24c77779ac543dc /src/vm/appdomain.hpp
parenta7dd6192530dec1d424c359233a1b92f559fa92a (diff)
downloadcoreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.tar.gz
coreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.tar.bz2
coreclr-d3e39bc2f81e3dbf9e4b96347f62b49d8700336c.zip
Remove ADID and ADIndex from CoreCLR (#23588)
- Remove concept of AppDomain from object api in VM - Various infrastructure around entering/leaving appdomains is removed - Add small implementation of GetAppDomain for use by DAC (to match existing behavior) - Simplify finalizer thread operations - Eliminate AppDomain::Terminate - Remove use of ADID from stresslog - Remove thread enter/leave tracking from AppDomain - Remove unused asm constants across all architectures - Re-order header inclusion order to put gcenv.h before handletable - Remove retail only sync block code involving appdomain index
Diffstat (limited to 'src/vm/appdomain.hpp')
-rw-r--r--src/vm/appdomain.hpp262
1 files changed, 10 insertions, 252 deletions
diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp
index 8cfd08cc02..edf2c0ba3b 100644
--- a/src/vm/appdomain.hpp
+++ b/src/vm/appdomain.hpp
@@ -887,14 +887,12 @@ private:
FileLoadLevel m_level;
DomainFile *m_pDomainFile;
HRESULT m_cachedHR;
- ADID m_AppDomainId;
public:
static FileLoadLock *Create(PEFileListLock *pLock, PEFile *pFile, DomainFile *pDomainFile);
~FileLoadLock();
DomainFile *GetDomainFile();
- ADID GetAppDomainId();
FileLoadLevel GetLoadLevel();
// CanAcquire will return FALSE if Acquire will definitely not take the lock due
@@ -1031,16 +1029,6 @@ class BaseDomain
VPTR_UNIQUE(VPTR_UNIQUE_BaseDomain)
protected:
- // These 2 variables are only used on the AppDomain, but by placing them here
- // we reduce the cost of keeping the asmconstants file up to date.
-
- // The creation sequence number of this app domain (starting from 1)
- // This ID is generated by the code:SystemDomain::GetNewAppDomainId routine
- // The ID are recycled.
- //
- // see also code:ADID
- ADID m_dwId;
-
DomainLocalBlock m_sDomainLocalBlock;
public:
@@ -1059,19 +1047,7 @@ public:
virtual ~BaseDomain() {}
void Init();
void Stop();
- void Terminate();
- // ID to uniquely identify this AppDomain - used by the AppDomain publishing
- // service (to publish the list of all appdomains present in the process),
- // which in turn is used by, for eg., the debugger (to decide which App-
- // Domain(s) to attach to).
- // This is also used by Remoting for routing cross-appDomain calls.
- ADID GetId (void)
- {
- LIMITED_METHOD_DAC_CONTRACT;
- return m_dwId;
- }
-
virtual BOOL IsAppDomain() { LIMITED_METHOD_DAC_CONTRACT; return FALSE; }
BOOL IsSharedDomain() { LIMITED_METHOD_DAC_CONTRACT; return FALSE; }
@@ -1815,25 +1791,11 @@ public:
// the critical sections
void Stop();
- // Gets rid of resources
- void Terminate();
-
-#ifdef FEATURE_PREJIT
- //assembly cleanup that requires suspended runtime
- void DeleteNativeCodeRanges();
-#endif
-
// final assembly cleanup
- void ShutdownAssemblies();
- void ShutdownFreeLoaderAllocators(BOOL bFromManagedCode);
+ void ShutdownFreeLoaderAllocators();
void ReleaseFiles();
-
- // Remove the Appdomain for the system and cleans up. This call should not be
- // called from shut down code.
- void CloseDomain();
-
virtual BOOL IsAppDomain() { LIMITED_METHOD_DAC_CONTRACT; return TRUE; }
virtual PTR_AppDomain AsAppDomain() { LIMITED_METHOD_CONTRACT; return dac_cast<PTR_AppDomain>(this); }
@@ -2123,7 +2085,6 @@ public:
PathIterator IterateNativeDllSearchDirectories();
void SetNativeDllSearchDirectories(LPCWSTR paths);
BOOL HasNativeDllSearchDirectories();
- void ShutdownNativeDllSearchDirectories();
public:
SIZE_T GetAssemblyCount()
@@ -2453,14 +2414,6 @@ public:
//****************************************************************************************
// Get the proxy for this app domain
- ADIndex GetIndex()
- {
- LIMITED_METHOD_CONTRACT;
- SUPPORTS_DAC;
-
- return m_dwIndex;
- }
-
TPIndex GetTPIndex()
{
LIMITED_METHOD_CONTRACT;
@@ -2502,70 +2455,6 @@ public:
static void ExceptionUnwind(Frame *pFrame);
-#ifdef _DEBUG
- void TrackADThreadEnter(Thread *pThread, Frame *pFrame);
- void TrackADThreadExit(Thread *pThread, Frame *pFrame);
- void DumpADThreadTrack();
-#endif
-
-#ifndef DACCESS_COMPILE
- void ThreadEnter(Thread *pThread, Frame *pFrame)
- {
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
-
-#ifdef _DEBUG
- if (LoggingOn(LF_APPDOMAIN, LL_INFO100))
- TrackADThreadEnter(pThread, pFrame);
- else
-#endif
- {
- InterlockedIncrement((LONG*)&m_dwThreadEnterCount);
- LOG((LF_APPDOMAIN, LL_INFO1000, "AppDomain::ThreadEnter %p to [%d] (%8.8x) %S count %d\n",
- pThread,GetId().m_dwId, this,
- GetFriendlyNameForLogging(),GetThreadEnterCount()));
-#if _DEBUG_AD_UNLOAD
- printf("AppDomain::ThreadEnter %p to [%d] (%8.8x) %S count %d\n",
- pThread, GetId().m_dwId, this,
- GetFriendlyNameForLogging(), GetThreadEnterCount());
-#endif
- }
- }
-
- void ThreadExit(Thread *pThread, Frame *pFrame)
- {
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
-
-#ifdef _DEBUG
- if (LoggingOn(LF_APPDOMAIN, LL_INFO100)) {
- TrackADThreadExit(pThread, pFrame);
- }
- else
-#endif
- {
- LONG result;
- result = InterlockedDecrement((LONG*)&m_dwThreadEnterCount);
- _ASSERTE(result >= 0);
- LOG((LF_APPDOMAIN, LL_INFO1000, "AppDomain::ThreadExit from [%d] (%8.8x) %S count %d\n",
- this, GetId().m_dwId,
- GetFriendlyNameForLogging(), GetThreadEnterCount()));
- }
- }
-#endif // DACCESS_COMPILE
-
- ULONG GetThreadEnterCount()
- {
- LIMITED_METHOD_CONTRACT;
- return m_dwThreadEnterCount;
- }
-
- BOOL OnlyOneThreadLeft()
- {
- LIMITED_METHOD_CONTRACT;
- return m_dwThreadEnterCount==1 || m_dwThreadsStillInAppDomain ==1;
- }
-
static void RefTakerAcquire(AppDomain* pDomain)
{
WRAPPER_NO_CONTRACT;
@@ -2671,8 +2560,6 @@ public:
_ASSERTE(m_dwCreationHolders > -1);
}
#endif
- BOOL IsRunningIn(Thread* pThread);
-
BOOL NotReadyForManagedCode()
{
LIMITED_METHOD_CONTRACT;
@@ -2897,8 +2784,8 @@ private:
MODE_ANY;
}
CONTRACTL_END;
- STRESS_LOG2(LF_APPDOMAIN, LL_INFO100,"Updating AD stage, ADID=%d, stage=%d\n",GetId().m_dwId,stage);
- TESTHOOKCALL(AppDomainStageChanged(GetId().m_dwId,m_Stage,stage));
+ STRESS_LOG1(LF_APPDOMAIN, LL_INFO100,"Updating AD stage, stage=%d\n",stage);
+ TESTHOOKCALL(AppDomainStageChanged(DefaultADID,m_Stage,stage));
Stage lastStage=m_Stage;
while (lastStage !=stage)
lastStage = (Stage)FastInterlockCompareExchange((LONG*)&m_Stage,stage,lastStage);
@@ -2924,15 +2811,6 @@ public:
return GetLoaderAllocator()->GetGCRefPoint();
}
- static USHORT GetOffsetOfId()
- {
- LIMITED_METHOD_CONTRACT;
- size_t ofs = offsetof(class AppDomain, m_dwId);
- _ASSERTE(FitsInI2(ofs));
- return (USHORT)ofs;
- }
-
-
void AddMemoryPressure();
void RemoveMemoryPressure();
@@ -2986,9 +2864,6 @@ private:
RCWRefCache *m_pRCWRefCache;
#endif // FEATURE_COMINTEROP
- // The index of this app domain among existing app domains (starting from 1)
- ADIndex m_dwIndex;
-
// The thread-pool index of this app domain among existing app domains (starting from 1)
TPIndex m_tpIndex;
@@ -3003,18 +2878,6 @@ private:
Volatile<ULONGLONG> m_ullTotalProcessorUsage;
#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING
-#ifdef _DEBUG
- struct ThreadTrackInfo;
- typedef CDynArray<ThreadTrackInfo *> ThreadTrackInfoList;
- ThreadTrackInfoList *m_pThreadTrackInfoList;
- DWORD m_TrackSpinLock;
-#endif
-
- // The number of times we have entered this AD
- ULONG m_dwThreadEnterCount;
- // The number of threads that have entered this AD, for ADU only
- ULONG m_dwThreadsStillInAppDomain;
-
Volatile<Stage> m_Stage;
ArrayList m_failedAssemblies;
@@ -3274,35 +3137,13 @@ class SystemDomain : public BaseDomain
friend class AppDomainIterator;
friend class UnsafeAppDomainIterator;
friend class ClrDataAccess;
- friend Frame *Thread::IsRunningIn(AppDomain* pDomain, int *count);
VPTR_VTABLE_CLASS(SystemDomain, BaseDomain)
VPTR_UNIQUE(VPTR_UNIQUE_SystemDomain)
- static AppDomain *GetAppDomainAtId(ADID indx);
public:
static PTR_LoaderAllocator GetGlobalLoaderAllocator();
- static AppDomain* GetAppDomainFromId(ADID indx,DWORD ADValidityKind)
- {
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- MODE_COOPERATIVE;
- }
- CONTRACTL_END;
- AppDomain* pRetVal;
- if (indx.m_dwId==DefaultADID)
- pRetVal= SystemDomain::System()->DefaultDomain();
- else
- pRetVal= GetAppDomainAtId(indx);
-#ifdef _DEBUG
- // Only call CheckADValidity in DEBUG builds for non-NULL return values
- if (pRetVal != NULL)
- CheckADValidity(pRetVal, ADValidityKind);
-#endif
- return pRetVal;
- }
+
//****************************************************************************************
//
// To be run during the initial start up of the EE. This must be
@@ -3333,7 +3174,6 @@ public:
#endif
void Init();
void Stop();
- void Terminate();
static void LazyInitGlobalStringLiteralMap();
//****************************************************************************************
@@ -3465,72 +3305,6 @@ public:
static HRESULT NotifyProfilerShutdown();
#endif // PROFILING_SUPPORTED
- //****************************************************************************************
- // return the dev path
-
-#ifndef DACCESS_COMPILE
- void IncrementNumAppDomains ()
- {
- LIMITED_METHOD_CONTRACT;
-
- s_dNumAppDomains++;
- }
-
- void DecrementNumAppDomains ()
- {
- LIMITED_METHOD_CONTRACT;
-
- s_dNumAppDomains--;
- }
-
- ULONG GetNumAppDomains ()
- {
- LIMITED_METHOD_CONTRACT;
-
- return s_dNumAppDomains;
- }
-#endif // DACCESS_COMPILE
-
- //
- // AppDomains currently have both an index and an ID. The
- // index is "densely" assigned; indices are reused as domains
- // are unloaded. The Id's on the other hand, are not reclaimed
- // so may be sparse.
- //
- // Another important difference - it's OK to call GetAppDomainAtId for
- // an unloaded domain (it will return NULL), while GetAppDomainAtIndex
- // will assert if the domain is unloaded.
- //<TODO>
- // @todo:
- // I'm not really happy with this situation, but
- // (a) we need an ID for a domain which will last the process lifetime for the
- // remoting code.
- // (b) we need a dense ID, for the handle table index.
- // So for now, I'm leaving both, but hopefully in the future we can come up
- // with something better.
- //</TODO>
-
- static ADIndex GetNewAppDomainIndex(AppDomain * pAppDomain);
- static void ReleaseAppDomainIndex(ADIndex indx);
- static PTR_AppDomain GetAppDomainAtIndex(ADIndex indx);
- static PTR_AppDomain TestGetAppDomainAtIndex(ADIndex indx);
- static DWORD GetCurrentAppDomainMaxIndex()
- {
- WRAPPER_NO_CONTRACT;
-
- ArrayListStatic* list = (ArrayListStatic *)&m_appDomainIndexList;
- PREFIX_ASSUME(list!=NULL);
- return list->GetCount();
- }
-
- static ADID GetNewAppDomainId(AppDomain *pAppDomain);
- static void ReleaseAppDomainId(ADID indx);
-
-#ifndef DACCESS_COMPILE
- static ADID GetCurrentAppDomainMaxId() { ADID id; id.m_dwId=m_appDomainIdList.GetCount(); return id;}
-#endif // DACCESS_COMPILE
-
-
#ifndef DACCESS_COMPILE
DWORD RequireAppDomainCleanup()
{
@@ -3690,14 +3464,10 @@ private:
static size_t m_totalSurvivedBytes;
#endif //FEATURE_APPDOMAIN_RESOURCE_MONITORING
- SVAL_DECL(ArrayListStatic, m_appDomainIndexList);
#ifndef DACCESS_COMPILE
static CrstStatic m_DelayedUnloadCrst;
static CrstStatic m_SystemDomainCrst;
-
- static ArrayListStatic m_appDomainIdList;
-
static GlobalStringLiteralMap *m_pGlobalStringLiteralMap;
static ULONG s_dNumAppDomains; // Maintain a count of children app domains.
@@ -3762,6 +3532,7 @@ public:
// start & end of the iteration. This iterator is considered unsafe because it does not
// reference count the various appdomains, and can only be used when the runtime is stopped,
// or external synchronization is used. (and therefore no other thread may cause the appdomain list to change.)
+// In CoreCLR, this iterator doesn't use a list as there is at most 1 AppDomain, and instead will find the only AppDomain, or not.
//
class UnsafeAppDomainIterator
{
@@ -3775,18 +3546,7 @@ public:
void Init()
{
LIMITED_METHOD_CONTRACT;
- SystemDomain* sysDomain = SystemDomain::System();
- if (sysDomain)
- {
- ArrayListStatic* list = &sysDomain->m_appDomainIndexList;
- PREFIX_ASSUME(list != NULL);
- m_i = list->Iterate();
- }
- else
- {
- m_i.SetEmpty();
- }
-
+ m_iterationCount = 0;
m_pCurrent = NULL;
}
@@ -3794,9 +3554,10 @@ public:
{
WRAPPER_NO_CONTRACT;
- while (m_i.Next())
+ if (m_iterationCount == 0)
{
- m_pCurrent = dac_cast<PTR_AppDomain>(m_i.GetElement());
+ m_iterationCount++;
+ m_pCurrent = AppDomain::GetCurrentDomain();
if (m_pCurrent != NULL &&
(m_bOnlyActive ?
m_pCurrent->IsActive() : m_pCurrent->IsValid()))
@@ -3818,7 +3579,7 @@ public:
private:
- ArrayList::Iterator m_i;
+ int m_iterationCount;
AppDomain * m_pCurrent;
BOOL m_bOnlyActive;
}; // class UnsafeAppDomainIterator
@@ -3891,7 +3652,4 @@ class AppDomainIterator : public UnsafeAppDomainIterator
#include "comreflectioncache.inl"
-#define INVALID_APPDOMAIN_ID ((DWORD)-1)
-#define CURRENT_APPDOMAIN_ID ((ADID)(DWORD)0)
-
#endif