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
// 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
{
GCX_PREEMP();
m_pSystemDomain->ClearFusionContext();
- if (m_pSystemDomain->m_pDefaultDomain)
- m_pSystemDomain->m_pDefaultDomain->ClearFusionContext();
+ AppDomain* pAppDomain = GetAppDomain();
+ if (pAppDomain)
+ pAppDomain->ClearFusionContext();
}
}
extern CompilationDomain * theDomain;
#endif
-void SystemDomain::CreateDefaultDomain()
+void AppDomain::Create()
{
STANDARD_VM_CONTRACT;
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
CONTRACTL
{
STANDARD_VM_CHECK;
- PRECONDITION(SystemDomain::IsUnderDomainLock());
}
CONTRACTL_END;
{
m_pSystemAssembly->EnumMemoryRegions(flags);
}
- if (m_pDefaultDomain.IsValid())
+ if (AppDomain::GetCurrentDomain())
{
- m_pDefaultDomain->EnumMemoryRegions(flags, true);
+ AppDomain::GetCurrentDomain()->EnumMemoryRegions(flags, true);
}
m_appDomainIndexList.EnumMem();
#ifndef DACCESS_COMPILE
AppDomain();
virtual ~AppDomain();
+ static void Create();
#endif
+
DomainAssembly* FindDomainAssembly(Assembly*);
void EnterContext(Thread* pThread, Context* pCtx,ContextTransitionFrame *pFrame);
-#ifndef DACCESS_COMPILE
//-----------------------------------------------------------------------------------------------------------------
// Convenience wrapper for ::GetAppDomain to provide better encapsulation.
static AppDomain * GetCurrentDomain()
- { return ::GetAppDomain(); }
-#endif //!DACCESS_COMPILE
+ { return m_pTheAppDomain; }
//-----------------------------------------------------------------------------------------------------------------
// Initializes an AppDomain. (this functions is not called from the SystemDomain)
#endif
private:
+ // The one and only AppDomain
+ static AppDomain* m_pTheAppDomain;
+
SString m_friendlyName;
PTR_Assembly m_pRootAssembly;
{
LIMITED_METHOD_DAC_CONTRACT;
- return m_pDefaultDomain;
+ return AppDomain::GetCurrentDomain();
}
// Notification when an assembly is loaded into the system domain
{
STANDARD_VM_CONTRACT;
- m_pDefaultDomain = NULL;
m_pDelayedUnloadListOfLoaderAllocators=NULL;
m_GlobalAllocator.Init(this);
PTR_PEAssembly m_pSystemFile; // Single assembly (here for quicker reference);
PTR_Assembly m_pSystemAssembly; // Single assembly (here for quicker reference);
- PTR_AppDomain m_pDefaultDomain; // Default domain for COM+ classes exposed through IClassFactory.
GlobalLoaderAllocator m_GlobalAllocator;