diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2018-11-13 22:51:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 22:51:20 +0100 |
commit | 89262cf66efe776a17c322efcbe896cc3073b446 (patch) | |
tree | 1cee8eb56dcb1982766a0ae04c4ccc75e0d2273b /src/vm/appdomain.cpp | |
parent | e586793e0fbf0fa3d42e4519663ed2d977198a23 (diff) | |
download | coreclr-89262cf66efe776a17c322efcbe896cc3073b446.tar.gz coreclr-89262cf66efe776a17c322efcbe896cc3073b446.tar.bz2 coreclr-89262cf66efe776a17c322efcbe896cc3073b446.zip |
Change GetAppDomain to return AppDomain from the global static (#20910)
* Change GetAppDomain to return it from the global static
The current implementation of the GetAppDomain takes it from the TLS for
the current thread. But we only have one AppDomain in the system, so we
can change it to return just that one.
I have still left the ThreadLocalInfo.m_pAppDomain and its setter
present, because SOS uses that to access the AppDomain and the SOS needs
to be runtime versino agnostic.
This makes it to perform better for Unix where accessing TLS is not
trivial.
* Move the AppDomain instance pointer to own static
To enable access to the one and only AppDomain without unnecessary
indirections, I have moved the pointer out of the SystemDomain class.
Diffstat (limited to 'src/vm/appdomain.cpp')
-rw-r--r-- | src/vm/appdomain.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index a3a2602a30..368725fd07 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -116,6 +116,9 @@ SVAL_IMPL(BOOL, SystemDomain, s_fForceDebug); SVAL_IMPL(BOOL, SystemDomain, s_fForceProfiling); SVAL_IMPL(BOOL, SystemDomain, s_fForceInstrument); +// The one and only AppDomain +AppDomain* AppDomain::m_pTheAppDomain = NULL; + #ifndef DACCESS_COMPILE // Base Domain Statics @@ -2071,8 +2074,8 @@ void SystemDomain::Attach() // We need to initialize the memory pools etc. for the system domain. m_pSystemDomain->BaseDomain::Init(); // Setup the memory heaps - // Create the default domain - m_pSystemDomain->CreateDefaultDomain(); + // Create the one and only app domain + AppDomain::Create(); SharedDomain::Attach(); // Each domain gets its own ReJitManager, and ReJitManager has its own static @@ -2113,8 +2116,9 @@ void SystemDomain::DetachEnd() { GCX_PREEMP(); m_pSystemDomain->ClearFusionContext(); - if (m_pSystemDomain->m_pDefaultDomain) - m_pSystemDomain->m_pDefaultDomain->ClearFusionContext(); + AppDomain* pAppDomain = GetAppDomain(); + if (pAppDomain) + pAppDomain->ClearFusionContext(); } } @@ -3575,7 +3579,7 @@ StackWalkAction SystemDomain::CallersMethodCallback(CrawlFrame* pCf, VOID* data) extern CompilationDomain * theDomain; #endif -void SystemDomain::CreateDefaultDomain() +void AppDomain::Create() { STANDARD_VM_CONTRACT; @@ -3585,25 +3589,25 @@ void SystemDomain::CreateDefaultDomain() AppDomainRefHolder pDomain(new AppDomain()); #endif - SystemDomain::LockHolder lh; pDomain->Init(); // need to make this assignment here since we'll be releasing // the lock before calling AddDomain. So any other thread // grabbing this lock after we release it will find that // the COM Domain has already been created - m_pDefaultDomain = pDomain; _ASSERTE (pDomain->GetId().m_dwId == DefaultADID); // allocate a Virtual Call Stub Manager for the default domain - m_pDefaultDomain->InitVSD(); + pDomain->InitVSD(); pDomain->SetStage(AppDomain::STAGE_OPEN); pDomain.SuppressRelease(); + m_pTheAppDomain = pDomain; + LOG((LF_CLASSLOADER | LF_CORDB, LL_INFO10, - "Created default domain at %p\n", m_pDefaultDomain)); + "Created the app domain at %p\n", m_pTheAppDomain)); } #ifdef DEBUGGING_SUPPORTED @@ -3957,7 +3961,6 @@ void AppDomain::Init() CONTRACTL { STANDARD_VM_CHECK; - PRECONDITION(SystemDomain::IsUnderDomainLock()); } CONTRACTL_END; @@ -9618,9 +9621,9 @@ SystemDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, { m_pSystemAssembly->EnumMemoryRegions(flags); } - if (m_pDefaultDomain.IsValid()) + if (AppDomain::GetCurrentDomain()) { - m_pDefaultDomain->EnumMemoryRegions(flags, true); + AppDomain::GetCurrentDomain()->EnumMemoryRegions(flags, true); } m_appDomainIndexList.EnumMem(); |