Skip to content
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

Merged
merged 11 commits into from
Sep 8, 2021
Merged

Conversation

VSadov
Copy link
Member

@VSadov VSadov commented Aug 31, 2021

  • fold the native AssemblyLoadContext into its base AssemblyBinder
    Now DefaultAssemblyBinder and CustomAssemblyBinder derive directly from AssemblyBinder
  • rename: NativeAssemblyLoadContext -> NativeAssemblyBinder
  • misc. renames:
    TPABinderContext -> DefaultBinder, FallbackLoadContextBinder -> FallbackBinder, etc ...
  • remove CoreBindResult and everything under src/coreclr/vm/coreclr folder
    The type is basically a tuple of BINDER_SPACE::Assembly and HRESULT and HRESULT 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 use Assembly directly.

@ghost
Copy link

ghost commented Aug 31, 2021

Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov
See info in area-owners.md if you want to be subscribed.

Issue Details
  • fold the native AssemblyLoadContext into its base AssemblyBinder
    Now DefaultAssemblyBinder and CustomAssemblyBinder derive directly from AssemblyBinder
Author: VSadov
Assignees: -
Labels:

area-AssemblyLoader-coreclr

Milestone: -

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@VSadov VSadov requested a review from janvorli September 1, 2021 16:42
hrBindResult = bindResult.GetHRBindResult();

if (bindResult.Found())
if (bindResult)
Copy link
Member

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)

Copy link
Member Author

@VSadov VSadov Sep 2, 2021

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.

Copy link
Member

@janvorli janvorli left a 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.

{
pAssemblyLoaderAllocator->EnsureReference(pBinderAssemblyLoaderAllocator);
pAssemblyLoaderAllocator->EnsureReference(pAssemblyLoaderAllocator);
Copy link
Member

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.

Copy link
Member Author

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()
Copy link
Member

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.


if (assemblyLoadContext.Get() != NULL)
{
INT_PTR nativeAssemblyLoadContext = ((ASSEMBLYLOADCONTEXTREF)assemblyLoadContext.Get())->GetNativeAssemblyLoadContext();
pBinderContext = reinterpret_cast<AssemblyBinder*>(nativeAssemblyLoadContext);
INT_PTR nativeAssemblyLoadContext = ((ASSEMBLYLOADCONTEXTREF)assemblyLoadContext.Get())->GetNativeAssemblyBinder();
Copy link
Member

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?

Copy link
Member Author

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.

@VSadov VSadov marked this pull request as ready for review September 8, 2021 18:15
@VSadov VSadov merged commit 74f238d into dotnet:main Sep 8, 2021
@VSadov VSadov deleted the aloader03 branch September 8, 2021 18:16
@VSadov
Copy link
Member Author

VSadov commented Sep 8, 2021

Thanks!!!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants