Remove some unused code in binder (dotnet/coreclr#27095)
authorElinor Fung <47805090+elinor-fung@users.noreply.github.com>
Wed, 9 Oct 2019 02:47:43 +0000 (19:47 -0700)
committerJan Kotas <jkotas@microsoft.com>
Wed, 9 Oct 2019 02:47:43 +0000 (19:47 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/1ced1af44e3fc3c8e0ccca4b846b5e635ba0c3bc

src/coreclr/src/binder/CMakeLists.txt
src/coreclr/src/binder/assembly.cpp
src/coreclr/src/binder/assemblybinder.cpp
src/coreclr/src/binder/binderinterface.cpp [deleted file]
src/coreclr/src/binder/fusionassemblyname.cpp
src/coreclr/src/binder/inc/assembly.hpp
src/coreclr/src/binder/inc/assembly.inl
src/coreclr/src/binder/inc/binderinterface.hpp [deleted file]
src/coreclr/src/vm/appdomain.cpp
src/coreclr/src/vm/appdomain.hpp

index 46f46e32397d714498837f5ef1004cf6437cda5b..e17f5a707c73314d008be6f33f1005d6bcd6c6d9 100644 (file)
@@ -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
index 73b9c2688c40ce551b5b2f5bc0ed54c7a47a16a3..f5145b18d559280a45625993a90f0eee62a55840 100644 (file)
@@ -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<DWORD>(-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,
index e3f9b5165c9fcee806afad317ee024edbef52dd1..1fc1e70e8bb161268f85412eff6b6f3f1f0f3b39 100644 (file)
 #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 (file)
index 4e5f9b4..0000000
+++ /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<ApplicationContext> pApplicationContext;
-
-                SAFE_NEW(pApplicationContext, ApplicationContext);
-                IF_FAIL_GO(pApplicationContext->Init());
-                pApplicationContext->SetAppDomainId(dwAppDomainId);
-                *ppIApplicationContext = static_cast<IUnknown *>(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<ApplicationContext *>(pIApplicationContext);
-
-                ReleaseHolder<AssemblyName> 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<ApplicationContext *>(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
-};
index eafc5a7fe25eb647b251a4ea232edf4a5422a9ca..28832beb6a37630b911d945886007a725d116bb0 100644 (file)
@@ -19,7 +19,6 @@
 #include <strsafe.h>
 #include "shlwapi.h"
 
-#include "binderinterface.hpp"
 #include "assemblyidentity.hpp"
 #include "textualidentityparser.hpp"
 
index 8846913059ea899bc63f3425fb7582b41b4c76b2..9d189bc8ab84ea329f26e3b2cffee11efeb8917f 100644 (file)
@@ -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;
index 7d7fab80285642e97a41f916e5ab3ef178cabf0f..2a3646a7cdb3ec998f8a32c95d8c28d5ecaae6b0 100644 (file)
@@ -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 (file)
index a9f0c21..0000000
+++ /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
index bf09db505831a36ce27731b6011536f9cb57b169..b89aab96a9cfa46737e040d58b9651a9434e74a9 100644 (file)
@@ -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,
index dd009ba253b3bcc8ca1af0e2d1c8ad488d2c3d89..1e5ee8d90c01d0b76b3dd8a30110c869bdec2eb1 100644 (file)
@@ -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<PTR_DomainAssembly>& 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>@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.</TODO>
-    //
-    // 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);
-
     //****************************************************************************************
     //
     //****************************************************************************************