diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-11-28 18:18:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-28 18:18:04 -0800 |
commit | b6d47b3a1b5b05c25968701615707e381f35a7ce (patch) | |
tree | 33056aabf9b36b2fbfd7d91218bd0a6fa3ff2cf3 /src/vm/domainfile.cpp | |
parent | e7ead79fedc52e17f2cf9befd5c0f5091d70f909 (diff) | |
download | coreclr-b6d47b3a1b5b05c25968701615707e381f35a7ce.tar.gz coreclr-b6d47b3a1b5b05c25968701615707e381f35a7ce.tar.bz2 coreclr-b6d47b3a1b5b05c25968701615707e381f35a7ce.zip |
Delete code related to LoaderOptimization and SharedDomain (#21031)
Diffstat (limited to 'src/vm/domainfile.cpp')
-rw-r--r-- | src/vm/domainfile.cpp | 294 |
1 files changed, 18 insertions, 276 deletions
diff --git a/src/vm/domainfile.cpp b/src/vm/domainfile.cpp index 8f19137ec6..664d10e690 100644 --- a/src/vm/domainfile.cpp +++ b/src/vm/domainfile.cpp @@ -1208,215 +1208,30 @@ void DomainFile::Activate() // Now activate any dependencies. // This will typically cause reentrancy of course. - if (!IsSingleAppDomain()) - { - // increment the counter (see the comment in Module::AddActiveDependency) - GetModule()->IncrementNumberOfActivations(); - -#ifdef FEATURE_LOADER_OPTIMIZATION - AppDomain *pDomain = this->GetAppDomain(); - Module::DependencyIterator i = GetCurrentModule()->IterateActiveDependencies(); - STRESS_LOG2(LF_LOADER, LL_INFO100,"Activating module %p in AD %i",GetCurrentModule(),pDomain->GetId().m_dwId); - - while (i.Next()) - { - Module *pModule = i.GetDependency(); - DomainFile *pDomainFile = pModule->FindDomainFile(pDomain); - if (pDomainFile == NULL) - pDomainFile = pDomain->LoadDomainNeutralModuleDependency(pModule, FILE_LOADED); - - STRESS_LOG3(LF_LOADER, LL_INFO100,"Activating dependency %p -> %p, unconditional=%i",GetCurrentModule(),pModule,i.IsUnconditional()); - - if (i.IsUnconditional()) - { - // Let any failures propagate - pDomainFile->EnsureActive(); - } - else - { - // Enable triggers if we fail here - if (!pDomainFile->TryEnsureActive()) - GetCurrentModule()->EnableModuleFailureTriggers(pModule, this->GetAppDomain()); - } - STRESS_LOG3(LF_LOADER, LL_INFO100,"Activated dependency %p -> %p, unconditional=%i",GetCurrentModule(),pModule,i.IsUnconditional()); - } -#endif - } - #ifndef CROSSGEN_COMPILE - if (m_pModule->CanExecuteCode()) - { - // - // Now call the module constructor. Note that this might cause reentrancy; - // this is fine and will be handled by the class cctor mechanism. - // - MethodTable *pMT = m_pModule->GetGlobalMethodTable(); - if (pMT != NULL) - { - pMT->CheckRestore(); - m_bDisableActivationCheck=TRUE; - pMT->CheckRunClassInitThrowing(); - } -#ifdef _DEBUG - if (g_pConfig->ExpandModulesOnLoad()) - { - m_pModule->ExpandAll(); - } -#endif //_DEBUG - } - else - { - // This exception does not need to be localized as it can only happen in - // NGen and PEVerify, and we are not localizing those tools. - _ASSERTE(this->GetAppDomain()->IsPassiveDomain()); - // This assert will fire if we attempt to run non-mscorlib code from within ngen - // Current audits of the system indicate that this will never occur, but if it does - // the exception below will prevent actual non-mscorlib code execution. - _ASSERTE(!this->GetAppDomain()->IsCompilationDomain()); - - LPCWSTR message = W("You may be trying to evaluate a permission from an assembly ") - W("without FullTrust, or which cannot execute code for other reasons."); - COMPlusThrowNonLocalized(kFileLoadException, message); - } -#endif // CROSSGEN_COMPILE - - RETURN; -} - -#ifdef FEATURE_LOADER_OPTIMIZATION -BOOL DomainFile::PropagateActivationInAppDomain(Module *pModuleFrom, Module *pModuleTo, AppDomain* pDomain) -{ - CONTRACTL - { - PRECONDITION(CheckPointer(pModuleFrom)); - PRECONDITION(CheckPointer(pModuleTo)); - THROWS; // should only throw transient failures - DISABLED(GC_TRIGGERS); - MODE_ANY; - } - CONTRACTL_END; - -#ifdef FEATURE_MULTICOREJIT - // Reset the flag to allow managed code to be called in multicore JIT background thread from this routine - ThreadStateNCStackHolder holder(-1, Thread::TSNC_CallingManagedCodeDisabled); -#endif - - BOOL completed=true; - EX_TRY - { - GCX_COOP(); - - ENTER_DOMAIN_PTR(pDomain,ADV_ITERATOR); //iterator - DomainFile *pDomainFileFrom = pModuleFrom->FindDomainFile(pDomain); - if (pDomainFileFrom != NULL && pDomain->IsLoading(pDomainFileFrom, FILE_ACTIVE)) - { - STRESS_LOG3(LF_LOADER, LL_INFO100,"Found DomainFile %p for module %p in AppDomain %i\n",pDomainFileFrom,pModuleFrom,pDomain->GetId().m_dwId); - DomainFile *pDomainFileTo = pModuleTo->FindDomainFile(pDomain); - if (pDomainFileTo == NULL) - pDomainFileTo = pDomain->LoadDomainNeutralModuleDependency(pModuleTo, FILE_LOADED); - - if (!pDomainFileTo->TryEnsureActive()) - pModuleFrom->EnableModuleFailureTriggers(pModuleTo, pDomain); - else if (!pDomainFileTo->IsActive()) - { - // We are in a reentrant case - completed = FALSE; - } - } - END_DOMAIN_TRANSITION; - } - EX_CATCH - { - if (!IsExceptionOfType(kAppDomainUnloadedException, GET_EXCEPTION())) - EX_RETHROW; - } - EX_END_CATCH(SwallowAllExceptions) - return completed; -} -#endif + // + // Now call the module constructor. Note that this might cause reentrancy; + // this is fine and will be handled by the class cctor mechanism. + // -// Returns TRUE if activation is completed for all app domains -// static -BOOL DomainFile::PropagateNewActivation(Module *pModuleFrom, Module *pModuleTo) -{ - CONTRACTL + MethodTable *pMT = m_pModule->GetGlobalMethodTable(); + if (pMT != NULL) { - PRECONDITION(CheckPointer(pModuleFrom)); - PRECONDITION(CheckPointer(pModuleTo)); - THROWS; // should only throw transient failures - GC_TRIGGERS; - MODE_ANY; + pMT->CheckRestore(); + m_bDisableActivationCheck=TRUE; + pMT->CheckRunClassInitThrowing(); } - CONTRACTL_END; - - BOOL completed = TRUE; -#ifdef FEATURE_LOADER_OPTIMIZATION - if (pModuleFrom->GetAssembly()->IsDomainNeutral()) - { - AppDomainIterator ai(TRUE); - Thread *pThread = GetThread(); - - while (ai.Next()) - { - STRESS_LOG3(LF_LOADER, LL_INFO100,"Attempting to propagate domain-neutral conditional module dependency %p -> %p to AppDomain %i\n",pModuleFrom,pModuleTo,ai.GetDomain()->GetId().m_dwId); - completed &= PropagateActivationInAppDomain(pModuleFrom,pModuleTo,ai.GetDomain()); - } - } - else -#endif - { - AppDomain *pDomain = pModuleFrom->GetDomain()->AsAppDomain(); - DomainFile *pDomainFileFrom = pModuleFrom->GetDomainFile(pDomain); - if (pDomain->IsLoading(pDomainFileFrom, FILE_ACTIVE)) - { - // The dependency should already be loaded - DomainFile *pDomainFileTo = pModuleTo->GetDomainFile(pDomain); - if (!pDomainFileTo->TryEnsureActive()) - pModuleFrom->EnableModuleFailureTriggers(pModuleTo, pDomain); - else if (!pDomainFileTo->IsActive()) - { - // Reentrant case - completed = FALSE; - } - } - } - - return completed; -} - -// Checks that module has not been activated in any domain -CHECK DomainFile::CheckUnactivatedInAllDomains(Module *pModule) -{ - CONTRACTL +#ifdef _DEBUG + if (g_pConfig->ExpandModulesOnLoad()) { - PRECONDITION(CheckPointer(pModule)); - THROWS; - GC_TRIGGERS; - MODE_ANY; + m_pModule->ExpandAll(); } - CONTRACTL_END; - - if (pModule->GetAssembly()->IsDomainNeutral()) - { - AppDomainIterator ai(TRUE); +#endif //_DEBUG - while (ai.Next()) - { - AppDomain *pDomain = ai.GetDomain(); - DomainFile *pDomainFile = pModule->FindDomainFile(pDomain); - if (pDomainFile != NULL) - CHECK(!pDomainFile->IsActive()); - } - } - else - { - DomainFile *pDomainFile = pModule->FindDomainFile(pModule->GetDomain()->AsAppDomain()); - if (pDomainFile != NULL) - CHECK(!pDomainFile->IsActive()); - } +#endif // CROSSGEN_COMPILE - CHECK_OK; + RETURN; } #ifdef FEATURE_PREJIT @@ -1448,7 +1263,6 @@ DomainAssembly::DomainAssembly(AppDomain *pDomain, PEFile *pFile, LoaderAllocato : DomainFile(pDomain, pFile), m_pAssembly(NULL), m_debuggerFlags(DACF_NONE), - m_MissingDependenciesCheckStatus(CMD_Unknown), m_fDebuggerUnloadStarted(FALSE), m_fCollectible(pLoaderAllocator->IsCollectible()), m_fHostAssemblyPublished(false), @@ -1628,23 +1442,6 @@ OBJECTREF DomainAssembly::GetExposedAssemblyObject() } // DomainAssembly::GetExposedAssemblyObject #endif // CROSSGEN_COMPILE -#ifdef FEATURE_LOADER_OPTIMIZATION - - -BOOL DomainAssembly::MissingDependenciesCheckDone() -{ - return m_MissingDependenciesCheckStatus != CMD_Unknown; -} - -CMD_State DomainAssembly::CheckMissingDependencies() -{ - //CoreCLR simply doesn't share if dependencies are missing - return CMD_NotNeeded; -} - -#endif // FEATURE_LOADER_OPTIMIZATION - - DomainFile* DomainAssembly::FindIJWModule(HMODULE hMod) { CONTRACT (DomainFile*) @@ -1736,31 +1533,7 @@ void DomainAssembly::FindNativeImage() ReleaseHolder<PEImage> pNativeImage = GetFile()->GetNativeImageWithRef(); - if(!IsSystem() && !SystemDomain::System()->SystemFile()->HasNativeImage()) - { - m_dwReasonForRejectingNativeImage = ReasonForRejectingNativeImage_MscorlibNotNative; - STRESS_LOG2(LF_ZAP,LL_INFO100,"Rejecting native file %p, because mscolib has not NI - reason 0x%x\n",pNativeImage.GetValue(),m_dwReasonForRejectingNativeImage); - ExternalLog(LL_ERROR, "Rejecting native image because mscorlib does not have native image"); - GetFile()->ClearNativeImage(); - - // Always throw exceptions when we throw the NI out - ThrowHR(CLR_E_BIND_SYS_ASM_NI_MISSING); - } - else - if (!CheckZapSecurity(pNativeImage)) - { - m_dwReasonForRejectingNativeImage = ReasonForRejectingNativeImage_FailedSecurityCheck; - STRESS_LOG2(LF_ZAP,LL_INFO100,"Rejecting native file %p, because security check failed - reason 0x%x\n",pNativeImage.GetValue(),m_dwReasonForRejectingNativeImage); - ExternalLog(LL_ERROR, "Rejecting native image because it failed the security check. " - "The assembly's permissions must have changed since the time it was ngenned, " - "or it is running with a different security context."); - - GetFile()->ClearNativeImage(); - - // Always throw exceptions when we throw the NI out - ThrowHR(CLR_E_BIND_NI_SECURITY_FAILURE); - } - else if (!CheckZapDependencyIdentities(pNativeImage)) + if (!CheckZapDependencyIdentities(pNativeImage)) { m_dwReasonForRejectingNativeImage = ReasonForRejectingNativeImage_DependencyIdentityMismatch; STRESS_LOG2(LF_ZAP,LL_INFO100,"Rejecting native file %p, because dependency identity mismatch - reason 0x%x\n",pNativeImage.GetValue(),m_dwReasonForRejectingNativeImage); @@ -1775,30 +1548,13 @@ void DomainAssembly::FindNativeImage() } else { - // We can only use a native image for a single Module. If this is a domain-bound - // load, we know that this means only a single load will use this image, so we can just - // flag it as in use. - - // If on the other hand, we are going to be domain neutral, we may have many loads use - // the same native image. Still, we only want to allow the native image to be used - // by loads which are going to end up with the same Module. So, we have to effectively - // eagerly compute whether that will be the case eagerly, now. To enable this computation, - // we store the binding closure in the image. - Module * pNativeModule = pNativeImage->GetLoadedLayout()->GetPersistedModuleImage(); EnsureWritablePages(pNativeModule); PEFile ** ppNativeFile = (PEFile **) (PBYTE(pNativeModule) + Module::GetFileOffset()); - GetFile()->SetNativeImageUsedExclusively(); PEAssembly * pFile = (PEAssembly *)FastInterlockCompareExchangePointer((void **)ppNativeFile, (void *)GetFile(), (void *)NULL); STRESS_LOG3(LF_ZAP,LL_INFO100,"Attempted to set new native file %p, old file was %p, location in the image=%p\n",GetFile(),pFile,ppNativeFile); - if (pFile!=NULL && !IsSystem() && - - ( pFile == PEFile::Dummy() || - pFile->IsNativeImageUsedExclusively() || - !(GetFile()->GetPath().Equals(pFile->GetPath()))) - - ) + if (pFile!=NULL) { // The non-shareable native image has already been used in this process by another Module. // We have to abandon the native image. (Note that it isn't enough to @@ -1823,9 +1579,7 @@ void DomainAssembly::FindNativeImage() } else { - //If we are the first and others can reuse us, we cannot go away - if ((pFile == NULL) && (!GetFile()->IsNativeImageUsedExclusively())) - GetFile()->AddRef(); + GetFile()->AddRef(); LOG((LF_ZAP, LL_INFO100, "ZAP: Found a candidate native image for %s\n", GetSimpleName())); } @@ -2301,18 +2055,6 @@ BOOL DomainAssembly::CheckZapDependencyIdentities(PEImage *pNativeImage) return TRUE; } - -BOOL DomainAssembly::CheckZapSecurity(PEImage *pNativeImage) -{ - CONTRACTL - { - INSTANCE_CHECK; - STANDARD_VM_CHECK; - } - CONTRACTL_END; - - return TRUE; -} #endif // FEATURE_PREJIT |