From 41e223bfb604759ea19637f81fb738ba84c61f40 Mon Sep 17 00:00:00 2001 From: Elinor Fung <47805090+elinor-fung@users.noreply.github.com> Date: Tue, 8 Oct 2019 19:47:43 -0700 Subject: [PATCH] Remove some unused code in binder (dotnet/coreclr#27095) Commit migrated from https://github.com/dotnet/coreclr/commit/1ced1af44e3fc3c8e0ccca4b846b5e635ba0c3bc --- src/coreclr/src/binder/CMakeLists.txt | 2 - src/coreclr/src/binder/assembly.cpp | 46 ----- src/coreclr/src/binder/assemblybinder.cpp | 62 ------ src/coreclr/src/binder/binderinterface.cpp | 191 ------------------ src/coreclr/src/binder/fusionassemblyname.cpp | 1 - src/coreclr/src/binder/inc/assembly.hpp | 6 - src/coreclr/src/binder/inc/assembly.inl | 15 -- .../src/binder/inc/binderinterface.hpp | 69 ------- src/coreclr/src/vm/appdomain.cpp | 30 --- src/coreclr/src/vm/appdomain.hpp | 26 --- 10 files changed, 448 deletions(-) delete mode 100644 src/coreclr/src/binder/binderinterface.cpp delete mode 100644 src/coreclr/src/binder/inc/binderinterface.hpp diff --git a/src/coreclr/src/binder/CMakeLists.txt b/src/coreclr/src/binder/CMakeLists.txt index 46f46e32397..e17f5a707c7 100644 --- a/src/coreclr/src/binder/CMakeLists.txt +++ b/src/coreclr/src/binder/CMakeLists.txt @@ -14,7 +14,6 @@ set(BINDER_COMMON_SOURCES assemblybinder.cpp stringlexer.cpp clrprivbindercoreclr.cpp - binderinterface.cpp debuglog.cpp bindinglog.cpp cdebuglog.cpp @@ -38,7 +37,6 @@ set(BINDER_COMMON_HEADERS inc/assemblyname.inl inc/assemblyversion.hpp inc/assemblyversion.inl - inc/binderinterface.hpp inc/bindertypes.hpp inc/bindinglog.hpp inc/bindinglog.inl diff --git a/src/coreclr/src/binder/assembly.cpp b/src/coreclr/src/binder/assembly.cpp index 73b9c2688c4..f5145b18d55 100644 --- a/src/coreclr/src/binder/assembly.cpp +++ b/src/coreclr/src/binder/assembly.cpp @@ -24,49 +24,6 @@ namespace BINDER_SPACE { return ((kArchitecture != peMSIL) && (kArchitecture != peNone)); } - - HRESULT GetAssemblyRefTokens(IMDInternalImport *pMDImport, - mdAssembly **ppAssemblyRefTokens, - DWORD *pdwCAssemblyRefTokens) - { - HRESULT hr = S_OK; - - _ASSERTE(pMDImport != NULL); - _ASSERTE(ppAssemblyRefTokens != NULL); - _ASSERTE(pdwCAssemblyRefTokens != NULL); - - mdAssembly *pAssemblyRefTokens = NULL; - COUNT_T assemblyRefCount; - - HENUMInternalHolder hEnumAssemblyRef(pMDImport); - IF_FAIL_GO(hEnumAssemblyRef.EnumInitNoThrow(mdtAssemblyRef, mdTokenNil)); - - assemblyRefCount = hEnumAssemblyRef.EnumGetCount(); - - pAssemblyRefTokens = new (nothrow) mdAssemblyRef[assemblyRefCount]; - if (pAssemblyRefTokens == NULL) - { - IF_FAIL_GO(E_OUTOFMEMORY); - } - ZeroMemory(pAssemblyRefTokens, assemblyRefCount * sizeof(mdAssemblyRef)); - - for (COUNT_T i = 0; i < assemblyRefCount; i++) - { - bool ret = hEnumAssemblyRef.EnumNext(&(pAssemblyRefTokens[i])); - _ASSERTE(ret); - } - - *ppAssemblyRefTokens = pAssemblyRefTokens; - pAssemblyRefTokens = NULL; - - *pdwCAssemblyRefTokens= assemblyRefCount; - hr = S_OK; - -Exit: - SAFE_DELETE_ARRAY(pAssemblyRefTokens); - - return hr; - } }; STDMETHODIMP Assembly::QueryInterface(REFIID riid, @@ -119,8 +76,6 @@ Exit: m_pNativePEImage = NULL; m_pAssemblyName = NULL; m_pMDImport = NULL; - m_pAssemblyRefTokens = NULL; - m_dwCAssemblyRefTokens = static_cast(-1); m_dwAssemblyFlags = FLAG_NONE; m_pBinder = NULL; } @@ -145,7 +100,6 @@ Exit: SAFE_RELEASE(m_pAssemblyName); SAFE_RELEASE(m_pMDImport); - SAFE_DELETE_ARRAY(m_pAssemblyRefTokens); } HRESULT Assembly::Init(IMDInternalImport *pIMetaDataAssemblyImport, diff --git a/src/coreclr/src/binder/assemblybinder.cpp b/src/coreclr/src/binder/assemblybinder.cpp index e3f9b5165c9..1fc1e70e8bb 100644 --- a/src/coreclr/src/binder/assemblybinder.cpp +++ b/src/coreclr/src/binder/assemblybinder.cpp @@ -35,10 +35,6 @@ #define APP_DOMAIN_LOCKED_UNLOCKED 0x02 #define APP_DOMAIN_LOCKED_CONTEXT 0x04 -#define BIND_BEHAVIOR_STATIC 0 -#define BIND_BEHAVIOR_ORDER_INDEPENDENT 1 -#define BIND_BEHAVIOR_BEST_MATCH 2 - #ifndef IMAGE_FILE_MACHINE_ARM64 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 // ARM64 Little-Endian #endif @@ -280,42 +276,6 @@ namespace BINDER_SPACE return hr; } - HRESULT LogBindBehavior(ApplicationContext *pApplicationContext, - DWORD dwBindBehavior) - { - HRESULT hr = S_OK; - BindingLog *pBindingLog = pApplicationContext->GetBindingLog(); - - if (pBindingLog->CanLog()) - { - PathString bindBehavior; - UINT uiBindBehavior = 0; - - switch (dwBindBehavior) - { - case BIND_BEHAVIOR_STATIC: - uiBindBehavior = ID_FUSLOG_BINDING_BEHAVIOR_STATIC; - break; - case BIND_BEHAVIOR_ORDER_INDEPENDENT: - uiBindBehavior = ID_FUSLOG_BINDING_BEHAVIOR_ORDER_INDEPENDENT; - break; - case BIND_BEHAVIOR_BEST_MATCH: - uiBindBehavior = ID_FUSLOG_BINDING_BEHAVIOR_BEST_MATCH; - break; - default: - _ASSERTE(0); - IF_FAIL_GO(E_INVALIDARG); - break; - } - - IF_FAIL_GO(bindBehavior.LoadResourceAndReturnHR(CCompRC::Debugging, uiBindBehavior)); - IF_FAIL_GO(pBindingLog->Log(bindBehavior.GetUnicode())); - } - - Exit: - return hr; - } - HRESULT LogAssemblyNameWhereRef(ApplicationContext *pApplicationContext, Assembly *pAssembly) { @@ -369,28 +329,6 @@ namespace BINDER_SPACE Exit: return hr; } - - HRESULT LogPathAttempt(ApplicationContext *pApplicationContext, - PathString &assemblyPath) - { - HRESULT hr = S_OK; - BindingLog *pBindingLog = pApplicationContext->GetBindingLog(); - - if (pBindingLog->CanLog()) - { - PathString tmp; - PathString info; - - IF_FAIL_GO(tmp.LoadResourceAndReturnHR(CCompRC::Debugging, - ID_FUSLOG_BINDING_LOG_PATH_ATTEMPT)); - info.Printf(tmp.GetUnicode(), assemblyPath.GetUnicode()); - - IF_FAIL_GO(pBindingLog->Log(info)); - } - - Exit: - return hr; - } #endif // FEATURE_VERSIONING_LOG #ifndef CROSSGEN_COMPILE diff --git a/src/coreclr/src/binder/binderinterface.cpp b/src/coreclr/src/binder/binderinterface.cpp deleted file mode 100644 index 4e5f9b42b39..00000000000 --- a/src/coreclr/src/binder/binderinterface.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// ============================================================ -// -// BinderInterface.cpp -// - - -// -// Implements the public AssemblyBinder interface -// -// ============================================================ - -#include "assemblybinder.hpp" -#include "assemblyname.hpp" -#include "applicationcontext.hpp" -#include "binderinterface.hpp" -#include "bindresult.inl" -#include "utils.hpp" - -#include "ex.h" - -using namespace BINDER_SPACE; - -namespace BinderInterface -{ - - HRESULT Init() - { - HRESULT hr = S_OK; - - EX_TRY - { - hr = AssemblyBinder::Startup(); - } - EX_CATCH_HRESULT(hr); - - return hr; - } - - HRESULT SetupContext(LPCWSTR wszApplicationBase, - DWORD dwAppDomainId, - IUnknown **ppIApplicationContext) - { - HRESULT hr = S_OK; - - EX_TRY - { - BINDER_LOG_LOCK(); - BINDER_LOG_ENTER(L"BinderInterface::SetupContext"); - - // Verify input arguments - IF_FALSE_GO(ppIApplicationContext != NULL); - - { - ReleaseHolder pApplicationContext; - - SAFE_NEW(pApplicationContext, ApplicationContext); - IF_FAIL_GO(pApplicationContext->Init()); - pApplicationContext->SetAppDomainId(dwAppDomainId); - *ppIApplicationContext = static_cast(pApplicationContext.Extract()); - } - - Exit: - BINDER_LOG_LEAVE_HR(L"BinderInterface::SetupContext", hr); - } - EX_CATCH_HRESULT(hr); - - return hr; - } - - // See code:BINDER_SPACE::AssemblyBinder::GetAssembly for info on fNgenExplicitBind - // and fExplicitBindToNativeImage, and see code:CEECompileInfo::LoadAssemblyByPath - // for an example of how they're used. - HRESULT Bind(IUnknown *pIApplicationContext, - SString &assemblyDisplayName, - LPCWSTR wszCodeBase, - PEAssembly *pParentAssembly, - BOOL fNgenExplicitBind, - BOOL fExplicitBindToNativeImage, - BINDER_SPACE::Assembly **ppAssembly) - { - HRESULT hr = S_OK; - - EX_TRY - { - BINDER_LOG_LOCK(); - BINDER_LOG_ENTER(L"BinderInterface::Bind"); - - // Verify input arguments - IF_FALSE_GO(pIApplicationContext != NULL); - IF_FALSE_GO(ppAssembly != NULL); - - { - ApplicationContext *pApplicationContext = - static_cast(pIApplicationContext); - - ReleaseHolder pAssemblyName; - if (!assemblyDisplayName.IsEmpty()) - { - SAFE_NEW(pAssemblyName, AssemblyName); - IF_FAIL_GO(pAssemblyName->Init(assemblyDisplayName)); - } - - IF_FAIL_GO(AssemblyBinder::BindAssembly(pApplicationContext, - pAssemblyName, - wszCodeBase, - pParentAssembly, - fNgenExplicitBind, - fExplicitBindToNativeImage, - false, // excludeAppPaths - ppAssembly)); - } - - Exit: - BINDER_LOG_LEAVE_HR(L"BinderInterface::Bind", hr); - } - EX_CATCH_HRESULT(hr); - - return hr; - } - - HRESULT BindToSystem(SString &sSystemDirectory, - BINDER_SPACE::Assembly **ppSystemAssembly, - bool fBindToNativeImage) - { - HRESULT hr = S_OK; - - IF_FALSE_GO(ppSystemAssembly != NULL); - - EX_TRY - { - BINDER_LOG_LOCK(); - - IF_FAIL_GO(AssemblyBinder::BindToSystem(sSystemDirectory, ppSystemAssembly, fBindToNativeImage)); - } - EX_CATCH_HRESULT(hr); - - Exit: - return hr; - } - - HRESULT SetupBindingPaths(IUnknown *pIApplicationContext, - SString &sTrustedPlatformAssemblies, - SString &sPlatformResourceRoots, - SString &sAppPaths, - SString &sAppNiPaths) - { - HRESULT hr = S_OK; - - EX_TRY - { - BINDER_LOG_LOCK(); - BINDER_LOG_ENTER(L"BinderInterface::SetupBindingPaths"); - - // Verify input arguments - IF_FALSE_GO(pIApplicationContext != NULL); - - { - ApplicationContext *pApplicationContext = - static_cast(pIApplicationContext); - _ASSERTE(pApplicationContext != NULL); - - IF_FAIL_GO(pApplicationContext->SetupBindingPaths(sTrustedPlatformAssemblies, sPlatformResourceRoots, sAppPaths, sAppNiPaths, TRUE /* fAcquireLock */)); - } - - Exit: - BINDER_LOG_LEAVE_HR(L"BinderInterface::SetupBindingPaths", hr); - } - EX_CATCH_HRESULT(hr); - - return hr; - } - -#ifdef BINDER_DEBUG_LOG - HRESULT Log(LPCWSTR wszMessage) - { - HRESULT hr = S_OK; - - EX_TRY - { - BINDER_LOG_LOCK(); - BINDER_LOG((WCHAR *) wszMessage); - } - EX_CATCH_HRESULT(hr); - - return hr; - } -#endif // BINDER_DEBUG_LOG -}; diff --git a/src/coreclr/src/binder/fusionassemblyname.cpp b/src/coreclr/src/binder/fusionassemblyname.cpp index eafc5a7fe25..28832beb6a3 100644 --- a/src/coreclr/src/binder/fusionassemblyname.cpp +++ b/src/coreclr/src/binder/fusionassemblyname.cpp @@ -19,7 +19,6 @@ #include #include "shlwapi.h" -#include "binderinterface.hpp" #include "assemblyidentity.hpp" #include "textualidentityparser.hpp" diff --git a/src/coreclr/src/binder/inc/assembly.hpp b/src/coreclr/src/binder/inc/assembly.hpp index 8846913059e..9d189bc8ab8 100644 --- a/src/coreclr/src/binder/inc/assembly.hpp +++ b/src/coreclr/src/binder/inc/assembly.hpp @@ -148,17 +148,11 @@ namespace BINDER_SPACE inline IMDInternalImport *GetMDImport(); inline void SetMDImport(IMDInternalImport *pMDImport); - inline mdAssembly *GetAssemblyRefTokens(); - - inline DWORD GetNbAssemblyRefTokens(); - inline void SetNbAsssemblyRefTokens(DWORD dwCAssemblyRefTokens); LONG m_cRef; PEImage *m_pPEImage; PEImage *m_pNativePEImage; IMDInternalImport *m_pMDImport; - mdAssembly *m_pAssemblyRefTokens; - DWORD m_dwCAssemblyRefTokens; AssemblyName *m_pAssemblyName; SString m_assemblyPath; DWORD m_dwAssemblyFlags; diff --git a/src/coreclr/src/binder/inc/assembly.inl b/src/coreclr/src/binder/inc/assembly.inl index 7d7fab80285..2a3646a7cdb 100644 --- a/src/coreclr/src/binder/inc/assembly.inl +++ b/src/coreclr/src/binder/inc/assembly.inl @@ -169,21 +169,6 @@ void Assembly::SetMDImport(IMDInternalImport *pMDImport) m_pMDImport->AddRef(); } -mdAssembly *Assembly::GetAssemblyRefTokens() -{ - return m_pAssemblyRefTokens; -} - -DWORD Assembly::GetNbAssemblyRefTokens() -{ - return m_dwCAssemblyRefTokens; -} - -void Assembly::SetNbAsssemblyRefTokens(DWORD dwCAssemblyRefTokens) -{ - m_dwCAssemblyRefTokens = dwCAssemblyRefTokens; -} - BINDER_SPACE::Assembly* GetAssemblyFromPrivAssemblyFast(ICLRPrivAssembly *pPrivAssembly) { #ifdef _DEBUG diff --git a/src/coreclr/src/binder/inc/binderinterface.hpp b/src/coreclr/src/binder/inc/binderinterface.hpp deleted file mode 100644 index a9f0c210ff6..00000000000 --- a/src/coreclr/src/binder/inc/binderinterface.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// ============================================================ -// -// BinderInterface.hpp -// - - -// -// Defines the public AssemblyBinder interface -// -// ============================================================ - -#ifndef __BINDER_INTERFACE_HPP__ -#define __BINDER_INTERFACE_HPP__ - -class PEImage; -class PEAssembly; -class StringArrayList; - -namespace BINDER_SPACE -{ - class Assembly; - class AssemblyIdentityUTF8; -}; - -namespace BinderInterface -{ - HRESULT Init(); - - HRESULT SetupContext(/* in */ LPCWSTR wszApplicationBase, - /* in */ DWORD dwAppDomainId, - /* out */ IUnknown **ppIApplicationContext); - - // See code:BINDER_SPACE::AssemblyBinder::GetAssembly for info on fNgenExplicitBind - // and fExplicitBindToNativeImage, and see code:CEECompileInfo::LoadAssemblyByPath - // for an example of how they're used. - HRESULT Bind(/* in */ IUnknown *pIApplicationContext, - /* in */ SString &assemblyDisplayName, - /* in */ LPCWSTR wszCodeBase, - /* in */ PEAssembly *pParentAssembly, - /* in */ BOOL fNgenExplicitBind, - /* in */ BOOL fExplicitBindToNativeImage, - /*out */ BINDER_SPACE::Assembly **ppAssembly); - - // - // Called via managed AppDomain.ExecuteAssembly variants and during binding host setup - // - HRESULT SetupBindingPaths(/* in */ IUnknown *pIApplicationContext, - /* in */ SString &sTrustedPlatformAssemblies, - /* in */ SString &sPlatformResourceRoots, - /* in */ SString &sAppPaths, - /* in */ SString &sAppNiPaths); - - // - // Called via CoreAssemblySpec::BindToSystem - // - HRESULT BindToSystem(/* in */ SString &sSystemDirectory, - /* out */ BINDER_SPACE::Assembly **ppSystemAssembly, - /* in */ bool fBindToNativeImage); - -#ifdef BINDER_DEBUG_LOG - HRESULT Log(/* in */ LPCWSTR wszMessage); -#endif // BINDER_DEBUG_LOG - -}; - -#endif diff --git a/src/coreclr/src/vm/appdomain.cpp b/src/coreclr/src/vm/appdomain.cpp index bf09db50583..b89aab96a9c 100644 --- a/src/coreclr/src/vm/appdomain.cpp +++ b/src/coreclr/src/vm/appdomain.cpp @@ -2239,36 +2239,6 @@ void SystemDomain::SetThreadAptState (Thread::ApartmentState state) } #endif // defined(FEATURE_COMINTEROP_APARTMENT_SUPPORT) && !defined(CROSSGEN_COMPILE) -// Helper function to load an assembly. This is called from LoadCOMClass. -/* static */ - -Assembly *AppDomain::LoadAssemblyHelper(LPCWSTR wszAssembly, - LPCWSTR wszCodeBase) -{ - CONTRACT(Assembly *) - { - THROWS; - POSTCONDITION(CheckPointer(RETVAL)); - PRECONDITION(wszAssembly || wszCodeBase); - INJECT_FAULT(COMPlusThrowOM();); - } - CONTRACT_END; - - AssemblySpec spec; - if(wszAssembly) { - #define MAKE_TRANSLATIONFAILED { ThrowOutOfMemory(); } - MAKE_UTF8PTR_FROMWIDE(szAssembly,wszAssembly); - #undef MAKE_TRANSLATIONFAILED - - IfFailThrow(spec.Init(szAssembly)); - } - - if (wszCodeBase) { - spec.SetCodeBase(wszCodeBase); - } - RETURN spec.LoadAssembly(FILE_LOADED); -} - #if defined(FEATURE_CLASSIC_COMINTEROP) && !defined(CROSSGEN_COMPILE) MethodTable *AppDomain::LoadCOMClass(GUID clsid, diff --git a/src/coreclr/src/vm/appdomain.hpp b/src/coreclr/src/vm/appdomain.hpp index dd009ba253b..1e5ee8d90c0 100644 --- a/src/coreclr/src/vm/appdomain.hpp +++ b/src/coreclr/src/vm/appdomain.hpp @@ -2038,9 +2038,6 @@ public: void TryIncrementalLoad(DomainFile *pFile, FileLoadLevel workLevel, FileLoadLockHolder &lockHolder); - Assembly *LoadAssemblyHelper(LPCWSTR wszAssembly, - LPCWSTR wszCodeBase); - #ifndef DACCESS_COMPILE // needs AssemblySpec void GetCacheAssemblyList(SetSHash& assemblyList); @@ -2118,29 +2115,6 @@ public: PEAssembly *TryResolveAssembly(AssemblySpec *pSpec); - // Store a successful binding into the cache. This will keep the file from - // being physically unmapped, as well as shortcutting future attempts to bind - // the same spec throught the Cached entry point. - // - // Right now we only cache assembly binds for "probing" type - // binding situations, basically when loading domain neutral assemblies or - // zap files. - // - // @todo: We may want to be more aggressive about this if - // there are other situations where we are repeatedly binding the - // same assembly specs, though. - // - // Returns TRUE if stored - // FALSE if it's a duplicate (caller should clean up args) - BOOL StoreBindAssemblySpecResult(AssemblySpec *pSpec, - PEAssembly *pFile, - BOOL clone = TRUE); - - BOOL StoreBindAssemblySpecError(AssemblySpec *pSpec, - HRESULT hr, - OBJECTREF *pThrowable, - BOOL clone = TRUE); - //**************************************************************************************** // //**************************************************************************************** -- 2.34.1