Skip to content

Commit

Permalink
Remove some unnecessary templating in assembly binder (#78441)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Nov 17, 2022
1 parent e2c0735 commit 48e43bf
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 123 deletions.
2 changes: 0 additions & 2 deletions src/coreclr/binder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ set(BINDER_COMMON_HEADERS
inc/defaultassemblybinder.h
inc/failurecache.hpp
inc/failurecachehashtraits.hpp
inc/loadcontext.hpp
inc/loadcontext.inl
inc/textualidentityparser.hpp
inc/utils.hpp
)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/binder/applicationcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// ============================================================

#include "applicationcontext.hpp"
#include "assemblyhashtraits.hpp"
#include "stringarraylist.h"
#include "loadcontext.hpp"
#include "failurecache.hpp"
#include "utils.hpp"
#include "ex.h"
Expand Down
15 changes: 13 additions & 2 deletions src/coreclr/binder/assemblybindercommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "assemblyname.hpp"
#include "assembly.hpp"
#include "applicationcontext.hpp"
#include "assemblyhashtraits.hpp"
#include "bindertracing.h"
#include "loadcontext.hpp"
#include "bindresult.inl"
#include "failurecache.hpp"
#include "utils.hpp"
Expand Down Expand Up @@ -1055,8 +1055,19 @@ namespace BINDER_SPACE
{
if (pContextEntry == NULL)
{
hr = S_OK; // FindInExecutionContext returns S_FALSE when not found - reset to S_OK
SAFE_NEW(pContextEntry, ContextEntry);

pContextEntry->SetIsInTPA(pBindResult->GetIsInTPA());
pContextEntry->SetAssemblyName(pBindResult->GetAssemblyName(), TRUE /* fAddRef */);
pContextEntry->SetAssembly(pBindResult->GetAssembly());
if (pBindResult->GetIsFirstRequest())
{
pContextEntry->SetIsFirstRequest(TRUE);
}

ExecutionContext *pExecutionContext = pApplicationContext->GetExecutionContext();
IF_FAIL_GO(pExecutionContext->Register(pBindResult));
pExecutionContext->Add(pContextEntry);
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/binder/inc/applicationcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ namespace BINDER_SPACE

typedef SHash<SimpleNameToFileNameMapTraits> SimpleNameToFileNameMap;

class AssemblyHashTraits;
typedef SHash<AssemblyHashTraits> ExecutionContext;

class ApplicationContext
{
public:
Expand Down
14 changes: 5 additions & 9 deletions src/coreclr/binder/inc/assemblyhashtraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,30 @@
#define __BINDER__ASSEMBLY_HASH_TRAITS_HPP__

#include "bindertypes.hpp"
#include "assemblyentry.hpp"
#include "contextentry.hpp"
#include "shash.h"

namespace BINDER_SPACE
{
template<typename HashEntry, DWORD dwAssemblyNameFlags>
class AssemblyHashTraits : public NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> >
class AssemblyHashTraits : public DeleteElementsOnDestructSHashTraits<NoRemoveSHashTraits<DefaultSHashTraits<ContextEntry*>>>
{
public:
typedef typename NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> >::element_t element_t;
typedef typename NoRemoveSHashTraits<DefaultSHashTraits<HashEntry> >::count_t count_t;

typedef AssemblyName* key_t;

// GetKey, Equals and Hash can throw due to SString
static const bool s_NoThrow = false;

static key_t GetKey(element_t pAssemblyEntry)
static key_t GetKey(const element_t& pAssemblyEntry)
{
return pAssemblyEntry->GetAssemblyName();
}
static BOOL Equals(key_t pAssemblyName1, key_t pAssemblyName2)
{
return pAssemblyName1->Equals(pAssemblyName2, dwAssemblyNameFlags);
return pAssemblyName1->Equals(pAssemblyName2, AssemblyName::INCLUDE_DEFAULT);
}
static count_t Hash(key_t pAssemblyName)
{
return pAssemblyName->Hash(dwAssemblyNameFlags);
return pAssemblyName->Hash(AssemblyName::INCLUDE_DEFAULT);
}
static element_t Null()
{
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/binder/inc/bindertypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace BINDER_SPACE
class Assembly;

class ContextEntry;
class ExecutionContext;

class ApplicationContext;

Expand Down
41 changes: 0 additions & 41 deletions src/coreclr/binder/inc/loadcontext.hpp

This file was deleted.

67 changes: 0 additions & 67 deletions src/coreclr/binder/inc/loadcontext.inl

This file was deleted.

0 comments on commit 48e43bf

Please sign in to comment.