From 4a2654124ecf38300a717db79926334703abeb70 Mon Sep 17 00:00:00 2001 From: David Wrighton Date: Wed, 24 Apr 2019 17:01:31 -0700 Subject: [PATCH] More multi-appdomain support removal (#23921) More multi-appdomain support removal - Remove DomainLocalBlock - Remove DomainModule - Remove FindDomain(File/Module/Assembly) - Remove GetDomainModule - Remove variants of GetDomain(File/Assembly) that take AppDomain parameter - Adjust contracts to be less strict - GetDomainFile/Assembly no longer need a complex contract as multi-domain support does not exist - Eliminiate uses of encoded ModuleID --- src/debug/daccess/dacdbiimpl.cpp | 18 +-- src/debug/daccess/dacdbiimplstackwalk.cpp | 4 +- src/debug/daccess/inspect.cpp | 2 +- src/debug/daccess/request.cpp | 37 +----- src/debug/ee/debugger.cpp | 8 +- src/vm/amd64/asmconstants.h | 4 - src/vm/appdomain.cpp | 141 ++------------------ src/vm/appdomain.hpp | 126 +----------------- src/vm/appdomain.inl | 12 -- src/vm/arm/asmconstants.h | 3 - src/vm/assembly.cpp | 34 +---- src/vm/assembly.hpp | 10 +- src/vm/ceeload.cpp | 207 +++--------------------------- src/vm/ceeload.h | 56 +------- src/vm/ceeload.inl | 20 +-- src/vm/class.h | 1 - src/vm/classcompat.h | 1 - src/vm/clsload.cpp | 4 +- src/vm/clsload.hpp | 2 +- src/vm/debugdebugger.cpp | 2 +- src/vm/domainfile.cpp | 4 +- src/vm/eventtrace.cpp | 8 +- src/vm/field.h | 23 ---- src/vm/jithelpers.cpp | 126 ++---------------- src/vm/jitinterface.h | 16 +-- src/vm/loaderallocator.cpp | 10 +- src/vm/methodtable.cpp | 12 +- src/vm/methodtable.h | 10 +- src/vm/methodtable.inl | 9 -- src/vm/multicorejit.cpp | 2 +- src/vm/pefile.cpp | 2 +- src/vm/profilingenumerators.cpp | 72 +---------- src/vm/proftoeeinterfaceimpl.cpp | 11 +- src/vm/proftoeeinterfaceimpl.inl | 6 +- src/vm/reflectioninvocation.cpp | 2 +- src/vm/runtimehandles.cpp | 13 +- src/vm/threadstatics.h | 3 +- src/vm/zapsig.cpp | 2 +- 38 files changed, 122 insertions(+), 901 deletions(-) diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp index 4f878cc..4d97298 100644 --- a/src/debug/daccess/dacdbiimpl.cpp +++ b/src/debug/daccess/dacdbiimpl.cpp @@ -1589,7 +1589,7 @@ void DacDbiInterfaceImpl::GetStaticsBases(TypeHandle thExact, Module * pModuleForStatics = pMT->GetModuleForStatics(); if (pModuleForStatics != NULL) { - PTR_DomainLocalModule pLocalModule = pModuleForStatics->GetDomainLocalModule(pAppDomain); + PTR_DomainLocalModule pLocalModule = pModuleForStatics->GetDomainLocalModule(); if (pLocalModule != NULL) { *ppGCStaticsBase = pLocalModule->GetGCStaticsBasePointer(pMT); @@ -2532,7 +2532,7 @@ void DacDbiInterfaceImpl::GetClassTypeInfo(TypeHandle typeH pTypeInfo->ClassTypeData.vmModule.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule)); if (pAppDomain) { - pTypeInfo->ClassTypeData.vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule->GetDomainFile(pAppDomain))); + pTypeInfo->ClassTypeData.vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule->GetDomainFile())); } else { @@ -2619,7 +2619,7 @@ void DacDbiInterfaceImpl::TypeHandleToBasicTypeInfo(TypeHandle pTypeInfo->vmModule.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule)); if (pAppDomain) { - pTypeInfo->vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule->GetDomainFile(pAppDomain))); + pTypeInfo->vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pModule->GetDomainFile())); } else { @@ -3281,7 +3281,7 @@ CORDB_ADDRESS DacDbiInterfaceImpl::GetCollectibleTypeStaticAddress(VMPTR_FieldDe // // Get the address // - PTR_VOID base = pFieldDesc->GetBaseInDomain(pAppDomain); + PTR_VOID base = pFieldDesc->GetBase(); if (base == PTR_NULL) { return PTR_HOST_TO_TADDR(NULL); @@ -3368,7 +3368,7 @@ void DacDbiInterfaceImpl::GetSimpleType(VMPTR_AppDomain vmAppDomain, if (pAppDomain) { - pVmDomainFile->SetHostPtr(pModule->GetDomainFile(pAppDomain)); + pVmDomainFile->SetHostPtr(pModule->GetDomainFile()); if (pVmDomainFile->IsNull()) ThrowHR(CORDBG_E_TARGET_INCONSISTENT); } @@ -3449,7 +3449,7 @@ void DacDbiInterfaceImpl::GetStackFramesFromException(VMPTR_Object vmObject, Dac _ASSERTE(pDomain != NULL); - pDomainFile = pModule->FindDomainFile(pDomain); + pDomainFile = pModule->GetDomainFile(); _ASSERTE(pDomainFile != NULL); currentFrame.vmAppDomain.SetHostPtr(pDomain); @@ -3963,7 +3963,7 @@ void DacDbiInterfaceImpl::ResolveTypeReference(const TypeRefData * pTypeRefInfo, AppDomain * pAppDomain = pDomainFile->GetAppDomain(); - pTargetRefInfo->vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pTargetModule->GetDomainFile(pAppDomain))); + pTargetRefInfo->vmDomainFile.SetDacTargetPtr(PTR_HOST_TO_TADDR(pTargetModule->GetDomainFile())); pTargetRefInfo->typeToken = targetTypeDef; } else @@ -4386,7 +4386,7 @@ VMPTR_DomainAssembly DacDbiInterfaceImpl::ResolveAssembly( Assembly * pAssembly = pModule->LookupAssemblyRef(tkAssemblyRef); if (pAssembly != NULL) { - DomainAssembly * pDomainAssembly = pAssembly->FindDomainAssembly(pAppDomain); + DomainAssembly * pDomainAssembly = pAssembly->GetDomainAssembly(); vmDomainAssembly.SetHostPtr(pDomainAssembly); } return vmDomainAssembly; @@ -6806,7 +6806,7 @@ bool DacDbiInterfaceImpl::GetAppDomainForObject(CORDB_ADDRESS addr, OUT VMPTR_Ap { pAppDomain->SetDacTargetPtr(PTR_HOST_TO_TADDR(baseDomain->AsAppDomain())); pModule->SetDacTargetPtr(PTR_HOST_TO_TADDR(module)); - pDomainFile->SetDacTargetPtr(PTR_HOST_TO_TADDR(module->GetDomainFile(baseDomain->AsAppDomain()))); + pDomainFile->SetDacTargetPtr(PTR_HOST_TO_TADDR(module->GetDomainFile())); } else { diff --git a/src/debug/daccess/dacdbiimplstackwalk.cpp b/src/debug/daccess/dacdbiimplstackwalk.cpp index 83e3e38..e8c2174 100644 --- a/src/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/debug/daccess/dacdbiimplstackwalk.cpp @@ -515,7 +515,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread #endif // FEATURE_COMINTEROP Module * pModule = (pMD ? pMD->GetModule() : NULL); - DomainFile * pDomainFile = (pModule ? pModule->GetDomainFile(pAppDomain) : NULL); + DomainFile * pDomainFile = (pModule ? pModule->GetDomainFile() : NULL); if (frameData.stubFrame.frameType == STUBFRAME_FUNC_EVAL) { @@ -714,7 +714,7 @@ void DacDbiInterfaceImpl::InitFrameData(StackFrameIterator * pIter, DomainFile *pDomainFile = NULL; EX_TRY_ALLOW_DATATARGET_MISSING_MEMORY { - pDomainFile = (pModule ? pModule->GetDomainFile(pAppDomain) : NULL); + pDomainFile = (pModule ? pModule->GetDomainFile() : NULL); _ASSERTE(pDomainFile != NULL); } EX_END_CATCH_ALLOW_DATATARGET_MISSING_MEMORY diff --git a/src/debug/daccess/inspect.cpp b/src/debug/daccess/inspect.cpp index bbd724f..5eb9b11 100644 --- a/src/debug/daccess/inspect.cpp +++ b/src/debug/daccess/inspect.cpp @@ -1437,7 +1437,7 @@ ClrDataValue::NewFromFieldDesc(ClrDataAccess* dac, { baseAddr = TO_CDADDR (PTR_TO_TADDR(fieldDesc->GetStaticAddressHandle - (fieldDesc->GetBaseInDomain(appDomain)))); + (fieldDesc->GetBase()))); } else { diff --git a/src/debug/daccess/request.cpp b/src/debug/daccess/request.cpp index 2365fdf..dff24c8 100644 --- a/src/debug/daccess/request.cpp +++ b/src/debug/daccess/request.cpp @@ -2316,9 +2316,8 @@ ClrDataAccess::GetAppDomainData(CLRDATA_ADDRESS addr, struct DacpAppDomainData * if (pBaseDomain->IsAppDomain()) { AppDomain * pAppDomain = pBaseDomain->AsAppDomain(); - appdomainData->DomainLocalBlock = appdomainData->AppDomainPtr + - offsetof(AppDomain, m_sDomainLocalBlock); - appdomainData->pDomainLocalModules = PTR_CDADDR(pAppDomain->m_sDomainLocalBlock.m_pModuleSlots); + appdomainData->DomainLocalBlock = 0; + appdomainData->pDomainLocalModules = 0; appdomainData->dwId = DefaultADID; appdomainData->appDomainStage = (DacpAppDomainDataStage)pAppDomain->m_Stage.Load(); @@ -3197,7 +3196,7 @@ ClrDataAccess::GetDomainLocalModuleDataFromModule(CLRDATA_ADDRESS addr, struct D SOSDacEnter(); Module* pModule = PTR_Module(TO_TADDR(addr)); - DomainLocalModule* pLocalModule = PTR_DomainLocalModule(pModule->GetDomainLocalModule(NULL)); + DomainLocalModule* pLocalModule = PTR_DomainLocalModule(pModule->GetDomainLocalModule()); if (!pLocalModule) { hr = E_INVALIDARG; @@ -3217,36 +3216,10 @@ ClrDataAccess::GetDomainLocalModuleDataFromModule(CLRDATA_ADDRESS addr, struct D HRESULT ClrDataAccess::GetDomainLocalModuleDataFromAppDomain(CLRDATA_ADDRESS appDomainAddr, int moduleID, struct DacpDomainLocalModuleData *pLocalModuleData) { - if (appDomainAddr == 0 || moduleID < 0 || pLocalModuleData == NULL) - return E_INVALIDARG; - - SOSDacEnter(); - - pLocalModuleData->appDomainAddr = appDomainAddr; - pLocalModuleData->ModuleID = moduleID; - - AppDomain *pAppDomain = PTR_AppDomain(TO_TADDR(appDomainAddr)); - ModuleIndex index = Module::IDToIndex(moduleID); - DomainLocalModule* pLocalModule = pAppDomain->GetDomainLocalBlock()->GetModuleSlot(index); - if (!pLocalModule) - { - hr = E_INVALIDARG; - } - else - { - pLocalModuleData->pGCStaticDataStart = TO_CDADDR(PTR_TO_TADDR(pLocalModule->GetPrecomputedGCStaticsBasePointer())); - pLocalModuleData->pNonGCStaticDataStart = TO_CDADDR(pLocalModule->GetPrecomputedNonGCStaticsBasePointer()); - pLocalModuleData->pDynamicClassTable = PTR_CDADDR(pLocalModule->m_pDynamicClassTable.Load()); - pLocalModuleData->pClassData = (TADDR) (PTR_HOST_MEMBER_TADDR(DomainLocalModule, pLocalModule, m_pDataBlob)); - } - - SOSDacLeave(); - return hr; + // CoreCLR does not support multi-appdomain shared assembly loading. Thus, a non-pointer sized moduleID cannot exist. + return E_INVALIDARG; } - - - HRESULT ClrDataAccess::GetThreadLocalModuleData(CLRDATA_ADDRESS thread, unsigned int index, struct DacpThreadLocalModuleData *pLocalModuleData) { diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index f2d2f06..e8e8de9 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -5335,7 +5335,7 @@ DebuggerModule* Debugger::LookupOrCreateModule(Module* pModule, AppDomain *pAppD HRESULT hr = S_OK; EX_TRY { - DomainFile * pDomainFile = pModule->FindDomainFile(pAppDomain); + DomainFile * pDomainFile = pModule->GetDomainFile(); SIMPLIFYING_ASSUMPTION(pDomainFile != NULL); dmod = AddDebuggerModule(pDomainFile); // throws } @@ -9592,7 +9592,7 @@ void Debugger::LoadModule(Module* pRuntimeModule, _ASSERTE(pManifestModule->IsManifest()); _ASSERTE(pManifestModule->GetAssembly() == pRuntimeModule->GetAssembly()); - DomainFile * pManifestDomainFile = pManifestModule->GetDomainFile(pAppDomain); + DomainFile * pManifestDomainFile = pManifestModule->GetDomainFile(); DebuggerLockHolder dbgLockHolder(this); @@ -9741,7 +9741,7 @@ void Debugger::LoadModuleFinished(Module * pRuntimeModule, AppDomain * pAppDomai #ifdef _DEBUG { // This notification is called once the module is loaded - DomainFile * pDomainFile = pRuntimeModule->FindDomainFile(pAppDomain); + DomainFile * pDomainFile = pRuntimeModule->GetDomainFile(); _ASSERTE((pDomainFile != NULL) && (pDomainFile->GetLoadLevel() >= FILE_LOADED)); } #endif // _DEBUG @@ -10202,7 +10202,7 @@ BOOL Debugger::SendSystemClassLoadUnloadEvent(mdTypeDef classMetadataToken, // triggers too early in the loading process. FindDomainFile will not become // non-NULL until the module is fully loaded into the domain which is what we // want. - if (classModule->FindDomainFile(pAppDomain) != NULL ) + if (classModule->GetDomainFile() != NULL ) { // Find the Left Side module that this class belongs in. DebuggerModule* pModule = LookupOrCreateModule(classModule, pAppDomain); diff --git a/src/vm/amd64/asmconstants.h b/src/vm/amd64/asmconstants.h index 7115e88..31885a4 100644 --- a/src/vm/amd64/asmconstants.h +++ b/src/vm/amd64/asmconstants.h @@ -254,10 +254,6 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__InterfaceInfo_t__m_pMethodTable ASMCONSTANTS_C_ASSERT(SIZEOF__InterfaceInfo_t == sizeof(InterfaceInfo_t)); -#define OFFSETOF__DomainLocalBlock__m_pModuleSlots 0x8 -ASMCONSTANTS_C_ASSERT(OFFSETOF__DomainLocalBlock__m_pModuleSlots - == offsetof(DomainLocalBlock, m_pModuleSlots)); - #define OFFSETOF__DomainLocalModule__m_pDataBlob 0x030 ASMCONSTANTS_C_ASSERT(OFFSETOF__DomainLocalModule__m_pDataBlob == offsetof(DomainLocalModule, m_pDataBlob)); diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index c106d9d..fc5d73f 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -157,7 +157,7 @@ BOOL CompareCLSID(UPTR u1, UPTR u2) #ifndef CROSSGEN_COMPILE // Constructor for the LargeHeapHandleBucket class. -LargeHeapHandleBucket::LargeHeapHandleBucket(LargeHeapHandleBucket *pNext, DWORD Size, BaseDomain *pDomain, BOOL bCrossAD) +LargeHeapHandleBucket::LargeHeapHandleBucket(LargeHeapHandleBucket *pNext, DWORD Size, BaseDomain *pDomain) : m_pNext(pNext) , m_ArraySize(Size) , m_CurrentPos(0) @@ -176,31 +176,8 @@ LargeHeapHandleBucket::LargeHeapHandleBucket(LargeHeapHandleBucket *pNext, DWORD PTRARRAYREF HandleArrayObj; // Allocate the array in the large object heap. - if (!bCrossAD) - { - OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED); - HandleArrayObj = (PTRARRAYREF)AllocateObjectArray(Size, g_pObjectClass, TRUE); - } - else - { - // During AD creation we don't want to assign the handle array to the currently running AD but - // to the AD being created. Ensure that AllocateArrayEx doesn't set the AD and then set it here. - AppDomain *pAD = pDomain->AsAppDomain(); - _ASSERTE(pAD); - _ASSERTE(pAD->IsBeingCreated()); - - OBJECTREF array; - { - OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED); - array = AllocateArrayEx( - ClassLoader::LoadArrayTypeThrowing(g_pObjectClass), - (INT32 *)(&Size), - 1, - TRUE); - } - - HandleArrayObj = (PTRARRAYREF)array; - } + OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED); + HandleArrayObj = (PTRARRAYREF)AllocateObjectArray(Size, g_pObjectClass, TRUE); // Retrieve the pointer to the data inside the array. This is legal since the array // is located in the large object heap and is guaranteed not to move. @@ -404,31 +381,19 @@ LargeHeapHandleTable::~LargeHeapHandleTable() // Third case: Releases for use in a string literal entry // // CrstHolder gch(&(SystemDomain::GetGlobalStringLiteralMap()->m_HashTableCrstGlobal)); -// taken in the AppDomainStringLiteralMap functions below protects the 4 ways that this can happen +// taken in the AppDomainStringLiteralMap functions below protects the 3 ways that this can happen // // case 3a) // -// in an appdomain unload case -// -// AppDomainStringLiteralMap::~AppDomainStringLiteralMap() takes the lock then -// leads to calls to -// StringLiteralEntry::Release -// which leads to -// SystemDomain::GetGlobalStringLiteralMapNoCreate()->RemoveStringLiteralEntry(this) -// which leads to -// m_LargeHeapHandleTable.ReleaseHandles((OBJECTREF*)pObjRef, 1); -// -// case 3b) -// // AppDomainStringLiteralMap::GetStringLiteral() can call StringLiteralEntry::Release in some // error cases, leading to the same stack as above // -// case 3c) +// case 3b) // // AppDomainStringLiteralMap::GetInternedString() can call StringLiteralEntry::Release in some // error cases, leading to the same stack as above // -// case 3d) +// case 3c) // // The same code paths in 3b and 3c and also end up releasing if an exception is thrown // during their processing. Both these paths use a StringLiteralEntryHolder to assist in cleanup, @@ -437,7 +402,7 @@ LargeHeapHandleTable::~LargeHeapHandleTable() // Allocate handles from the large heap handle table. -OBJECTREF* LargeHeapHandleTable::AllocateHandles(DWORD nRequested, BOOL bCrossAD) +OBJECTREF* LargeHeapHandleTable::AllocateHandles(DWORD nRequested) { CONTRACTL { @@ -507,7 +472,7 @@ OBJECTREF* LargeHeapHandleTable::AllocateHandles(DWORD nRequested, BOOL bCrossAD // We need a block big enough to hold the requested handles DWORD NewBucketSize = max(m_NextBucketSize, nRequested); - m_pHead = new LargeHeapHandleBucket(m_pHead, NewBucketSize, m_pDomain, bCrossAD); + m_pHead = new LargeHeapHandleBucket(m_pHead, NewBucketSize, m_pDomain); m_NextBucketSize = min(m_NextBucketSize * 2, MAX_BUCKETSIZE); } @@ -982,7 +947,7 @@ void AppDomain::ReleaseFiles() } // AppDomain::ReleaseFiles -OBJECTREF* BaseDomain::AllocateObjRefPtrsInLargeTable(int nRequested, OBJECTREF** ppLazyAllocate, BOOL bCrossAD) +OBJECTREF* BaseDomain::AllocateObjRefPtrsInLargeTable(int nRequested, OBJECTREF** ppLazyAllocate) { CONTRACTL { @@ -1016,7 +981,7 @@ OBJECTREF* BaseDomain::AllocateObjRefPtrsInLargeTable(int nRequested, OBJECTREF* InitLargeHeapHandleTable(); // Allocate the handles. - OBJECTREF* result = m_pLargeHeapHandleTable->AllocateHandles(nRequested, bCrossAD); + OBJECTREF* result = m_pLargeHeapHandleTable->AllocateHandles(nRequested); if (ppLazyAllocate) { @@ -3114,8 +3079,6 @@ void AppDomain::Init() m_MemoryPressure = 0; - m_sDomainLocalBlock.Init(this); - #ifndef CROSSGEN_COMPILE #ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING @@ -4423,7 +4386,7 @@ CHECK AppDomain::CheckValidModule(Module * pModule) } CONTRACTL_END; - if (pModule->FindDomainFile(this) != NULL) + if (pModule->GetDomainFile() != NULL) CHECK_OK; CHECK_OK; @@ -6258,64 +6221,6 @@ void DomainLocalModule::PopulateClass(MethodTable *pMT) } #endif // CROSSGEN_COMPILE -void DomainLocalBlock::EnsureModuleIndex(ModuleIndex index) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - INJECT_FAULT(COMPlusThrowOM();); - // Assumes BaseDomain::DomainLocalBlockLockHolder is taken - PRECONDITION(m_pDomain->OwnDomainLocalBlockLock()); - } - CONTRACTL_END; - - if (m_aModuleIndices > index.m_dwIndex) - { - _ASSERTE(m_pModuleSlots != NULL); - return; - } - - SIZE_T aModuleIndices = max(16, m_aModuleIndices); - while (aModuleIndices <= index.m_dwIndex) - { - aModuleIndices *= 2; - } - - PTR_DomainLocalModule* pNewModuleSlots = (PTR_DomainLocalModule*) (void*)m_pDomain->GetHighFrequencyHeap()->AllocMem(S_SIZE_T(sizeof(PTR_DomainLocalModule)) * S_SIZE_T(aModuleIndices)); - - memcpy(pNewModuleSlots, m_pModuleSlots, sizeof(SIZE_T)*m_aModuleIndices); - - // Note: Memory allocated on loader heap is zero filled - // memset(pNewModuleSlots + m_aModuleIndices, 0 , (aModuleIndices - m_aModuleIndices)*sizeof(PTR_DomainLocalModule) ); - - // Commit new table. The lock-free helpers depend on the order. - MemoryBarrier(); - m_pModuleSlots = pNewModuleSlots; - MemoryBarrier(); - m_aModuleIndices = aModuleIndices; - -} - -void DomainLocalBlock::SetModuleSlot(ModuleIndex index, PTR_DomainLocalModule pLocalModule) -{ - // Need to synchronize with table growth in this domain - BaseDomain::DomainLocalBlockLockHolder lh(m_pDomain); - - EnsureModuleIndex(index); - - _ASSERTE(index.m_dwIndex < m_aModuleIndices); - - // We would like this assert here, unfortunately, loading a module in this appdomain can fail - // after here and we will keep the module around and reuse the slot when we retry (if - // the failure happened due to a transient error, such as OOM). In that case the slot wont - // be null. - //_ASSERTE(m_pModuleSlots[index.m_dwIndex] == 0); - - m_pModuleSlots[index.m_dwIndex] = pLocalModule; -} - #ifndef CROSSGEN_COMPILE DomainAssembly* AppDomain::RaiseTypeResolveEventThrowing(DomainAssembly* pAssembly, LPCSTR szName, ASSEMBLYREF *pResultingAssemblyRef) @@ -7076,28 +6981,6 @@ DomainLocalModule::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) } void -DomainLocalBlock::EnumMemoryRegions(CLRDataEnumMemoryFlags flags) -{ - SUPPORTS_DAC; - // Block is contained in AppDomain, don't enum this. - - if (m_pModuleSlots.IsValid()) - { - DacEnumMemoryRegion(dac_cast(m_pModuleSlots), - m_aModuleIndices * sizeof(TADDR)); - - for (SIZE_T i = 0; i < m_aModuleIndices; i++) - { - PTR_DomainLocalModule domMod = m_pModuleSlots[i]; - if (domMod.IsValid()) - { - domMod->EnumMemoryRegions(flags); - } - } - } -} - -void BaseDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, bool enumThis) { @@ -7142,8 +7025,6 @@ AppDomain::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, { pDomainAssembly->EnumMemoryRegions(flags); } - - m_sDomainLocalBlock.EnumMemoryRegions(flags); } void diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index edf2c0b..5bc45d7 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -483,97 +483,6 @@ public: #define OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob TARGET_POINTER_SIZE /* m_pGCStatics */ #endif -typedef DPTR(class DomainLocalBlock) PTR_DomainLocalBlock; -class DomainLocalBlock -{ - friend class ClrDataAccess; - friend class CheckAsmOffsets; - -private: - PTR_AppDomain m_pDomain; - DPTR(PTR_DomainLocalModule) m_pModuleSlots; - SIZE_T m_aModuleIndices; // Module entries the shared block has allocated - -public: // used by code generators - static SIZE_T GetOffsetOfModuleSlotsPointer() { return offsetof(DomainLocalBlock, m_pModuleSlots);} - -public: - -#ifndef DACCESS_COMPILE - DomainLocalBlock() - : m_pDomain(NULL), m_pModuleSlots(NULL), m_aModuleIndices(0) {} - - void EnsureModuleIndex(ModuleIndex index); - - void Init(AppDomain *pDomain) { LIMITED_METHOD_CONTRACT; m_pDomain = pDomain; } -#endif - - void SetModuleSlot(ModuleIndex index, PTR_DomainLocalModule pLocalModule); - - FORCEINLINE PTR_DomainLocalModule GetModuleSlot(ModuleIndex index) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - _ASSERTE(index.m_dwIndex < m_aModuleIndices); - return m_pModuleSlots[index.m_dwIndex]; - } - - inline PTR_DomainLocalModule GetModuleSlot(MethodTable* pMT) - { - WRAPPER_NO_CONTRACT; - return GetModuleSlot(pMT->GetModuleForStatics()->GetModuleIndex()); - } - - DomainFile* TryGetDomainFile(ModuleIndex index) - { - WRAPPER_NO_CONTRACT; - SUPPORTS_DAC; - - // the publishing of m_aModuleIndices and m_pModuleSlots is dependent - // on the order of accesses; we must ensure that we read from m_aModuleIndices - // before m_pModuleSlots. - if (index.m_dwIndex < m_aModuleIndices) - { - MemoryBarrier(); - if (m_pModuleSlots[index.m_dwIndex]) - { - return m_pModuleSlots[index.m_dwIndex]->GetDomainFile(); - } - } - - return NULL; - } - - DomainFile* GetDomainFile(SIZE_T ModuleID) - { - WRAPPER_NO_CONTRACT; - ModuleIndex index = Module::IDToIndex(ModuleID); - _ASSERTE(index.m_dwIndex < m_aModuleIndices); - return m_pModuleSlots[index.m_dwIndex]->GetDomainFile(); - } - -#ifndef DACCESS_COMPILE - void SetDomainFile(ModuleIndex index, DomainFile* pDomainFile) - { - WRAPPER_NO_CONTRACT; - _ASSERTE(index.m_dwIndex < m_aModuleIndices); - m_pModuleSlots[index.m_dwIndex]->SetDomainFile(pDomainFile); - } -#endif - -#ifdef DACCESS_COMPILE - void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); -#endif - - -private: - - // - // Low level routines to get & set class entries - // - -}; - #ifdef _MSC_VER #pragma warning(pop) #endif @@ -585,7 +494,7 @@ class LargeHeapHandleBucket { public: // Constructor and desctructor. - LargeHeapHandleBucket(LargeHeapHandleBucket *pNext, DWORD Size, BaseDomain *pDomain, BOOL bCrossAD = FALSE); + LargeHeapHandleBucket(LargeHeapHandleBucket *pNext, DWORD Size, BaseDomain *pDomain); ~LargeHeapHandleBucket(); // This returns the next bucket. @@ -642,7 +551,7 @@ public: ~LargeHeapHandleTable(); // Allocate handles from the large heap handle table. - OBJECTREF* AllocateHandles(DWORD nRequested, BOOL bCrossAD = FALSE); + OBJECTREF* AllocateHandles(DWORD nRequested); // Release object handles allocated using AllocateHandles(). void ReleaseHandles(OBJECTREF *pObjRef, DWORD nReleased); @@ -1028,9 +937,6 @@ class BaseDomain VPTR_BASE_VTABLE_CLASS(BaseDomain) VPTR_UNIQUE(VPTR_UNIQUE_BaseDomain) -protected: - DomainLocalBlock m_sDomainLocalBlock; - public: class AssemblyIterator; @@ -1091,7 +997,6 @@ public: return m_pWinRtBinder; } #endif // FEATURE_COMINTEROP - #ifdef _DEBUG BOOL OwnDomainLocalBlockLock() { @@ -1100,7 +1005,7 @@ public: return m_DomainLocalBlockCrst.OwnedByCurrentThread(); } #endif - + //**************************************************************************************** // Get the class init lock. The method is limited to friends because inappropriate use // will cause deadlocks in the system @@ -1130,7 +1035,7 @@ public: // Statics and reflection info (Types, MemberInfo,..) are stored this way // If ppLazyAllocate != 0, allocation will only take place if *ppLazyAllocate != 0 (and the allocation // will be properly serialized) - OBJECTREF *AllocateObjRefPtrsInLargeTable(int nRequested, OBJECTREF** ppLazyAllocate = NULL, BOOL bCrossAD = FALSE); + OBJECTREF *AllocateObjRefPtrsInLargeTable(int nRequested, OBJECTREF** ppLazyAllocate = NULL); #ifdef FEATURE_PREJIT // Ensures that the file for logging profile data is open (we only open it once) @@ -1767,8 +1672,6 @@ public: static void Create(); #endif - DomainAssembly* FindDomainAssembly(Assembly*); - //----------------------------------------------------------------------------------------------------------------- // Convenience wrapper for ::GetAppDomain to provide better encapsulation. static PTR_AppDomain GetCurrentDomain() @@ -2280,31 +2183,10 @@ public: return AllocateObjRefPtrsInLargeTable(nRequested, ppLazyAllocate); } - - OBJECTREF* AllocateStaticFieldObjRefPtrsCrossDomain(int nRequested, OBJECTREF** ppLazyAllocate = NULL) - { - WRAPPER_NO_CONTRACT; - - return AllocateObjRefPtrsInLargeTable(nRequested, ppLazyAllocate, TRUE); - } #endif // DACCESS_COMPILE void EnumStaticGCRefs(promote_func* fn, ScanContext* sc); - DomainLocalBlock *GetDomainLocalBlock() - { - LIMITED_METHOD_DAC_CONTRACT; - - return &m_sDomainLocalBlock; - } - - static SIZE_T GetOffsetOfModuleSlotsPointer() - { - WRAPPER_NO_CONTRACT; - - return offsetof(AppDomain,m_sDomainLocalBlock) + DomainLocalBlock::GetOffsetOfModuleSlotsPointer(); - } - void SetupSharedStatics(); //**************************************************************************************** diff --git a/src/vm/appdomain.inl b/src/vm/appdomain.inl index d98272c..65491f8 100644 --- a/src/vm/appdomain.inl +++ b/src/vm/appdomain.inl @@ -19,18 +19,6 @@ #include "appdomain.hpp" -inline DomainAssembly* AppDomain::FindDomainAssembly(Assembly* assembly) -{ - CONTRACTL - { - GC_NOTRIGGER; - MODE_COOPERATIVE; - PRECONDITION(CheckPointer(assembly)); - } - CONTRACTL_END; - return assembly->FindDomainAssembly(this); -}; - inline void AppDomain::AddMemoryPressure() { STANDARD_VM_CONTRACT; diff --git a/src/vm/arm/asmconstants.h b/src/vm/arm/asmconstants.h index 7f9b0ac..ed57b89 100644 --- a/src/vm/arm/asmconstants.h +++ b/src/vm/arm/asmconstants.h @@ -176,9 +176,6 @@ ASMCONSTANTS_C_ASSERT(Thread__m_pFrame == offsetof(Thread, m_pFrame)); #define Thread_m_pFrame Thread__m_pFrame #ifndef CROSSGEN_COMPILE -#define DomainLocalBlock__m_pModuleSlots 0x04 -ASMCONSTANTS_C_ASSERT(DomainLocalBlock__m_pModuleSlots == offsetof(DomainLocalBlock, m_pModuleSlots)); - #define DomainLocalModule__m_pDataBlob 0x18 ASMCONSTANTS_C_ASSERT(DomainLocalModule__m_pDataBlob == offsetof(DomainLocalModule, m_pDataBlob)); diff --git a/src/vm/assembly.cpp b/src/vm/assembly.cpp index 2d89cc4..80e7f9c 100644 --- a/src/vm/assembly.cpp +++ b/src/vm/assembly.cpp @@ -726,35 +726,10 @@ void Assembly::SetDomainAssembly(DomainAssembly *pDomainAssembly) #endif // #ifndef DACCESS_COMPILE -DomainAssembly *Assembly::GetDomainAssembly(AppDomain *pDomain) +DomainAssembly *Assembly::GetDomainAssembly() { - CONTRACT(DomainAssembly *) - { - PRECONDITION(CheckPointer(pDomain, NULL_NOT_OK)); - POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - GC_TRIGGERS; - } - CONTRACT_END; - - RETURN GetManifestModule()->GetDomainAssembly(pDomain); -} - -DomainAssembly *Assembly::FindDomainAssembly(AppDomain *pDomain) -{ - CONTRACT(DomainAssembly *) - { - PRECONDITION(CheckPointer(pDomain)); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - FORBID_FAULT; - SUPPORTS_DAC; - } - CONTRACT_END; - - PREFIX_ASSUME (GetManifestModule() !=NULL); - RETURN GetManifestModule()->FindDomainAssembly(pDomain); + LIMITED_METHOD_DAC_CONTRACT; + return GetManifestModule()->GetDomainAssembly(); } PTR_LoaderHeap Assembly::GetLowFrequencyHeap() @@ -883,7 +858,7 @@ Module *Assembly::FindModuleByExportedType(mdExportedType mdType, #ifndef DACCESS_COMPILE // LoadAssembly never returns NULL DomainAssembly * pDomainAssembly = - GetManifestModule()->LoadAssembly(::GetAppDomain(), mdLinkRef); + GetManifestModule()->LoadAssembly(mdLinkRef); PREFIX_ASSUME(pDomainAssembly != NULL); RETURN pDomainAssembly->GetCurrentModule(); @@ -1137,7 +1112,6 @@ Module * Assembly::FindModuleByTypeRef( DomainAssembly * pDomainAssembly = pModule->LoadAssembly( - ::GetAppDomain(), tkType, szNamespace, szClassName); diff --git a/src/vm/assembly.hpp b/src/vm/assembly.hpp index 43d9172..5adf596 100644 --- a/src/vm/assembly.hpp +++ b/src/vm/assembly.hpp @@ -432,17 +432,9 @@ public: //**************************************************************************************** - DomainAssembly *GetDomainAssembly(AppDomain *pDomain); + DomainAssembly *GetDomainAssembly(); void SetDomainAssembly(DomainAssembly *pAssembly); - // Verison of GetDomainAssembly that uses the current AppDomain (N/A in DAC builds) -#ifndef DACCESS_COMPILE - DomainAssembly *GetDomainAssembly() { WRAPPER_NO_CONTRACT; return GetDomainAssembly(GetAppDomain()); } -#endif - - // FindDomainAssembly will return NULL if the assembly is not in the given domain - DomainAssembly *FindDomainAssembly(AppDomain *pDomain); - #if defined(FEATURE_COLLECTIBLE_TYPES) && !defined(DACCESS_COMPILE) OBJECTHANDLE GetLoaderAllocatorObjectHandle() { WRAPPER_NO_CONTRACT; return GetLoaderAllocator()->GetLoaderAllocatorObjectHandle(); } #endif // FEATURE_COLLECTIBLE_TYPES diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index d98f180..6575d57 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -1856,130 +1856,18 @@ BOOL Module::IsManifest() dac_cast(this); } -DomainAssembly* Module::GetDomainAssembly(AppDomain *pDomain) +DomainAssembly* Module::GetDomainAssembly() { - CONTRACT(DomainAssembly *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain, NULL_OK)); - POSTCONDITION(CheckPointer(RETVAL)); - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACT_END; - - if (IsManifest()) - RETURN (DomainAssembly *) GetDomainFile(pDomain); - else - RETURN (DomainAssembly *) m_pAssembly->GetDomainAssembly(pDomain); -} - -DomainFile *Module::GetDomainFile(AppDomain *pDomain) -{ - CONTRACT(DomainFile *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain)); - POSTCONDITION(CheckPointer(RETVAL)); - GC_TRIGGERS; - THROWS; - MODE_ANY; - SUPPORTS_DAC; - } - CONTRACT_END; - - if (Module::IsEncodedModuleIndex(GetModuleID())) - { - DomainLocalBlock *pLocalBlock = pDomain->GetDomainLocalBlock(); - DomainFile *pDomainFile = pLocalBlock->TryGetDomainFile(GetModuleIndex()); - - RETURN (PTR_DomainFile) pDomainFile; - } - else - { - RETURN dac_cast(m_ModuleID->GetDomainFile()); - } -} - -DomainAssembly* Module::FindDomainAssembly(AppDomain *pDomain) -{ - CONTRACT(DomainAssembly *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain)); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - SUPPORTS_DAC; - } - CONTRACT_END; - - if (IsManifest()) - RETURN dac_cast(FindDomainFile(pDomain)); - else - RETURN m_pAssembly->FindDomainAssembly(pDomain); -} - -DomainModule *Module::GetDomainModule(AppDomain *pDomain) -{ - CONTRACT(DomainModule *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain)); - PRECONDITION(!IsManifest()); - POSTCONDITION(CheckPointer(RETVAL)); - - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACT_END; - - RETURN (DomainModule *) GetDomainFile(pDomain); -} - -DomainFile *Module::FindDomainFile(AppDomain *pDomain) -{ - CONTRACT(DomainFile *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain)); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - SUPPORTS_DAC; - } - CONTRACT_END; + LIMITED_METHOD_DAC_CONTRACT; - if (Module::IsEncodedModuleIndex(GetModuleID())) - { - DomainLocalBlock *pLocalBlock = pDomain->GetDomainLocalBlock(); - RETURN pLocalBlock->TryGetDomainFile(GetModuleIndex()); - } - else - { - RETURN m_ModuleID->GetDomainFile(); - } + return dac_cast(m_ModuleID->GetDomainFile()); } -DomainModule *Module::FindDomainModule(AppDomain *pDomain) +DomainFile *Module::GetDomainFile() { - CONTRACT(DomainModule *) - { - INSTANCE_CHECK; - PRECONDITION(CheckPointer(pDomain)); - PRECONDITION(!IsManifest()); - POSTCONDITION(CheckPointer(RETVAL, NULL_OK)); - GC_NOTRIGGER; - NOTHROW; - MODE_ANY; - } - CONTRACT_END; + LIMITED_METHOD_DAC_CONTRACT; - RETURN (DomainModule *) FindDomainFile(pDomain); + return dac_cast(m_ModuleID->GetDomainFile()); } #ifndef DACCESS_COMPILE @@ -2815,9 +2703,6 @@ void Module::FreeModuleIndex() CONTRACTL_END; if (m_ModuleID != NULL) { - // Module's m_ModuleID should not contain the ID, it should - // contain a pointer to the DLM - _ASSERTE(!Module::IsEncodedModuleIndex((SIZE_T)m_ModuleID)); _ASSERTE(m_ModuleIndex == m_ModuleID->GetModuleIndex()); #ifndef CROSSGEN_COMPILE @@ -2888,31 +2773,13 @@ void Module::AllocateRegularStaticHandles(AppDomain* pDomain) // allocate if pModuleData->GetGCStaticsBasePointerAddress(pMT) != 0, avoiding creating // handles more than once for a given MT or module - DomainLocalModule *pModuleData = GetDomainLocalModule(pDomain); + DomainLocalModule *pModuleData = GetDomainLocalModule(); _ASSERTE(pModuleData->GetPrecomputedGCStaticsBasePointerAddress() != NULL); if (this->m_dwMaxGCRegularStaticHandles > 0) { - // If we're setting up a non-default domain, we want the allocation to look like it's - // coming from the created domain. - - // REVISIT_TODO: The comparison "pDomain != GetDomain()" will always be true for domain-neutral - // modules, since GetDomain() will return the SharedDomain, which is NOT an AppDomain. - // Was this intended? If so, there should be a clarifying comment. If not, then we should - // probably do "pDomain != GetAppDomain()" instead. - - if (pDomain != GetDomain() && - pDomain != SystemDomain::System()->DefaultDomain() && - IsSystem()) - { - pDomain->AllocateStaticFieldObjRefPtrsCrossDomain(this->m_dwMaxGCRegularStaticHandles, + pDomain->AllocateStaticFieldObjRefPtrs(this->m_dwMaxGCRegularStaticHandles, pModuleData->GetPrecomputedGCStaticsBasePointerAddress()); - } - else - { - pDomain->AllocateStaticFieldObjRefPtrs(this->m_dwMaxGCRegularStaticHandles, - pModuleData->GetPrecomputedGCStaticsBasePointerAddress()); - } // We should throw if we fail to allocate and never hit this assert _ASSERTE(pModuleData->GetPrecomputedGCStaticsBasePointer() != NULL); @@ -2983,7 +2850,7 @@ void Module::AllocateStatics(AllocMemTracker *pamTracker) // statics is through the handle table. Module::AllocateRegularStaticHandles() allocates a GC handle // from the handle table, and the GC will trace this handle and find the statics. -void Module::EnumRegularStaticGCRefs(AppDomain* pAppDomain, promote_func* fn, ScanContext* sc) +void Module::EnumRegularStaticGCRefs(promote_func* fn, ScanContext* sc) { CONTRACT_VOID { @@ -2997,7 +2864,7 @@ void Module::EnumRegularStaticGCRefs(AppDomain* pAppDomain, promote_func* fn, Sc IsGCSpecialThread()); - DomainLocalModule *pModuleData = GetDomainLocalModule(pAppDomain); + DomainLocalModule *pModuleData = GetDomainLocalModule(); DWORD dwHandles = m_dwMaxGCRegularStaticHandles; if (IsResource()) @@ -4624,30 +4491,6 @@ void Module::AddActiveDependency(Module *pModule, BOOL unconditional) RETURN; } -void Module::EnableModuleFailureTriggers(Module *pModuleTo, AppDomain *pDomain) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - // At this point we need to enable failure triggers we have placed in the code for this module. However, - // the failure trigger codegen logic is NYI. To keep correctness, we just allow the exception to propagate - // here. Note that in general this will enforce the failure invariants, but will also result in some rude - // behavior as these failures will be propagated too widely rather than constrained to the appropriate - // assemblies/app domains. - // - // This should throw. - STRESS_LOG1(LF_CLASSLOADER, LL_INFO100,"EnableModuleFailureTriggers for module %p\n",pModuleTo); - DomainFile *pDomainFileTo = pModuleTo->GetDomainFile(pDomain); - pDomainFileTo->EnsureActive(); - - // @NYI: shouldn't get here yet since we propagate failures - UNREACHABLE_MSG("Module failure triggers NYI"); -} - #endif //!DACCESS_COMPILE #if !defined(DACCESS_COMPILE) && defined(FEATURE_PREJIT) @@ -4792,7 +4635,7 @@ Module::GetAssemblyIfLoaded( if ((pAssembly != NULL) && !IsGCThread() && !IsStackWalkerThread()) { _ASSERTE(::GetAppDomain() != NULL); - DomainAssembly * pDomainAssembly = pAssembly->FindDomainAssembly(::GetAppDomain()); + DomainAssembly * pDomainAssembly = pAssembly->GetDomainAssembly(); if ((pDomainAssembly == NULL) || !pDomainAssembly->IsLoaded()) pAssembly = NULL; } @@ -4804,7 +4647,7 @@ Module::GetAssemblyIfLoaded( { AppDomain * pAppDomainExamine = AppDomain::GetCurrentDomain(); - DomainAssembly * pCurAssemblyInExamineDomain = GetAssembly()->FindDomainAssembly(pAppDomainExamine); + DomainAssembly * pCurAssemblyInExamineDomain = GetAssembly()->GetDomainAssembly(); if (pCurAssemblyInExamineDomain == NULL) { continue; @@ -4937,7 +4780,7 @@ Module::GetAssemblyIfLoaded( { AppDomain * pAppDomainExamine = ::GetAppDomain(); // There is only 1 AppDomain on CoreCLR - DomainAssembly * pCurAssemblyInExamineDomain = GetAssembly()->FindDomainAssembly(pAppDomainExamine); + DomainAssembly * pCurAssemblyInExamineDomain = GetAssembly()->GetDomainAssembly(); if (pCurAssemblyInExamineDomain == NULL) { continue; @@ -5065,7 +4908,6 @@ Module::GetAssemblyRefFlags( // szWinRtTypeNamespace ... Namespace of WinRT type. // szWinRtTypeClassName ... Name of WinRT type, NULL for non-WinRT (classic) types. DomainAssembly * Module::LoadAssembly( - AppDomain * pDomain, mdAssemblyRef kAssemblyRef, LPCUTF8 szWinRtTypeNamespace, LPCUTF8 szWinRtTypeClassName) @@ -5077,7 +4919,6 @@ DomainAssembly * Module::LoadAssembly( if (FORBIDGC_LOADER_USE_ENABLED()) GC_NOTRIGGER; else GC_TRIGGERS; if (FORBIDGC_LOADER_USE_ENABLED()) FORBID_FAULT; else { INJECT_FAULT(COMPlusThrowOM();); } MODE_ANY; - PRECONDITION(CheckPointer(pDomain)); POSTCONDITION(CheckPointer(RETVAL, NULL_NOT_OK)); //POSTCONDITION((CheckPointer(GetAssemblyIfLoaded(kAssemblyRef, szWinRtTypeNamespace, szWinRtTypeClassName)), NULL_NOT_OK)); } @@ -5095,11 +4936,8 @@ DomainAssembly * Module::LoadAssembly( { _ASSERTE(HasBindableIdentity(kAssemblyRef)); - pDomainAssembly = pAssembly->FindDomainAssembly(pDomain); - - if (pDomainAssembly == NULL) - pDomainAssembly = pAssembly->GetDomainAssembly(pDomain); - pDomain->LoadDomainFile(pDomainAssembly, FILE_LOADED); + pDomainAssembly = pAssembly->GetDomainAssembly(); + ::GetAppDomain()->LoadDomainFile(pDomainAssembly, FILE_LOADED); RETURN pDomainAssembly; } @@ -5107,13 +4945,13 @@ DomainAssembly * Module::LoadAssembly( bool fHasBindableIdentity = HasBindableIdentity(kAssemblyRef); { - PEAssemblyHolder pFile = GetDomainFile(GetAppDomain())->GetFile()->LoadAssembly( + PEAssemblyHolder pFile = GetDomainAssembly()->GetFile()->LoadAssembly( kAssemblyRef, NULL, szWinRtTypeNamespace, szWinRtTypeClassName); AssemblySpec spec; - spec.InitializeSpec(kAssemblyRef, GetMDImport(), GetDomainFile(GetAppDomain())->GetDomainAssembly()); + spec.InitializeSpec(kAssemblyRef, GetMDImport(), GetDomainAssembly()); // Set the binding context in the AssemblySpec if one is available. This can happen if the LoadAssembly ended up // invoking the custom AssemblyLoadContext implementation that returned a reference to an assembly bound to a different // AssemblyLoadContext implementation. @@ -13756,7 +13594,7 @@ CHECK Module::CheckActivated() CONTRACTL_END; #ifndef DACCESS_COMPILE - DomainFile *pDomainFile = FindDomainFile(GetAppDomain()); + DomainFile *pDomainFile = GetDomainFile(); CHECK(pDomainFile != NULL); PREFIX_ASSUME(pDomainFile != NULL); CHECK(pDomainFile->CheckActivated()); @@ -13806,16 +13644,11 @@ void Module::EnumMemoryRegions(CLRDataEnumMemoryFlags flags, } //Save module id data only if it a real pointer, not a tagged sugestion to use ModuleIndex. - if (!Module::IsEncodedModuleIndex(GetModuleID())) + if (m_ModuleID.IsValid()) { - if (m_ModuleID.IsValid()) - { - m_ModuleID->EnumMemoryRegions(flags); - } + m_ModuleID->EnumMemoryRegions(flags); } - // TODO: Enumerate DomainLocalModules? It's not clear if we need all AppDomains - // in the multi-domain case (where m_ModuleID has it's low-bit set). if (m_file.IsValid()) { m_file->EnumMemoryRegions(flags); diff --git a/src/vm/ceeload.h b/src/vm/ceeload.h index 99c1c78..04d78c3 100644 --- a/src/vm/ceeload.h +++ b/src/vm/ceeload.h @@ -1763,24 +1763,11 @@ protected: MethodTable *GetGlobalMethodTable(); bool NeedsGlobalMethodTable(); - // Only for non-manifest modules - DomainModule *GetDomainModule(AppDomain *pDomain); - DomainModule *FindDomainModule(AppDomain *pDomain); - // This works for manifest modules too - DomainFile *GetDomainFile(AppDomain *pDomain); - DomainFile *FindDomainFile(AppDomain *pDomain); + DomainFile *GetDomainFile(); // Operates on assembly of module - DomainAssembly *GetDomainAssembly(AppDomain *pDomain); - DomainAssembly *FindDomainAssembly(AppDomain *pDomain); - - // Versions which rely on the current AppDomain (N/A for DAC builds) -#ifndef DACCESS_COMPILE - DomainModule * GetDomainModule() { WRAPPER_NO_CONTRACT; return GetDomainModule(GetAppDomain()); } - DomainFile * GetDomainFile() { WRAPPER_NO_CONTRACT; return GetDomainFile(GetAppDomain()); } - DomainAssembly * GetDomainAssembly() { WRAPPER_NO_CONTRACT; return GetDomainAssembly(GetAppDomain()); } -#endif + DomainAssembly *GetDomainAssembly(); void SetDomainFile(DomainFile *pDomainFile); @@ -2179,7 +2166,6 @@ private: public: DomainAssembly * LoadAssembly( - AppDomain * pDomain, mdAssemblyRef kAssemblyRef, LPCUTF8 szWinRtTypeNamespace = NULL, LPCUTF8 szWinRtTypeClassName = NULL); @@ -2684,9 +2670,6 @@ public: void AddActiveDependency(Module *pModule, BOOL unconditional); - // Turn triggers from this module into runtime checks - void EnableModuleFailureTriggers(Module *pModule, AppDomain *pDomain); - #ifdef FEATURE_PREJIT BOOL IsZappedCode(PCODE code); BOOL IsZappedPrecode(PCODE code); @@ -3010,33 +2993,6 @@ public: // We need this for the jitted shared case, inline MethodTable* GetDynamicClassMT(DWORD dynamicClassID); - static BOOL IsEncodedModuleIndex(SIZE_T ModuleID) - { - LIMITED_METHOD_DAC_CONTRACT; - - // We should never see encoded module index in CoreCLR - _ASSERTE((ModuleID&1)==0); - return FALSE; - } - - static SIZE_T IndexToID(ModuleIndex index) - { - LIMITED_METHOD_CONTRACT - - return (index.m_dwIndex << 1) | 1; - } - - static ModuleIndex IDToIndex(SIZE_T ModuleID) - { - LIMITED_METHOD_CONTRACT - SUPPORTS_DAC; - - _ASSERTE(IsEncodedModuleIndex(ModuleID)); - ModuleIndex index(ModuleID >> 1); - - return index; - } - static ModuleIndex AllocateModuleIndex(); static void FreeModuleIndex(ModuleIndex index); @@ -3064,11 +3020,7 @@ public: return offsetof(Module, m_ModuleID); } - PTR_DomainLocalModule GetDomainLocalModule(AppDomain *pDomain); - -#ifndef DACCESS_COMPILE - PTR_DomainLocalModule GetDomainLocalModule() { WRAPPER_NO_CONTRACT; return GetDomainLocalModule(NULL); }; -#endif + PTR_DomainLocalModule GetDomainLocalModule(); #ifdef FEATURE_PREJIT NgenStats *GetNgenStats() @@ -3086,7 +3038,7 @@ public: // Self-initializing accessor for domain-independent IJW thunk heap LoaderHeap *GetDllThunkHeap(); - void EnumRegularStaticGCRefs (AppDomain* pAppDomain, promote_func* fn, ScanContext* sc); + void EnumRegularStaticGCRefs (promote_func* fn, ScanContext* sc); protected: diff --git a/src/vm/ceeload.inl b/src/vm/ceeload.inl index e0ce07f..dc2593f 100644 --- a/src/vm/ceeload.inl +++ b/src/vm/ceeload.inl @@ -473,28 +473,12 @@ inline BOOL Module::IsEditAndContinueCapable() return isEnCCapable; } -FORCEINLINE PTR_DomainLocalModule Module::GetDomainLocalModule(AppDomain *pDomain) +FORCEINLINE PTR_DomainLocalModule Module::GetDomainLocalModule() { WRAPPER_NO_CONTRACT; SUPPORTS_DAC; - if (!Module::IsEncodedModuleIndex(GetModuleID())) - { - return m_ModuleID; - } - -#if !defined(DACCESS_COMPILE) - if (pDomain == NULL) - { - pDomain = GetAppDomain(); - } -#endif // DACCESS_COMPILE - - // If the module is domain neutral, then you must supply an AppDomain argument. - // Use GetDomainLocalModule() if you want to rely on the current AppDomain - _ASSERTE(pDomain != NULL); - - return pDomain->GetDomainLocalBlock()->GetModuleSlot(GetModuleIndex()); + return m_ModuleID; } #include "nibblestream.h" diff --git a/src/vm/class.h b/src/vm/class.h index 7faf7a0..680755e 100644 --- a/src/vm/class.h +++ b/src/vm/class.h @@ -72,7 +72,6 @@ class ArrayMethodDesc; class Assembly; class ClassLoader; class DictionaryLayout; -class DomainLocalBlock; class FCallMethodDesc; class EEClass; class EnCFieldDesc; diff --git a/src/vm/classcompat.h b/src/vm/classcompat.h index f16fcd0..90a56c2 100644 --- a/src/vm/classcompat.h +++ b/src/vm/classcompat.h @@ -38,7 +38,6 @@ class ArrayClass; class ArrayMethodDesc; class Assembly; class ClassLoader; -class DomainLocalBlock; class FCallMethodDesc; class EEClass; class LayoutEEClass; diff --git a/src/vm/clsload.cpp b/src/vm/clsload.cpp index 323e29b..67b4dee 100644 --- a/src/vm/clsload.cpp +++ b/src/vm/clsload.cpp @@ -2236,10 +2236,10 @@ TypeHandle ClassLoader::LookupTypeDefOrRefInModule(Module *pModule, mdToken cl, RETURN(typeHandle); } -DomainAssembly *ClassLoader::GetDomainAssembly(AppDomain *pDomain/*=NULL*/) +DomainAssembly *ClassLoader::GetDomainAssembly() { WRAPPER_NO_CONTRACT; - return GetAssembly()->GetDomainAssembly(pDomain); + return GetAssembly()->GetDomainAssembly(); } #ifndef DACCESS_COMPILE diff --git a/src/vm/clsload.hpp b/src/vm/clsload.hpp index a0debb2..32550fe 100644 --- a/src/vm/clsload.hpp +++ b/src/vm/clsload.hpp @@ -636,7 +636,7 @@ public: void Init(AllocMemTracker *pamTracker); PTR_Assembly GetAssembly(); - DomainAssembly* GetDomainAssembly(AppDomain *pDomain = NULL); + DomainAssembly* GetDomainAssembly(); void FreeModules(); diff --git a/src/vm/debugdebugger.cpp b/src/vm/debugdebugger.cpp index a115238..93457b4 100644 --- a/src/vm/debugdebugger.cpp +++ b/src/vm/debugdebugger.cpp @@ -819,7 +819,7 @@ FCIMPL1(void, DebugDebugger::CustomNotification, Object * dataUNSAFE) StrongHandleHolder objHandle = pAppDomain->CreateStrongHandle(pData); MethodTable * pMT = pData->GetGCSafeMethodTable(); Module * pModule = pMT->GetModule(); - DomainFile * pDomainFile = pModule->GetDomainFile(pAppDomain); + DomainFile * pDomainFile = pModule->GetDomainFile(); mdTypeDef classToken = pMT->GetCl(); pThread->SetThreadCurrNotification(objHandle); diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index 562d551..a60f8d4 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -2421,8 +2421,8 @@ void DomainAssembly::EnumStaticGCRefs(promote_func* fn, ScanContext* sc) { // We guarantee that at this point the module has it's DomainLocalModule set up // , as we create it while we load the module - _ASSERTE(pDomainFile->GetLoadedModule()->GetDomainLocalModule(this->GetAppDomain())); - pDomainFile->GetLoadedModule()->EnumRegularStaticGCRefs(this->GetAppDomain(), fn, sc); + _ASSERTE(pDomainFile->GetLoadedModule()->GetDomainLocalModule()); + pDomainFile->GetLoadedModule()->EnumRegularStaticGCRefs(fn, sc); // We current to do not iterate over the ThreadLocalModules that correspond // to this Module. The GC discovers thread statics through the handle table. diff --git a/src/vm/eventtrace.cpp b/src/vm/eventtrace.cpp index 7c30cde..4eb424f 100644 --- a/src/vm/eventtrace.cpp +++ b/src/vm/eventtrace.cpp @@ -1513,7 +1513,7 @@ void BulkStaticsLogger::LogAllStatics() if (module == NULL) continue; - DomainFile *domainFile = module->FindDomainFile(domain); + DomainFile *domainFile = module->GetDomainFile(); if (domainFile == NULL) continue; @@ -1521,7 +1521,7 @@ void BulkStaticsLogger::LogAllStatics() if (!domainFile->IsActive()) continue; - DomainLocalModule *domainModule = module->GetDomainLocalModule(domain); + DomainLocalModule *domainModule = module->GetDomainLocalModule(); if (domainModule == NULL) continue; @@ -6092,7 +6092,7 @@ VOID ETW::LoaderLog::SendModuleEvent(Module *pModule, DWORD dwEventOptions, BOOL { if(pModule->GetDomain()->IsSharedDomain()) // for shared domains, we do not fire domainmodule event return; - ullAppDomainId = (ULONGLONG)pModule->FindDomainAssembly(pModule->GetDomain()->AsAppDomain())->GetAppDomain(); + ullAppDomainId = (ULONGLONG)pModule->GetDomainAssembly()->GetAppDomain(); } LPCWSTR pEmptyString = W(""); @@ -7193,7 +7193,7 @@ VOID ETW::EnumerationLog::IterateAssembly(Assembly *pAssembly, DWORD enumeration { if(pAssembly->GetDomain()->IsAppDomain()) { - DomainModuleIterator dmIterator = pAssembly->FindDomainAssembly(pAssembly->GetDomain()->AsAppDomain())->IterateModules(kModIterIncludeLoaded); + DomainModuleIterator dmIterator = pAssembly->GetDomainAssembly()->IterateModules(kModIterIncludeLoaded); while (dmIterator.Next()) { ETW::LoaderLog::SendModuleEvent(dmIterator.GetModule(), enumerationOptions, TRUE); diff --git a/src/vm/field.h b/src/vm/field.h index 38b6393..c526453 100644 --- a/src/vm/field.h +++ b/src/vm/field.h @@ -451,7 +451,6 @@ public: } } -#ifndef DACCESS_COMPILE PTR_BYTE GetBase() { CONTRACTL @@ -467,28 +466,6 @@ public: return GetBaseInDomainLocalModule(pMT->GetDomainLocalModule()); } -#endif //!DACCESS_COMPILE - - PTR_BYTE GetBaseInDomain(AppDomain * appDomain) - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - } - CONTRACTL_END; - - Module *pModule = GetEnclosingMethodTable()->GetModuleForStatics(); - if (pModule == NULL) - return NULL; - - DomainLocalModule *pLocalModule = pModule->GetDomainLocalModule(appDomain); - if (pLocalModule == NULL) - return NULL; - - return GetBaseInDomainLocalModule(pLocalModule); - } - // returns the address of the field void* GetStaticAddress(void *base); diff --git a/src/vm/jithelpers.cpp b/src/vm/jithelpers.cpp index 7d0b5a0..11d07e6 100644 --- a/src/vm/jithelpers.cpp +++ b/src/vm/jithelpers.cpp @@ -1337,20 +1337,10 @@ HCIMPLEND #include -HCIMPL2(void*, JIT_GetSharedNonGCStaticBase_Portable, SIZE_T moduleDomainID, DWORD dwClassDomainID) +HCIMPL2(void*, JIT_GetSharedNonGCStaticBase_Portable, DomainLocalModule *pLocalModule, DWORD dwClassDomainID) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule = NULL; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - // If type doesn't have a class constructor, the contents of this if statement may // still get executed. JIT_GetSharedNonGCStaticBaseNoCtor should be used in this case. if (pLocalModule->IsPrecomputedClassInitialized(dwClassDomainID)) @@ -1366,38 +1356,18 @@ HCIMPLEND // No constructor version of JIT_GetSharedNonGCStaticBase. Does not check if class has // been initialized. -HCIMPL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor_Portable, SIZE_T moduleDomainID) +HCIMPL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor_Portable, DomainLocalModule *pLocalModule) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule = NULL; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - return (void*)pLocalModule->GetPrecomputedNonGCStaticsBasePointer(); } HCIMPLEND -HCIMPL2(void*, JIT_GetSharedGCStaticBase_Portable, SIZE_T moduleDomainID, DWORD dwClassDomainID) +HCIMPL2(void*, JIT_GetSharedGCStaticBase_Portable, DomainLocalModule *pLocalModule, DWORD dwClassDomainID) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule = NULL; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - // If type doesn't have a class constructor, the contents of this if statement may // still get executed. JIT_GetSharedGCStaticBaseNoCtor should be used in this case. if (pLocalModule->IsPrecomputedClassInitialized(dwClassDomainID)) @@ -1413,20 +1383,10 @@ HCIMPLEND // No constructor version of JIT_GetSharedGCStaticBase. Does not check if class has been // initialized. -HCIMPL1(void*, JIT_GetSharedGCStaticBaseNoCtor_Portable, SIZE_T moduleDomainID) +HCIMPL1(void*, JIT_GetSharedGCStaticBaseNoCtor_Portable, DomainLocalModule *pLocalModule) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule = NULL; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - return (void*)pLocalModule->GetPrecomputedGCStaticsBasePointer(); } HCIMPLEND @@ -1494,20 +1454,10 @@ HCIMPLEND /*************************************************************/ #include -HCIMPL2(void*, JIT_GetSharedNonGCStaticBaseDynamicClass, SIZE_T moduleDomainID, DWORD dwDynamicClassDomainID) +HCIMPL2(void*, JIT_GetSharedNonGCStaticBaseDynamicClass, DomainLocalModule *pLocalModule, DWORD dwDynamicClassDomainID) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - DomainLocalModule::PTR_DynamicClassInfo pLocalInfo = pLocalModule->GetDynamicClassInfoIfInitialized(dwDynamicClassDomainID); if (pLocalInfo != NULL) { @@ -1546,20 +1496,10 @@ HCIMPL2(void, JIT_ClassInitDynamicClass_Helper, DomainLocalModule *pLocalModule, HCIMPLEND #include -HCIMPL2(void, JIT_ClassInitDynamicClass, SIZE_T moduleDomainID, DWORD dwDynamicClassDomainID) +HCIMPL2(void, JIT_ClassInitDynamicClass, DomainLocalModule *pLocalModule, DWORD dwDynamicClassDomainID) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - DomainLocalModule::PTR_DynamicClassInfo pLocalInfo = pLocalModule->GetDynamicClassInfoIfInitialized(dwDynamicClassDomainID); if (pLocalInfo != NULL) { @@ -1597,20 +1537,10 @@ HCIMPLEND /*************************************************************/ #include -HCIMPL2(void*, JIT_GetSharedGCStaticBaseDynamicClass, SIZE_T moduleDomainID, DWORD dwDynamicClassDomainID) +HCIMPL2(void*, JIT_GetSharedGCStaticBaseDynamicClass, DomainLocalModule *pLocalModule, DWORD dwDynamicClassDomainID) { FCALL_CONTRACT; - DomainLocalModule *pLocalModule; - - if (!Module::IsEncodedModuleIndex(moduleDomainID)) - pLocalModule = (DomainLocalModule *) moduleDomainID; - else - { - DomainLocalBlock *pLocalBlock = GetAppDomain()->GetDomainLocalBlock(); - pLocalModule = pLocalBlock->GetModuleSlot(Module::IDToIndex(moduleDomainID)); - } - DomainLocalModule::PTR_DynamicClassInfo pLocalInfo = pLocalModule->GetDynamicClassInfoIfInitialized(dwDynamicClassDomainID); if (pLocalInfo != NULL) { @@ -1845,15 +1775,12 @@ HCIMPLEND // possible. #include -HCIMPL2(void*, JIT_GetSharedNonGCThreadStaticBase, SIZE_T moduleDomainID, DWORD dwClassDomainID) +HCIMPL2(void*, JIT_GetSharedNonGCThreadStaticBase, DomainLocalModule *pDomainLocalModule, DWORD dwClassDomainID) { FCALL_CONTRACT; // Get the ModuleIndex - ModuleIndex index = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - Module::IDToIndex(moduleDomainID) : - ((DomainLocalModule *)moduleDomainID)->GetModuleIndex(); + ModuleIndex index = pDomainLocalModule->GetModuleIndex(); // Get the relevant ThreadLocalModule ThreadLocalModule * pThreadLocalModule = ThreadStatics::GetTLMIfExists(index); @@ -1866,12 +1793,6 @@ HCIMPL2(void*, JIT_GetSharedNonGCThreadStaticBase, SIZE_T moduleDomainID, DWORD // If the TLM was not allocated or if the class was not marked as initialized // then we have to go through the slow path - // Get the DomainLocalModule - DomainLocalModule *pDomainLocalModule = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - GetAppDomain()->GetDomainLocalBlock()->GetModuleSlot(Module::IDToIndex(moduleDomainID)) : - (DomainLocalModule *) moduleDomainID; - // Obtain the MethodTable MethodTable * pMT = pDomainLocalModule->GetMethodTableFromClassDomainID(dwClassDomainID); _ASSERTE(!pMT->HasGenericsStaticsInfo()); @@ -1889,15 +1810,12 @@ HCIMPLEND // possible. #include -HCIMPL2(void*, JIT_GetSharedGCThreadStaticBase, SIZE_T moduleDomainID, DWORD dwClassDomainID) +HCIMPL2(void*, JIT_GetSharedGCThreadStaticBase, DomainLocalModule *pDomainLocalModule, DWORD dwClassDomainID) { FCALL_CONTRACT; // Get the ModuleIndex - ModuleIndex index = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - Module::IDToIndex(moduleDomainID) : - ((DomainLocalModule *)moduleDomainID)->GetModuleIndex(); + ModuleIndex index = pDomainLocalModule->GetModuleIndex(); // Get the relevant ThreadLocalModule ThreadLocalModule * pThreadLocalModule = ThreadStatics::GetTLMIfExists(index); @@ -1910,12 +1828,6 @@ HCIMPL2(void*, JIT_GetSharedGCThreadStaticBase, SIZE_T moduleDomainID, DWORD dwC // If the TLM was not allocated or if the class was not marked as initialized // then we have to go through the slow path - // Get the DomainLocalModule - DomainLocalModule *pDomainLocalModule = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - GetAppDomain()->GetDomainLocalBlock()->GetModuleSlot(Module::IDToIndex(moduleDomainID)) : - (DomainLocalModule *) moduleDomainID; - // Obtain the MethodTable MethodTable * pMT = pDomainLocalModule->GetMethodTableFromClassDomainID(dwClassDomainID); _ASSERTE(!pMT->HasGenericsStaticsInfo()); @@ -1929,16 +1841,10 @@ HCIMPLEND // *** This helper corresponds to CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS #include -HCIMPL2(void*, JIT_GetSharedNonGCThreadStaticBaseDynamicClass, SIZE_T moduleDomainID, DWORD dwDynamicClassDomainID) +HCIMPL2(void*, JIT_GetSharedNonGCThreadStaticBaseDynamicClass, DomainLocalModule *pDomainLocalModule, DWORD dwDynamicClassDomainID) { FCALL_CONTRACT; - // Obtain the DomainLocalModule - DomainLocalModule *pDomainLocalModule = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - GetAppDomain()->GetDomainLocalBlock()->GetModuleSlot(Module::IDToIndex(moduleDomainID)) : - (DomainLocalModule *)moduleDomainID; - // Get the ModuleIndex ModuleIndex index = pDomainLocalModule->GetModuleIndex(); @@ -1983,16 +1889,10 @@ HCIMPLEND // *** This helper corresponds to CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS #include -HCIMPL2(void*, JIT_GetSharedGCThreadStaticBaseDynamicClass, SIZE_T moduleDomainID, DWORD dwDynamicClassDomainID) +HCIMPL2(void*, JIT_GetSharedGCThreadStaticBaseDynamicClass, DomainLocalModule *pDomainLocalModule, DWORD dwDynamicClassDomainID) { FCALL_CONTRACT; - // Obtain the DomainLocalModule - DomainLocalModule *pDomainLocalModule = - (Module::IsEncodedModuleIndex(moduleDomainID)) ? - GetAppDomain()->GetDomainLocalBlock()->GetModuleSlot(Module::IDToIndex(moduleDomainID)) : - (DomainLocalModule *)moduleDomainID; - // Get the ModuleIndex ModuleIndex index = pDomainLocalModule->GetModuleIndex(); diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h index 4b2fd00..e97eb33 100644 --- a/src/vm/jitinterface.h +++ b/src/vm/jitinterface.h @@ -165,26 +165,26 @@ EXTERN_C FCDECL_MONHELPER(JIT_MonExitStatic_Portable, AwareLock *lock); #ifndef JIT_GetSharedGCStaticBase #define JIT_GetSharedGCStaticBase JIT_GetSharedGCStaticBase_Portable #endif -EXTERN_C FCDECL2(void*, JIT_GetSharedGCStaticBase, SIZE_T moduleDomainID, DWORD dwModuleClassID); -EXTERN_C FCDECL2(void*, JIT_GetSharedGCStaticBase_Portable, SIZE_T moduleDomainID, DWORD dwModuleClassID); +EXTERN_C FCDECL2(void*, JIT_GetSharedGCStaticBase, DomainLocalModule *pLocalModule, DWORD dwModuleClassID); +EXTERN_C FCDECL2(void*, JIT_GetSharedGCStaticBase_Portable, DomainLocalModule *pLocalModule, DWORD dwModuleClassID); #ifndef JIT_GetSharedNonGCStaticBase #define JIT_GetSharedNonGCStaticBase JIT_GetSharedNonGCStaticBase_Portable #endif -EXTERN_C FCDECL2(void*, JIT_GetSharedNonGCStaticBase, SIZE_T moduleDomainID, DWORD dwModuleClassID); -EXTERN_C FCDECL2(void*, JIT_GetSharedNonGCStaticBase_Portable, SIZE_T moduleDomainID, DWORD dwModuleClassID); +EXTERN_C FCDECL2(void*, JIT_GetSharedNonGCStaticBase, DomainLocalModule *pLocalModule, DWORD dwModuleClassID); +EXTERN_C FCDECL2(void*, JIT_GetSharedNonGCStaticBase_Portable, DomainLocalModule *pLocalModule, DWORD dwModuleClassID); #ifndef JIT_GetSharedGCStaticBaseNoCtor #define JIT_GetSharedGCStaticBaseNoCtor JIT_GetSharedGCStaticBaseNoCtor_Portable #endif -EXTERN_C FCDECL1(void*, JIT_GetSharedGCStaticBaseNoCtor, SIZE_T moduleDomainID); -EXTERN_C FCDECL1(void*, JIT_GetSharedGCStaticBaseNoCtor_Portable, SIZE_T moduleDomainID); +EXTERN_C FCDECL1(void*, JIT_GetSharedGCStaticBaseNoCtor, DomainLocalModule *pLocalModule); +EXTERN_C FCDECL1(void*, JIT_GetSharedGCStaticBaseNoCtor_Portable, DomainLocalModule *pLocalModule); #ifndef JIT_GetSharedNonGCStaticBaseNoCtor #define JIT_GetSharedNonGCStaticBaseNoCtor JIT_GetSharedNonGCStaticBaseNoCtor_Portable #endif -EXTERN_C FCDECL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor, SIZE_T moduleDomainID); -EXTERN_C FCDECL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor_Portable, SIZE_T moduleDomainID); +EXTERN_C FCDECL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor, DomainLocalModule *pLocalModule); +EXTERN_C FCDECL1(void*, JIT_GetSharedNonGCStaticBaseNoCtor_Portable, DomainLocalModule *pLocalModule); #ifndef JIT_ChkCastClass #define JIT_ChkCastClass JIT_ChkCastClass_Portable diff --git a/src/vm/loaderallocator.cpp b/src/vm/loaderallocator.cpp index eb3f29b..5ca4b65 100644 --- a/src/vm/loaderallocator.cpp +++ b/src/vm/loaderallocator.cpp @@ -686,15 +686,7 @@ BOOL QCALLTYPE LoaderAllocator::Destroy(QCall::LoaderAllocatorHandle pLoaderAllo if (pDomainAssembly != NULL) { Assembly *pAssembly = pDomainAssembly->GetCurrentAssembly(); - - //if not fully loaded, it is still domain specific, so just get one from DomainAssembly - BaseDomain *pDomain = pAssembly ? pAssembly->Parent() : pDomainAssembly->GetAppDomain(); - - // This will probably change for shared code unloading - _ASSERTE(pDomain->IsAppDomain()); - - AppDomain *pAppDomain = pDomain->AsAppDomain(); - pLoaderAllocator->m_pFirstDomainAssemblyFromSameALCToDelete = pAssembly->GetDomainAssembly(pAppDomain); + pLoaderAllocator->m_pFirstDomainAssemblyFromSameALCToDelete = pAssembly->GetDomainAssembly(); } // Iterate through all references to other loader allocators and decrement their reference diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 27083b0..f1b1f49 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -513,7 +513,7 @@ BOOL MethodTable::ValidateWithPossibleAV() #ifndef DACCESS_COMPILE //========================================================================================== -BOOL MethodTable::IsClassInited(AppDomain* pAppDomain /* = NULL */) +BOOL MethodTable::IsClassInited() { WRAPPER_NO_CONTRACT; @@ -523,15 +523,7 @@ BOOL MethodTable::IsClassInited(AppDomain* pAppDomain /* = NULL */) if (IsSharedByGenericInstantiations()) return FALSE; - DomainLocalModule *pLocalModule; - if (pAppDomain == NULL) - { - pLocalModule = GetDomainLocalModule(); - } - else - { - pLocalModule = GetDomainLocalModule(pAppDomain); - } + DomainLocalModule *pLocalModule = GetDomainLocalModule(); _ASSERTE(pLocalModule != NULL); diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h index 18cca3f..3fe016f 100644 --- a/src/vm/methodtable.h +++ b/src/vm/methodtable.h @@ -36,7 +36,6 @@ class ArrayClass; class ArrayMethodDesc; struct ClassCtorInfoEntry; class ClassLoader; -class DomainLocalBlock; class FCallMethodDesc; class EEClass; class EnCFieldDesc; @@ -693,12 +692,7 @@ public: void SetLoaderAllocator(LoaderAllocator* pAllocator); // Get the domain local module - useful for static init checks - PTR_DomainLocalModule GetDomainLocalModule(AppDomain * pAppDomain); - -#ifndef DACCESS_COMPILE - // Version of GetDomainLocalModule which relies on the current AppDomain PTR_DomainLocalModule GetDomainLocalModule(); -#endif MethodTable *LoadEnclosingMethodTable(ClassLoadLevel targetLevel = CLASS_DEPENDENCIES_LOADED); @@ -877,7 +871,7 @@ public: //------------------------------------------------------------------- // THE CLASS INITIALIZATION CONDITION - // (and related DomainLocalBlock/DomainLocalModule storage) + // (and related DomainLocalModule storage) // // - populate the DomainLocalModule if needed // - run the cctor @@ -914,7 +908,7 @@ public: // mark the class as having its cctor run. #ifndef DACCESS_COMPILE void SetClassInited(); - BOOL IsClassInited(AppDomain* pAppDomain = NULL); + BOOL IsClassInited(); BOOL IsInitError(); void SetClassInitError(); diff --git a/src/vm/methodtable.inl b/src/vm/methodtable.inl index afb5237..31e373c 100644 --- a/src/vm/methodtable.inl +++ b/src/vm/methodtable.inl @@ -1490,20 +1490,11 @@ inline PTR_BYTE MethodTable::GetGCThreadStaticsBasePointer(PTR_Thread pThread) } //========================================================================================== -inline PTR_DomainLocalModule MethodTable::GetDomainLocalModule(AppDomain * pAppDomain) -{ - WRAPPER_NO_CONTRACT; - return GetModuleForStatics()->GetDomainLocalModule(pAppDomain); -} - -#ifndef DACCESS_COMPILE -//========================================================================================== inline PTR_DomainLocalModule MethodTable::GetDomainLocalModule() { WRAPPER_NO_CONTRACT; return GetModuleForStatics()->GetDomainLocalModule(); } -#endif //!DACCESS_COMPILE //========================================================================================== inline OBJECTREF MethodTable::AllocateNoChecks() diff --git a/src/vm/multicorejit.cpp b/src/vm/multicorejit.cpp index 20e8f4b..5ff9bb1 100644 --- a/src/vm/multicorejit.cpp +++ b/src/vm/multicorejit.cpp @@ -234,7 +234,7 @@ FileLoadLevel MulticoreJitManager::GetModuleFileLoadLevel(Module * pModule) if (pModule != NULL) { - DomainFile * pDomainFile = pModule->FindDomainFile(GetAppDomain()); + DomainFile * pDomainFile = pModule->GetDomainFile(); if (pDomainFile != NULL) { diff --git a/src/vm/pefile.cpp b/src/vm/pefile.cpp index f0a44d8..5c7aa55 100644 --- a/src/vm/pefile.cpp +++ b/src/vm/pefile.cpp @@ -1716,7 +1716,7 @@ BOOL PEFile::GetResource(LPCSTR szName, DWORD *cbResource, if (pAssembly == NULL) return FALSE; - pDomainAssembly = pAssembly->GetDomainAssembly(pAppDomain); + pDomainAssembly = pAssembly->GetDomainAssembly(); pPEFile = pDomainAssembly->GetFile(); if (FAILED(pAssembly->GetManifestImport()->FindManifestResourceByName( diff --git a/src/vm/profilingenumerators.cpp b/src/vm/profilingenumerators.cpp index 0cb3148..b03638f 100644 --- a/src/vm/profilingenumerators.cpp +++ b/src/vm/profilingenumerators.cpp @@ -310,76 +310,6 @@ HRESULT IterateUnsharedModules(AppDomain * pAppDomain, //--------------------------------------------------------------------------------------- -// This is a helper class used by ProfilerModuleEnum when determining which shared -// modules should be added to the enumerator. See code:ProfilerModuleEnum::Init for how -// this gets used - -class IterateAppDomainsForSharedModule -{ -public: - IterateAppDomainsForSharedModule(CDynArray< ModuleID > * pElements, Module * pModule) - : m_pElements(pElements), m_pModule(pModule) - { - LIMITED_METHOD_CONTRACT; - } - - //--------------------------------------------------------------------------------------- - // Callback passed to IterateAppDomains, that takes the currently iterated AppDomain, - // and adds m_pModule to the enumerator if it's loaded into the AppDomain. See - // code:ProfilerModuleEnum::Init for how this gets used. - // - // Arguments: - // * pAppDomain - Current AppDomain being iterated. - // - // Return Value: - // * S_OK = the iterator should continue after we return. - // * S_FALSE = we verified m_pModule is loaded into this AppDomain, so no need - // for the iterator to continue with the next AppDomain - // * error indicating a failure - // - HRESULT AddSharedModuleForAppDomain(AppDomain * pAppDomain) - { - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - CANNOT_TAKE_LOCK; - } - CONTRACTL_END; - - DomainFile * pDomainFile = m_pModule->FindDomainFile(pAppDomain); - if ((pDomainFile == NULL) || !pDomainFile->IsAvailableToProfilers()) - { - // This AD doesn't contain a fully loaded DomainFile for m_pModule. So continue - // iterating with the next AD - return S_OK; - } - - ModuleID * pElement = m_pElements->Append(); - if (pElement == NULL) - { - // Stop iteration with error - return E_OUTOFMEMORY; - } - - // If we're here, we found a fully loaded DomainFile for m_pModule. So add - // m_pModule to our array, and no need to look at other other ADs for this - // m_pModule. - *pElement = (ModuleID) m_pModule; - return S_FALSE; - } - -private: - // List of ModuleIDs in the enumerator we're building - CDynArray< ModuleID > * m_pElements; - - // Shared Module we're testing for load status in the iterated ADs. - Module * m_pModule; -}; - - -//--------------------------------------------------------------------------------------- // // Callback passed to IterateAppDomains, that takes the currently iterated AppDomain, // and then iterates through the unshared modules loaded into that AD. See @@ -528,7 +458,7 @@ HRESULT IterateAppDomainContainingModule::AddAppDomainContainingModule(AppDomain } CONTRACTL_END; - DomainFile * pDomainFile = m_pModule->FindDomainFile(pAppDomain); + DomainFile * pDomainFile = m_pModule->GetDomainFile(); if ((pDomainFile != NULL) && (pDomainFile->IsAvailableToProfilers())) { if (m_index < m_cAppDomainIds) diff --git a/src/vm/proftoeeinterfaceimpl.cpp b/src/vm/proftoeeinterfaceimpl.cpp index 663b82f..e663298 100644 --- a/src/vm/proftoeeinterfaceimpl.cpp +++ b/src/vm/proftoeeinterfaceimpl.cpp @@ -3113,7 +3113,7 @@ HRESULT ProfToEEInterfaceImpl::GetRVAStaticAddress(ClassID classId, // // Check that the data is available // - if (!IsClassOfMethodTableInited(pMethodTable, GetAppDomain())) + if (!IsClassOfMethodTableInited(pMethodTable)) { return CORPROF_E_DATAINCOMPLETE; } @@ -3170,7 +3170,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainStaticAddress(ClassID classId, // Yay! EE_THREAD_NOT_REQUIRED; - // FieldDesc::GetStaticAddress & FieldDesc::GetBaseInDomain take locks + // FieldDesc::GetStaticAddress & FieldDesc::GetBase take locks CAN_TAKE_LOCK; } @@ -3251,7 +3251,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainStaticAddress(ClassID classId, // // Check that the data is available // - if (!IsClassOfMethodTableInited(pMethodTable, pAppDomain)) + if (!IsClassOfMethodTableInited(pMethodTable)) { return CORPROF_E_DATAINCOMPLETE; } @@ -3259,7 +3259,7 @@ HRESULT ProfToEEInterfaceImpl::GetAppDomainStaticAddress(ClassID classId, // // Get the address // - void *base = (void*)pFieldDesc->GetBaseInDomain(pAppDomain); + void *base = (void*)pFieldDesc->GetBase(); if (base == NULL) { @@ -3466,12 +3466,11 @@ HRESULT ProfToEEInterfaceImpl::GetThreadStaticAddress2(ClassID classId, // It may seem redundant to try to retrieve the same method table from GetEnclosingMethodTable, but classId // leads to the instantiated method table while GetEnclosingMethodTable returns the uninstantiated one. MethodTable *pMethodTable = pFieldDesc->GetEnclosingMethodTable(); - AppDomain * pAppDomain = (AppDomain *)appDomainId; // // Check that the data is available // - if (!IsClassOfMethodTableInited(pMethodTable, pAppDomain)) + if (!IsClassOfMethodTableInited(pMethodTable)) { return CORPROF_E_DATAINCOMPLETE; } diff --git a/src/vm/proftoeeinterfaceimpl.inl b/src/vm/proftoeeinterfaceimpl.inl index 376fad2..58a3770 100644 --- a/src/vm/proftoeeinterfaceimpl.inl +++ b/src/vm/proftoeeinterfaceimpl.inl @@ -178,14 +178,14 @@ inline ProfToEEInterfaceImpl::ProfToEEInterfaceImpl() }; -inline BOOL IsClassOfMethodTableInited(MethodTable * pMethodTable, AppDomain * pAppDomain) +inline BOOL IsClassOfMethodTableInited(MethodTable * pMethodTable) { LIMITED_METHOD_CONTRACT; return (pMethodTable->IsRestored() && (pMethodTable->GetModuleForStatics() != NULL) && - (pMethodTable->GetDomainLocalModule(pAppDomain) != NULL) && - pMethodTable->IsClassInited(pAppDomain)); + (pMethodTable->GetDomainLocalModule() != NULL) && + pMethodTable->IsClassInited()); } diff --git a/src/vm/reflectioninvocation.cpp b/src/vm/reflectioninvocation.cpp index ec1d175..3d45ef2 100644 --- a/src/vm/reflectioninvocation.cpp +++ b/src/vm/reflectioninvocation.cpp @@ -1926,7 +1926,7 @@ FCIMPL1(void, ReflectionInvocation::RunModuleConstructor, ReflectModuleBaseObjec Assembly *pAssem = pModule->GetAssembly(); - DomainFile *pDomainFile = pModule->FindDomainFile(GetAppDomain()); + DomainFile *pDomainFile = pModule->GetDomainFile(); if (pDomainFile==NULL || !pDomainFile->IsActive()) { HELPER_METHOD_FRAME_BEGIN_1(refModule); diff --git a/src/vm/runtimehandles.cpp b/src/vm/runtimehandles.cpp index 620886e..911dcab 100644 --- a/src/vm/runtimehandles.cpp +++ b/src/vm/runtimehandles.cpp @@ -169,7 +169,7 @@ NOINLINE ReflectModuleBaseObject* GetRuntimeModuleHelper(LPVOID __me, Module *pM if (pModule == NULL) return NULL; - DomainFile * pDomainFile = pModule->FindDomainFile(GetAppDomain()); + DomainFile * pDomainFile = pModule->GetDomainFile(); OBJECTREF refModule = (pDomainFile != NULL) ? pDomainFile->GetExposedModuleObjectIfExists() : NULL; @@ -500,13 +500,10 @@ FCIMPL1(AssemblyBaseObject*, RuntimeTypeHandle::GetAssembly, ReflectClassBaseObj if (refType == NULL) FCThrowRes(kArgumentNullException, W("Arg_InvalidHandle")); - DomainFile *pDomainFile = NULL; - - Module *pModule = refType->GetType().GetAssembly()->GetManifestModule(); - - pDomainFile = pModule->FindDomainFile(GetAppDomain()); + Module *pModule = refType->GetType().GetAssembly()->GetManifestModule(); + DomainAssembly *pDomainAssembly = pModule->GetDomainAssembly(); - FC_RETURN_ASSEMBLY_OBJECT((DomainAssembly *)pDomainFile, refType); + FC_RETURN_ASSEMBLY_OBJECT(pDomainAssembly, refType); } FCIMPLEND @@ -2761,7 +2758,7 @@ FCIMPL1(ReflectModuleBaseObject*, AssemblyHandle::GetManifestModule, AssemblyBas return NULL; Module *pModule = currentAssembly->GetManifestModule(); - DomainFile * pDomainFile = pModule->FindDomainFile(GetAppDomain()); + DomainFile * pDomainFile = pModule->GetDomainFile(); #ifdef _DEBUG OBJECTREF orModule; diff --git a/src/vm/threadstatics.h b/src/vm/threadstatics.h index c85245d..1269277 100644 --- a/src/vm/threadstatics.h +++ b/src/vm/threadstatics.h @@ -13,8 +13,7 @@ // sets and gets values for that field. // // This implementation of thread statics closely parallels the implementation for regular statics. Regular -// statics use the DomainLocalBlock and DomainLocalModule structures to allocate space for statics each time -// a module is loaded in an AppDomain. +// statics use the DomainLocalModule structure to allocate space for statics. // // diff --git a/src/vm/zapsig.cpp b/src/vm/zapsig.cpp index 73cc604..fbf67c0 100644 --- a/src/vm/zapsig.cpp +++ b/src/vm/zapsig.cpp @@ -652,7 +652,7 @@ Module *ZapSig::DecodeModuleFromIndex(Module *fromModule, { if (index < fromModule->GetAssemblyRefMax()) { - pAssembly = fromModule->LoadAssembly(GetAppDomain(), RidToToken(index, mdtAssemblyRef))->GetAssembly(); + pAssembly = fromModule->LoadAssembly(RidToToken(index, mdtAssemblyRef))->GetAssembly(); } else { -- 2.7.4