Replace InternalLoadUnmanagedDllFromPath with NativeLibrary.Load (dotnet/coreclr...
authorRyan Lucia <rylucia@microsoft.com>
Tue, 8 Oct 2019 23:23:06 +0000 (19:23 -0400)
committerJan Kotas <jkotas@microsoft.com>
Tue, 8 Oct 2019 23:23:06 +0000 (16:23 -0700)
Both just call into NDirect::LoadLibraryFromPath, and so this simplifies the code by removing a superfluous QCall

Commit migrated from https://github.com/dotnet/coreclr/commit/b3efcae9f917f57417418f462c4244e0feade689

src/coreclr/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs
src/coreclr/src/vm/assemblynative.cpp
src/coreclr/src/vm/assemblynative.hpp
src/coreclr/src/vm/dllimport.cpp
src/coreclr/src/vm/ecalllist.h
src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs

index 0c35f1c..1735a9d 100644 (file)
@@ -79,9 +79,6 @@ namespace System.Runtime.Loader
         }
 #endif
 
-        [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
-        private static extern IntPtr InternalLoadUnmanagedDllFromPath(string unmanagedDllPath);
-
         // This method is invoked by the VM when using the host-provided assembly load context
         // implementation.
         private static IntPtr ResolveUnmanagedDll(string unmanagedDllName, IntPtr gchManagedAssemblyLoadContext)
index 9162bfd..08ead4c 100644 (file)
@@ -297,22 +297,6 @@ void QCALLTYPE AssemblyNative::LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext
     END_QCALL;
 }
 
-// static
-INT_PTR QCALLTYPE AssemblyNative::InternalLoadUnmanagedDllFromPath(LPCWSTR unmanagedLibraryPath)
-{
-    QCALL_CONTRACT;
-
-    NATIVE_LIBRARY_HANDLE moduleHandle = nullptr;
-
-    BEGIN_QCALL;
-
-    moduleHandle = NDirect::LoadLibraryFromPath(unmanagedLibraryPath, true);
-
-    END_QCALL;
-
-    return reinterpret_cast<INT_PTR>(moduleHandle);
-}
-
 /*static */
 void QCALLTYPE AssemblyNative::LoadFromStream(INT_PTR ptrNativeAssemblyLoadContext, INT_PTR ptrAssemblyArray, 
                                               INT32 cbAssemblyArrayLength, INT_PTR ptrSymbolArray, INT32 cbSymbolArrayLength, 
index 898f131..265f2f9 100644 (file)
@@ -120,7 +120,6 @@ public:
     static INT_PTR QCALLTYPE InitializeAssemblyLoadContext(INT_PTR ptrManagedAssemblyLoadContext, BOOL fRepresentsTPALoadContext, BOOL fIsCollectible);
     static void QCALLTYPE PrepareForAssemblyLoadContextRelease(INT_PTR ptrNativeAssemblyLoadContext, INT_PTR ptrManagedStrongAssemblyLoadContext);
     static void QCALLTYPE LoadFromPath(INT_PTR ptrNativeAssemblyLoadContext, LPCWSTR pwzILPath, LPCWSTR pwzNIPath, QCall::ObjectHandleOnStack retLoadedAssembly);
-    static INT_PTR QCALLTYPE InternalLoadUnmanagedDllFromPath(LPCWSTR unmanagedLibraryPath);
     static void QCALLTYPE LoadFromStream(INT_PTR ptrNativeAssemblyLoadContext, INT_PTR ptrAssemblyArray, INT32 cbAssemblyArrayLength, INT_PTR ptrSymbolArray, INT32 cbSymbolArrayLength, QCall::ObjectHandleOnStack retLoadedAssembly);
 #ifndef FEATURE_PAL
     static void QCALLTYPE LoadFromInMemoryModule(INT_PTR ptrNativeAssemblyLoadContext, INT_PTR hModule, QCall::ObjectHandleOnStack retLoadedAssembly);
index 17c7ff4..1ac4c4f 100644 (file)
@@ -5876,8 +5876,7 @@ private:
 };  // class LoadLibErrorTracker
 
 // Load the library directly. On Unix systems, don't register it yet with PAL. 
-// * External callers like AssemblyNative::InternalLoadUnmanagedDllFromPath() and the upcoming 
-//   System.Runtime.InteropServices.NativeLibrary.Load() need the raw system handle
+// * External callers like System.Runtime.InteropServices.NativeLibrary.Load() need the raw system handle
 // * Internal callers like LoadLibraryModule() can convert this handle to a HMODULE via PAL APIs on Unix
 static NATIVE_LIBRARY_HANDLE LocalLoadLibraryHelper( LPCWSTR name, DWORD flags, LoadLibErrorTracker *pErrorTracker )
 {
index 064f514..35b0a86 100644 (file)
@@ -509,7 +509,6 @@ FCFuncStart(gAssemblyLoadContextFuncs)
     QCFuncElement("InitializeAssemblyLoadContext", AssemblyNative::InitializeAssemblyLoadContext)
     QCFuncElement("PrepareForAssemblyLoadContextRelease", AssemblyNative::PrepareForAssemblyLoadContextRelease)
     QCFuncElement("LoadFromPath", AssemblyNative::LoadFromPath)
-    QCFuncElement("InternalLoadUnmanagedDllFromPath", AssemblyNative::InternalLoadUnmanagedDllFromPath)
     QCFuncElement("LoadFromStream", AssemblyNative::LoadFromStream)
 #ifdef FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION
     QCFuncElement("LoadTypeForWinRTTypeNameInContextInternal", AssemblyNative::LoadTypeForWinRTTypeNameInContext)
index 24805bf..c9d0c16 100644 (file)
@@ -397,7 +397,7 @@ namespace System.Runtime.Loader
                 throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(unmanagedDllPath));
             }
 
-            return InternalLoadUnmanagedDllFromPath(unmanagedDllPath);
+            return NativeLibrary.Load(unmanagedDllPath);
         }
 
         // Custom AssemblyLoadContext implementations can override this