-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More cleanups in Assembly/Loader/Binder area #58462
Conversation
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue Details
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
…extBinder -> FallbackBinder, etc ...
src/coreclr/vm/appdomain.cpp
Outdated
hrBindResult = bindResult.GetHRBindResult(); | ||
|
||
if (bindResult.Found()) | ||
if (bindResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would rename the local variable to something like boundAssembly
- basically include the word "Assembly" in it. It feels weird to read the code below and use a "result" as an assembly. (Not that it was better before, it was even worse)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I actually thought that boundAssembly
could be a better name here.
I think I will make another pass over variables typed as AssemblyBinder*
. We have a variety of [ load | context | binder ] combinations when naming these. Perhaps calling them binder
or pBinder
, in majority of cases at least, would make it more consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good modulo the bug.
src/coreclr/vm/assembly.cpp
Outdated
{ | ||
pAssemblyLoaderAllocator->EnsureReference(pBinderAssemblyLoaderAllocator); | ||
pAssemblyLoaderAllocator->EnsureReference(pAssemblyLoaderAllocator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is a bug. The pBinderAssemblyLoaderAllocator needs to stay or to be renamed to something else than pAssemblyLoaderAllocator. The motivation for the name was that it is the loader allocator that came from the binder and we need to distinguish it from the other one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, right, thee are two of them here. Thanks!
@@ -30,6 +30,11 @@ class DefaultAssemblyBinder final : public AssemblyLoadContext | |||
return NULL; | |||
} | |||
|
|||
bool IsDefault() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this to be marked as virtual (or override) to make it obvious that it is an override of the base method. The same at the other places.
src/coreclr/vm/assemblynative.cpp
Outdated
|
||
if (assemblyLoadContext.Get() != NULL) | ||
{ | ||
INT_PTR nativeAssemblyLoadContext = ((ASSEMBLYLOADCONTEXTREF)assemblyLoadContext.Get())->GetNativeAssemblyLoadContext(); | ||
pBinderContext = reinterpret_cast<AssemblyBinder*>(nativeAssemblyLoadContext); | ||
INT_PTR nativeAssemblyLoadContext = ((ASSEMBLYLOADCONTEXTREF)assemblyLoadContext.Get())->GetNativeAssemblyBinder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit - maybe rename the local to nativeAssemblyBinder or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, nativeAssemblyBinder will be better.
Thanks!!! |
AssemblyLoadContext
into its baseAssemblyBinder
Now
DefaultAssemblyBinder
andCustomAssemblyBinder
derive directly fromAssemblyBinder
TPABinderContext -> DefaultBinder, FallbackLoadContextBinder -> FallbackBinder, etc ...
CoreBindResult
and everything undersrc/coreclr/vm/coreclr
folderThe type is basically a tuple of
BINDER_SPACE::Assembly
andHRESULT
andHRESULT
is used in a single place right after it is set. The rest is COM support, ref-counting, holder, init/reset/delete, and other plumbing. We can just useAssembly
directly.