Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <michals@microsoft.com>2016-01-06 22:37:18 +0300
committerMichal Strehovský <michals@microsoft.com>2016-01-06 22:37:18 +0300
commit3946235f6d032b3fe72325cd78fd01bf5f280f89 (patch)
tree29a74b17a1aa409f80e57f6e7e0b8e2b049de46a /src/System.Private.Reflection.Execution
parent3895869e8c55c50f59bea0ca0c12c3ab5f2227a8 (diff)
Get System.Private.Reflection.Execution building
* Project file changes to get the project building in CoreRT build environment * Replace a bunch of places where we were talking to the type loader with a NotImplementedException. These should be all non-essential code paths (generic virtual method support, generic types, MakeArrayType for multidimensional arrays, support for building templated DynamicInvoke methods, invoking virtual methods, reflection getting/setting static fields, RuntimeMethodHandle/RuntimeFieldHandle, MakePointerType) * `TypeLoaderDependencies.cs` contains a bunch of extra dependencies from the type loader, including a dumbed-down CanonicallyEquivalentEntryLocator.
Diffstat (limited to 'src/System.Private.Reflection.Execution')
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.GVMResolution.cs553
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs347
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/SignatureParsing.cs11
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/TypeLoaderDependencies.cs47
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs8
-rw-r--r--src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj68
6 files changed, 114 insertions, 920 deletions
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.GVMResolution.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.GVMResolution.cs
index 2524030b2..fb79abfdf 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.GVMResolution.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.GVMResolution.cs
@@ -1,558 +1,19 @@
-namespace Internal.Reflection.Execution
-{
- using global::System;
- using global::System.Runtime.InteropServices;
-
- using global::Internal.Runtime;
- using global::Internal.Runtime.Augments;
- using global::Internal.Runtime.CompilerServices;
- using global::Internal.Runtime.TypeLoader;
- using global::Internal.NativeFormat;
- using CanonicalFormKind = global::Internal.TypeSystem.CanonicalFormKind;
-
- using global::Internal.Reflection.Core.Execution;
-
- using Debug = System.Diagnostics.Debug;
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using System;
+using Internal.Reflection.Core.Execution;
+namespace Internal.Reflection.Execution
+{
//==========================================================================================================
// This file has all the GVM resolution related logic
//==========================================================================================================
internal sealed partial class ExecutionEnvironmentImplementation : ExecutionEnvironment
{
- #region Data Structures
- [StructLayout(LayoutKind.Sequential)]
- internal struct GVMInterfaceSlotEntry
- {
- [StructLayout(LayoutKind.Sequential)]
- internal struct ImplementingTypeDetails
- {
- public uint ImplementingTypeRva;
- public uint[] ImplementedInterfacesSignatures;
- public uint[] ImplementedInterfaceIds;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct GVMTargetSlotEntry
- {
- public MethodNameAndSignature TargetMethodNameAndSignature;
- public uint TargetTypeRva;
- public ImplementingTypeDetails[] ImplementingTypes;
- }
-
- public MethodNameAndSignature InterfaceMethodNameAndSignature;
- public uint InterfaceTypeRva;
- public GVMTargetSlotEntry[] GVMTargetSlots;
-
- internal unsafe static GVMInterfaceSlotEntry ReadEntry(ref uint* pBlob, NativeReader reader)
- {
- GVMInterfaceSlotEntry result = new GVMInterfaceSlotEntry();
-
- uint methodSignature = *pBlob; pBlob++;
- NativeParser parser = new NativeParser(reader, methodSignature);
- result.InterfaceMethodNameAndSignature = GetMethodNameAndSignatureFromNativeParser(parser);
-
- result.InterfaceTypeRva = *pBlob; pBlob++;
- int numTargetImplementations = (int)*pBlob; pBlob++;
- result.GVMTargetSlots = new GVMTargetSlotEntry[numTargetImplementations];
-
- for (int i = 0; i < numTargetImplementations; i++)
- {
- methodSignature = *pBlob; pBlob++;
- parser = new NativeParser(reader, methodSignature);
- result.GVMTargetSlots[i].TargetMethodNameAndSignature = GetMethodNameAndSignatureFromNativeParser(parser);
- result.GVMTargetSlots[i].TargetTypeRva = *pBlob; pBlob++;
- int numIfaceImpls = (int)*pBlob; pBlob++;
- result.GVMTargetSlots[i].ImplementingTypes = new ImplementingTypeDetails[numIfaceImpls];
-
- for (int j = 0; j < numIfaceImpls; j++)
- {
- result.GVMTargetSlots[i].ImplementingTypes[j].ImplementingTypeRva = *pBlob; pBlob++;
-
- int numIfaceSigs = (int)*pBlob; pBlob++;
- result.GVMTargetSlots[i].ImplementingTypes[j].ImplementedInterfacesSignatures = new uint[numIfaceSigs];
- for (int k = 0; k < numIfaceSigs; k++)
- {
- result.GVMTargetSlots[i].ImplementingTypes[j].ImplementedInterfacesSignatures[k] = *pBlob; pBlob++;
- }
-
- int numIfaceIds = (int)*pBlob; pBlob++;
- result.GVMTargetSlots[i].ImplementingTypes[j].ImplementedInterfaceIds = new uint[numIfaceIds];
- for (int k = 0; k < numIfaceIds; k++)
- {
- result.GVMTargetSlots[i].ImplementingTypes[j].ImplementedInterfaceIds[k] = *pBlob; pBlob++;
- }
- }
- }
-
- return result;
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct GVMTypeSlotEntry
- {
- [StructLayout(LayoutKind.Sequential)]
- internal struct TargetMethod
- {
- public uint ImplementingTypeRva;
- public TargetMethodInfo[] TargetMethods;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct TargetMethodInfo
- {
- public uint MethodPointer;
- public uint MethodSignature;
- public uint IsUniversalGenericTargetMethod;
- }
-
- public MethodNameAndSignature MethodNameAndSignature;
- public uint ContainingTypeRva;
- public TargetMethod[] TargetMethods;
-
- internal unsafe static GVMTypeSlotEntry ReadEntry(ref uint* pBlob, NativeReader reader)
- {
- GVMTypeSlotEntry result = new GVMTypeSlotEntry();
-
- uint methodSignature = *pBlob; pBlob++;
- NativeParser parser = new NativeParser(reader, methodSignature);
- result.MethodNameAndSignature = GetMethodNameAndSignatureFromNativeParser(parser);
-
- result.ContainingTypeRva = *pBlob; pBlob++;
- result.TargetMethods = new TargetMethod[*pBlob]; pBlob++;
-
- for (int i = 0; i < result.TargetMethods.Length; i++)
- {
- result.TargetMethods[i].ImplementingTypeRva = *pBlob; pBlob++;
- result.TargetMethods[i].TargetMethods = new TargetMethodInfo[*pBlob]; pBlob++;
-
- for (int j = 0; j < result.TargetMethods[i].TargetMethods.Length; j++)
- {
- result.TargetMethods[i].TargetMethods[j].MethodPointer = *pBlob; pBlob++;
- result.TargetMethods[i].TargetMethods[j].MethodSignature = *pBlob; pBlob++;
- result.TargetMethods[i].TargetMethods[j].IsUniversalGenericTargetMethod = *pBlob; pBlob++;
- }
- }
-
- return result;
- }
- }
- #endregion
-
- private static MethodNameAndSignature GetMethodNameAndSignatureFromNativeParser(NativeParser parser)
- {
- string methodName = parser.GetString();
-
- // Signatures are indirected to through a relative offset so that we don't have to parse them
- // when not comparing signatures (parsing them requires resolving types and is tremendously
- // expensive).
- NativeParser sigParser = parser.GetParserFromRelativeOffset();
- IntPtr methodSignature = sigParser.Reader.OffsetToAddress(sigParser.Offset);
-
- return new MethodNameAndSignature(methodName, methodSignature);
- }
-
- private unsafe bool CanTargetGVMShareCodeWithTemplateGVM(NativeReader reader, ref ExternalReferencesTable externalReferencesLookup, uint templateGVMSig, RuntimeTypeHandle targetMethodContainingType, RuntimeTypeHandle[] targetMethodInstantiation, CanonicalFormKind canonSearchStyle, out MethodNameAndSignature templateMethodNameAndSignature, out bool requiresDictionary)
- {
- requiresDictionary = false;
-
- // Parse the template GVM signature
-
- NativeParser parser = new NativeParser(reader, templateGVMSig);
-
- RuntimeTypeHandle templateMethodContainingType = externalReferencesLookup.GetRuntimeTypeHandleFromIndex(parser.GetUnsigned());
- IntPtr signatureAddress = parser.Reader.OffsetToAddress(parser.Offset);
- if(!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutSignature(ref signatureAddress, out templateMethodNameAndSignature))
- return false;
- uint offset = reader.AddressToOffset(signatureAddress);
- parser.Offset = offset;
-
- RuntimeTypeHandle[] templateMethodInstantiation = GetTypeSequence(ref externalReferencesLookup, ref parser);
-
-#if REFLECTION_EXECUTION_TRACE
- string methodInstStr = "";
- foreach (var arg in templateMethodInstantiation)
- methodInstStr += (methodInstStr == "" ? GetTypeNameDebug(arg) : "," + GetTypeNameDebug(arg));
- ReflectionExecutionLogger.WriteLine(" TEMPLATE GVM = " + GetTypeNameDebug(templateMethodContainingType) + "::Method(" + templateMethodNameAndSignature.Name + "<" + methodInstStr + ">");
-
- methodInstStr = "";
- foreach (var arg in targetMethodInstantiation)
- methodInstStr += (methodInstStr == "" ? GetTypeNameDebug(arg) : "," + GetTypeNameDebug(arg));
- ReflectionExecutionLogger.WriteLine(" TARGET GVM = " + GetTypeNameDebug(targetMethodContainingType) + "::Method(" + templateMethodNameAndSignature.Name + "<" + methodInstStr + ">");
-#endif
-
- CanonicallyEquivalentEntryLocator canonHelper = new CanonicallyEquivalentEntryLocator(templateMethodContainingType, canonSearchStyle);
- if (!canonHelper.IsCanonicallyEquivalent(targetMethodContainingType))
- return false;
-
- if (!TypeLoaderEnvironment.Instance.CanInstantiationsShareCode(templateMethodInstantiation, targetMethodInstantiation, canonSearchStyle))
- return false;
-
- if (canonSearchStyle == CanonicalFormKind.Universal)
- {
- requiresDictionary = true;
- }
- else
- {
- bool requiresDictFromType = canonHelper.ConversionToCanonFormIsAChange();
- bool requiresDictFromMethod = TypeLoaderEnvironment.Instance.ConversionToCanonFormIsAChange(templateMethodInstantiation, canonSearchStyle);
- requiresDictionary = requiresDictFromType || requiresDictFromMethod;
- }
-
- return true;
- }
-
- private unsafe bool FindMatchingInterfaceSlot(ref GVMInterfaceSlotEntry entry, byte* pNativeLayoutInfoBlobPtr, ref RuntimeTypeHandle declaringType, ref RuntimeTypeHandle[] genericArguments, ref MethodNameAndSignature methodNameAndSignature, IntPtr moduleHandle, RuntimeTypeHandle openTargetTypeHandle, RuntimeTypeHandle[] targetTypeInstantiation, bool variantDispatch)
- {
- for (int j = 0; j < entry.GVMTargetSlots.Length; j++)
- {
-#if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine(" => (" + entry.GVMTargetSlots[j].TargetMethodNameAndSignature.Name + ") on target type " + GetTypeNameDebug(RvaToRuntimeTypeHandle(moduleHandle, entry.GVMTargetSlots[j].TargetTypeRva)));
-#endif
-
- for (int k = 0; k < entry.GVMTargetSlots[j].ImplementingTypes.Length; k++)
- {
-#if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine(" TYPE = " + GetTypeNameDebug(RvaToRuntimeTypeHandle(moduleHandle, entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementingTypeRva)));
-#endif
-
- if (openTargetTypeHandle.Equals(RvaToRuntimeTypeHandle(moduleHandle, entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementingTypeRva)))
- {
-#if REFLECTION_EXECUTION_TRACE
- for (int l = 0; l < entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfacesSignatures.Length; l++)
- ReflectionExecutionLogger.WriteLine(" IFACE " + l + " signature context = " + entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfacesSignatures[l]);
-
- for (int l = 0; l < entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfaceIds.Length; l++)
- ReflectionExecutionLogger.WriteLine(" Impl IFACE #" + entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfaceIds[l]);
-#endif
-
- for (int l = 0; l < entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfaceIds.Length; l++)
- {
- uint currentIfaceId = entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfaceIds[l];
- Debug.Assert(currentIfaceId < entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfacesSignatures.Length);
- uint currentIfaceSig = entry.GVMTargetSlots[j].ImplementingTypes[k].ImplementedInterfacesSignatures[currentIfaceId];
-
- RuntimeTypeHandle currentIfaceTypeHandle = default(RuntimeTypeHandle);
- IntPtr currentIfaceSigPtr = (IntPtr)(pNativeLayoutInfoBlobPtr + currentIfaceSig);
- if (TypeLoaderEnvironment.Instance.GetTypeFromSignatureAndContext(currentIfaceSigPtr, targetTypeInstantiation, null, out currentIfaceTypeHandle, out currentIfaceSigPtr))
- {
- Debug.Assert(!currentIfaceTypeHandle.IsNull());
-
-#if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine("SOURCE INTERFACE = " + GetTypeNameDebug(declaringType));
- ReflectionExecutionLogger.WriteLine("TARGET INTERFACE = " + GetTypeNameDebug(currentIfaceTypeHandle));
-#endif
- if ((!variantDispatch && declaringType.Equals(currentIfaceTypeHandle)) ||
- (variantDispatch && RuntimeAugments.IsAssignableFrom(declaringType, currentIfaceTypeHandle)))
- {
- // We found the GVM slot target for the input interface GVM call, so let's update the interface GVM slot and return success to the caller
- declaringType = RvaToRuntimeTypeHandle(moduleHandle, entry.GVMTargetSlots[j].TargetTypeRva);
- methodNameAndSignature = entry.GVMTargetSlots[j].TargetMethodNameAndSignature;
- return true;
- }
- }
- }
- }
- }
- }
-
- return false;
- }
-
- private unsafe bool ResolveInterfaceGenericVirtualMethodSlot(RuntimeTypeHandle targetTypeHandle, ref RuntimeTypeHandle declaringType, ref RuntimeTypeHandle[] genericArguments, ref MethodNameAndSignature methodNameAndSignature)
- {
- // Get the open type definition of the containing type of the generic virtual method being resolved
- RuntimeTypeHandle openCallingTypeHandle;
- RuntimeTypeHandle[] callingTypeInstantiation;
- if (!TryGetOpenTypeDefinition(declaringType, out openCallingTypeHandle, out callingTypeInstantiation))
- return false;
-
- // Get the open type definition of the current type of the object instance on which the GVM is being resolved
- RuntimeTypeHandle openTargetTypeHandle;
- RuntimeTypeHandle[] targetTypeInstantiation;
- if (!TryGetOpenTypeDefinition(targetTypeHandle, out openTargetTypeHandle, out targetTypeInstantiation))
- return false;
-
- foreach (IntPtr moduleHandle in ModuleList.Enumerate(RuntimeAugments.GetModuleFromTypeHandle(openTargetTypeHandle)))
- {
- uint* pBlob;
- uint cbBlob;
- if (!RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.GenericVirtualMethodTable, new IntPtr(&pBlob), new IntPtr(&cbBlob)))
- {
- continue;
- }
-
- byte* pNativeLayoutInfoBlob;
- uint cbNativeLayoutInfoBlob;
- if (!RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.NativeLayoutInfo, new IntPtr(&pNativeLayoutInfoBlob), new IntPtr(&cbNativeLayoutInfoBlob)))
- {
- continue;
- }
-
- // Interfaces section size
- pBlob++;
-
- NativeReader reader = new NativeReader(pNativeLayoutInfoBlob, cbNativeLayoutInfoBlob);
-
- uint numIfaceSlots = *pBlob; pBlob++;
- for (int i = 0; i < numIfaceSlots; i++)
- {
- GVMInterfaceSlotEntry entry = GVMInterfaceSlotEntry.ReadEntry(ref pBlob, reader);
-
- #if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine("INTERFACE method call = (" + entry.InterfaceMethodNameAndSignature.Name + ") on interface " + GetTypeNameDebug(RvaToRuntimeTypeHandle(moduleHandle, entry.InterfaceTypeRva)));
- #endif
-
- if (entry.InterfaceMethodNameAndSignature.Equals(methodNameAndSignature) && openCallingTypeHandle.Equals(RvaToRuntimeTypeHandle(moduleHandle, entry.InterfaceTypeRva)))
- {
- // For each of the possible GVM slot targets for the current interface call, we will do the following:
- //
- // Step 1: Scan the types that currently provide implementations for the current GVM slot target, and look
- // for ones that match the target object's type.
- //
- // Step 2: For each type that we find in step #1, get a list of all the interfaces that the current GVM target
- // provides an implementation for
- //
- // Step 3: For each interface in the list in step #2, parse the signature of that interface, do the generic argument
- // substitution (in case of a generic interface), and check if this interface signature is assignable from the
- // calling interface signature (from the name and sig input). if there is an exact match based on
- // interface type, then we've found the right slot. Otherwise, re-scan the entry again and see if some interface
- // type is compatible with the initial slots interface by means of variance.
- // This is done by calling the TypeLoaderEnvironment helper function.
- //
- // Example:
- // public interface IFoo<out T, out U>
- // {
- // string M1<V>();
- // }
- // public class Foo1<T, U> : IFoo<T, U>, IFoo<Kvp<T, string>, U>
- // {
- // string IFoo<T, U>.M1<V>() { ... }
- // public virtual string M1<V>() { ... }
- // }
- // public class Foo2<T, U> : Foo1<object, U>, IFoo<U, T>
- // {
- // string IFoo<U, T>.M1<V>() { ... }
- // }
- //
- // GVM Table layout for IFoo<T, U>.M1<V>:
- // {
- // InterfaceMethodNameAndSignature = { "M1", SigOf(string M1) }
- // InterfaceTypeRva = IFoo<T, U>
- // GVMTargetSlots[] = {
- //
- // {
- // TargetMethodNameAndSignature = { "M1", SigOf(M1) }
- // TargetTypeRva = Foo1<T, U>
- // ImplementingTypes[] = {
- // ImplementingTypeRva = Foo1<T, U>
- // ImplementedInterfacesSignatures[] = { SigOf(IFoo<!0, !1>), SigOf(IFoo<Kvp<!0, string>, !1>) }
- // ImplementedInterfaceIds[] = { 0 }
- // }
- // },
- //
- // {
- // TargetMethodNameAndSignature = { "M1", SigOf(M1) }
- // TargetTypeRva = Foo1<T, U>
- // ImplementingTypes[] = {
- // ImplementingTypeRva = Foo1<T, U>
- // ImplementedInterfacesSignatures[] = { SigOf(IFoo<!0, !1>), SigOf(IFoo<Kvp<!0, string>, !1>) }
- // ImplementedInterfaceIds[] = { 1 }
- // }
- // },
- //
- // {
- // TargetMethodNameAndSignature = { "M1", SigOf(M1) }
- // TargetTypeRva = Foo2<T, U>
- // ImplementingTypes = {
- // ImplementingTypeRva = Foo2<T, U>
- // ImplementedInterfacesSignatures[] = { SigOf(IFoo<!1, !0>) }
- // ImplementedInterfaceIds[] = { 0 }
- // }
- // },
- // }
- // }
- //
-
- // Non-variant dispatch of a variant generic interface generic virtual method.
- if (FindMatchingInterfaceSlot(ref entry, pNativeLayoutInfoBlob, ref declaringType, ref genericArguments, ref methodNameAndSignature, moduleHandle, openTargetTypeHandle, targetTypeInstantiation, false))
- {
- return true;
- }
-
- // Variant dispatch of a variant generic interface generic virtual method.
- if (FindMatchingInterfaceSlot(ref entry, pNativeLayoutInfoBlob, ref declaringType, ref genericArguments, ref methodNameAndSignature, moduleHandle, openTargetTypeHandle, targetTypeInstantiation, true))
- {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- private unsafe bool ResolveGenericVirtualMethodTarget(RuntimeTypeHandle targetTypeHandle, RuntimeTypeHandle declaringType, RuntimeTypeHandle[] genericArguments, MethodNameAndSignature methodNameAndSignature, out IntPtr methodPointer, out IntPtr dictionaryPointer)
- {
- methodPointer = IntPtr.Zero;
- dictionaryPointer = IntPtr.Zero;
-
- // Get the open type definition of the containing type of the generic virtual method being resolved
- RuntimeTypeHandle openCallingTypeHandle;
- RuntimeTypeHandle[] callingTypeInstantiation;
- if (!TryGetOpenTypeDefinition(declaringType, out openCallingTypeHandle, out callingTypeInstantiation))
- return false;
-
- // Get the open type definition of the current type of the object instance on which the GVM is being resolved
- RuntimeTypeHandle openTargetTypeHandle;
- RuntimeTypeHandle[] targetTypeInstantiation;
- if (!TryGetOpenTypeDefinition(targetTypeHandle, out openTargetTypeHandle, out targetTypeInstantiation))
- return false;
-
- foreach (IntPtr moduleHandle in ModuleList.Enumerate(RuntimeAugments.GetModuleFromTypeHandle(openTargetTypeHandle)))
- {
- uint* pBlob;
- uint cbBlob;
- if (!RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.GenericVirtualMethodTable, new IntPtr(&pBlob), new IntPtr(&cbBlob)))
- {
- continue;
- }
-
- byte* pBlobStart = (byte*)pBlob;
- byte* pBlobEnd = (byte*)pBlob + cbBlob;
-
- NativeReader reader = GetNativeReaderForBlob(moduleHandle, ReflectionMapBlob.NativeLayoutInfo);
- ExternalReferencesTable externalReferencesLookup = new ExternalReferencesTable(moduleHandle, ReflectionMapBlob.NativeReferences);
-
- byte* pNativeLayoutInfoBlob;
- uint cbNativeLayoutInfoBlob;
- if (!RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.NativeLayoutInfo, new IntPtr(&pNativeLayoutInfoBlob), new IntPtr(&cbNativeLayoutInfoBlob)))
- {
- continue;
- }
-
- // Skip over the interfaces section in the GVM table
- uint ifaceSectionSize = *pBlob; pBlob++;
- pBlob = (uint*)(pBlobStart + ifaceSectionSize);
-
- while (pBlob < pBlobEnd)
- {
- GVMTypeSlotEntry entry = GVMTypeSlotEntry.ReadEntry(ref pBlob, reader);
-
- #if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine("TYPE GVM method call = (" + entry.MethodNameAndSignature.Name + ") on type " + GetTypeNameDebug(RvaToRuntimeTypeHandle(moduleHandle, entry.ContainingTypeRva)));
- for (int i = 0; i < entry.TargetMethods.Length; i++)
- ReflectionExecutionLogger.WriteLine(" => " + entry.TargetMethods[i].TargetMethods.Length + " TEMPLATES available on type " + GetTypeNameDebug(RvaToRuntimeTypeHandle(moduleHandle, entry.TargetMethods[i].ImplementingTypeRva)));
- #endif
-
- if (entry.MethodNameAndSignature.Equals(methodNameAndSignature) && openCallingTypeHandle.Equals(RvaToRuntimeTypeHandle(moduleHandle, entry.ContainingTypeRva)))
- {
- for (int i = 0; i < entry.TargetMethods.Length; i++)
- {
- if (openTargetTypeHandle.Equals(RvaToRuntimeTypeHandle(moduleHandle, entry.TargetMethods[i].ImplementingTypeRva)))
- {
- for (int canonSearchStyle = 0; canonSearchStyle < 2; canonSearchStyle++)
- {
- // Search for a non-universal match first
- CanonicalFormKind canonSearchRule = canonSearchStyle == 0 ? CanonicalFormKind.Specific : CanonicalFormKind.Universal;
-
- // We have found the target GVM slot. Start scanning the different implementations of this method to find a match
- for (int j = 0; j < entry.TargetMethods[i].TargetMethods.Length; j++)
- {
- if ((canonSearchRule == CanonicalFormKind.Universal) != (entry.TargetMethods[i].TargetMethods[j].IsUniversalGenericTargetMethod == 1))
- continue;
-
- // Step 1: Check if the current template method can be shared with the target GVM we are trying to invoke
- bool requiresDictionary;
- MethodNameAndSignature templateMethodNameAndSignature;
- if (CanTargetGVMShareCodeWithTemplateGVM(reader, ref externalReferencesLookup, entry.TargetMethods[i].TargetMethods[j].MethodSignature, targetTypeHandle, genericArguments, canonSearchRule, out templateMethodNameAndSignature, out requiresDictionary))
- {
- dictionaryPointer = IntPtr.Zero;
- methodPointer = RvaToFunctionPointer(moduleHandle, entry.TargetMethods[i].TargetMethods[j].MethodPointer);
- // Universal canon methods always require a dictionary
- Debug.Assert(!(canonSearchRule == CanonicalFormKind.Universal) || requiresDictionary);
-
- if (requiresDictionary)
- {
- Debug.Assert(!string.IsNullOrEmpty(templateMethodNameAndSignature.Name));
-
- // Step 2: Get a method dictionary for this GVM
- if (!TypeLoaderEnvironment.Instance.TryGetGenericMethodDictionaryForComponents(targetTypeHandle, genericArguments, templateMethodNameAndSignature, out dictionaryPointer))
- {
- methodPointer = IntPtr.Zero;
-
- // We couldn't find/build a dictionary... we should fail at this point.
- // Maybe Debug.Assert(false) here??... we'll AV anyways when the code starts calling the NULL function pointer
- return false;
- }
- }
-
- if (canonSearchRule == CanonicalFormKind.Universal)
- {
- if (TypeLoaderEnvironment.Instance.MethodSignatureHasVarsNeedingCallingConventionConverter(templateMethodNameAndSignature.Signature))
- {
- RuntimeTypeHandle[] typeArgs = Array.Empty<RuntimeTypeHandle>();
-
- if (RuntimeAugments.IsGenericType(targetTypeHandle))
- {
- RuntimeTypeHandle openGenericType;
- bool success = TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeComponents(targetTypeHandle, out openGenericType, out typeArgs);
- Debug.Assert(success);
- }
-
- // Create a CallingConventionConverter to call the method correctly
- IntPtr thunkPtr = CallConverterThunk.MakeThunk(
- CallConverterThunk.ThunkKind.StandardToGenericInstantiating,
- methodPointer,
- templateMethodNameAndSignature.Signature,
- dictionaryPointer,
- typeArgs,
- genericArguments);
-
- methodPointer = thunkPtr;
- // Set dictionaryPointer to null so we don't make a fat function pointer around the whole thing.
- // TODO! add a new call converter thunk that will pass the instantiating arg through and use a fat function pointer.
- // should allow us to make fewer thunks.
- dictionaryPointer = IntPtr.Zero;
- }
- }
-
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
-
- return false;
- }
-
public sealed override unsafe bool TryGetGenericVirtualTargetForTypeAndSlot(RuntimeTypeHandle targetHandle, ref RuntimeTypeHandle declaringType, ref RuntimeTypeHandle[] genericArguments, ref string methodName, ref IntPtr methodSignature, out IntPtr methodPointer, out IntPtr dictionaryPointer, out bool slotUpdated)
{
- MethodNameAndSignature methodNameAndSignature = new MethodNameAndSignature(methodName, methodSignature);
-
-#if REFLECTION_EXECUTION_TRACE
- ReflectionExecutionLogger.WriteLine("GVM resolution starting for " + GetTypeNameDebug(declaringType) + ".Method(" + methodNameAndSignature.Name + ") on a target of type " + GetTypeNameDebug(targetHandle) + " ...");
-#endif
-
- if (RuntimeAugments.IsInterface(declaringType))
- {
- methodPointer = IntPtr.Zero;
- dictionaryPointer = IntPtr.Zero;
- slotUpdated = ResolveInterfaceGenericVirtualMethodSlot(targetHandle, ref declaringType, ref genericArguments, ref methodNameAndSignature);
- methodName = methodNameAndSignature.Name;
- methodSignature = methodNameAndSignature.Signature;
- return slotUpdated;
- }
- else
- {
- slotUpdated = false;
- return ResolveGenericVirtualMethodTarget(targetHandle, declaringType, genericArguments, methodNameAndSignature, out methodPointer, out dictionaryPointer);
- }
+ throw new NotImplementedException();
}
}
}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
index 3e9c0d7e0..51220bb5f 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
@@ -26,7 +26,6 @@ using CanonicalFormKind = global::Internal.TypeSystem.CanonicalFormKind;
using Debug = System.Diagnostics.Debug;
using TargetException = System.ArgumentException;
-using ThunkKind = Internal.Runtime.TypeLoader.CallConverterThunk.ThunkKind;
using Interlocked = System.Threading.Interlocked;
namespace Internal.Reflection.Execution
@@ -479,7 +478,7 @@ namespace Internal.Reflection.Execution
}
// Array not found in the ArrayMap blob: attempt to dynamically create a new one:
- return TypeLoaderEnvironment.Instance.TryGetArrayTypeForElementType(elementTypeHandle, out arrayTypeHandle);
+ throw new NotImplementedException();
}
//
@@ -519,7 +518,7 @@ namespace Internal.Reflection.Execution
// We can call directly into the type loader, bypassing the constraint validator because we know
// MDArrays have no constraints. This also prevents us from hitting a MissingMetadataException
// due to MDArray not being metadata enabled.
- return TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeForComponents(mdArrayTypeHandle, new RuntimeTypeHandle[] { elementTypeHandle }, out arrayTypeHandle);
+ throw new NotImplementedException();
}
//
@@ -561,7 +560,7 @@ namespace Internal.Reflection.Execution
//
public unsafe sealed override bool TryGetPointerTypeForTargetType(RuntimeTypeHandle targetTypeHandle, out RuntimeTypeHandle pointerTypeHandle)
{
- return TypeLoaderEnvironment.Instance.TryGetPointerTypeForTargetType(targetTypeHandle, out pointerTypeHandle);
+ throw new NotImplementedException();
}
//
@@ -586,7 +585,7 @@ namespace Internal.Reflection.Execution
//
public unsafe sealed override bool TryGetConstructedGenericTypeComponents(RuntimeTypeHandle runtimeTypeHandle, out RuntimeTypeHandle genericTypeDefinitionHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles)
{
- return TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeComponents(runtimeTypeHandle, out genericTypeDefinitionHandle, out genericTypeArgumentHandles);
+ throw new NotImplementedException();
}
//
@@ -600,7 +599,7 @@ namespace Internal.Reflection.Execution
//
public unsafe bool TryGetConstructedGenericTypeComponentsDiag(RuntimeTypeHandle runtimeTypeHandle, out RuntimeTypeHandle genericTypeDefinitionHandle, out RuntimeTypeHandle[] genericTypeArgumentHandles)
{
- return TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeComponents(runtimeTypeHandle, out genericTypeDefinitionHandle, out genericTypeArgumentHandles);
+ throw new NotImplementedException();
}
//
@@ -613,20 +612,7 @@ namespace Internal.Reflection.Execution
//
public unsafe sealed override bool TryGetConstructedGenericTypeForComponents(RuntimeTypeHandle genericTypeDefinitionHandle, RuntimeTypeHandle[] genericTypeArgumentHandles, out RuntimeTypeHandle runtimeTypeHandle)
{
- if (TypeLoaderEnvironment.Instance.TryLookupConstructedGenericTypeForComponents(genericTypeDefinitionHandle, genericTypeArgumentHandles, out runtimeTypeHandle))
- {
- return true;
- }
-
- TypeInfo typeDefinition = Type.GetTypeFromHandle(genericTypeDefinitionHandle).GetTypeInfo();
-
- TypeInfo[] typeArguments = new TypeInfo[genericTypeArgumentHandles.Length];
- for (int i = 0; i < genericTypeArgumentHandles.Length; i++)
- typeArguments[i] = Type.GetTypeFromHandle(genericTypeArgumentHandles[i]).GetTypeInfo();
-
- ConstraintValidator.EnsureSatisfiesClassConstraints(typeDefinition, typeArguments);
-
- return TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeForComponents(genericTypeDefinitionHandle, genericTypeArgumentHandles, out runtimeTypeHandle);
+ throw new NotImplementedException();
}
public sealed override MethodInvoker TryGetMethodInvoker(MetadataReader reader, RuntimeTypeHandle declaringTypeHandle, MethodHandle methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles)
@@ -696,36 +682,7 @@ namespace Internal.Reflection.Execution
{
if ((cookie & 1) == 1)
{
- // If the dynamic invoke method is a generic method, we need to consult the DynamicInvokeTemplateData table to locate
- // the matching template so that we can instantiate it. The DynamicInvokeTemplateData table starts with a single UINT
- // with the RVA of the type that hosts all DynamicInvoke methods. The table then follows with list of [Token, FunctionPointer]
- // pairs. The cookie parameter is an index into this table and points to a single pair.
- uint* pBlob;
- uint cbBlob;
- bool success = RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.DynamicInvokeTemplateData, (IntPtr)(&pBlob), (IntPtr)(&cbBlob));
- Debug.Assert(success && cbBlob > 4);
-
- byte* pNativeLayoutInfoBlob;
- uint cbNativeLayoutInfoBlob;
- success = RuntimeAugments.FindBlob(moduleHandle, (int)ReflectionMapBlob.NativeLayoutInfo, new IntPtr(&pNativeLayoutInfoBlob), new IntPtr(&cbNativeLayoutInfoBlob));
- Debug.Assert(success);
-
- // All methods referred from this blob are contained in the same type. The first UINT in the blob is the RVA of that EEType
- RuntimeTypeHandle declaringTypeHandle = RvaToRuntimeTypeHandle(moduleHandle, pBlob[0]);
-
- // The index points to two entries: the token of the dynamic invoke method and the function pointer to the canonical method
- // Now have the type loader build or locate a dictionary for this method
- uint index = cookie >> 1;
-
- MethodNameAndSignature nameAndSignature;
- IntPtr nameAndSigSignature = (IntPtr)(pNativeLayoutInfoBlob + pBlob[index]);
- success = TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutSignature(ref nameAndSigSignature, out nameAndSignature);
- Debug.Assert(success);
-
- success = TypeLoaderEnvironment.Instance.TryGetGenericMethodDictionaryForComponents(declaringTypeHandle, argHandles, nameAndSignature, out dynamicInvokeMethodGenericDictionary);
- Debug.Assert(success);
-
- dynamicInvokeMethod = RvaToFunctionPointer(moduleHandle, pBlob[index + 1]);
+ throw new NotImplementedException();
}
else
{
@@ -786,124 +743,7 @@ namespace Internal.Reflection.Execution
private IntPtr TryGetVirtualResolveData(IntPtr moduleHandle, RuntimeTypeHandle methodHandleDeclaringType, MethodHandle methodHandle, RuntimeTypeHandle[] genericArgs)
{
- NativeReader invokeMapReader = GetNativeReaderForBlob(moduleHandle, ReflectionMapBlob.VirtualInvokeMap);
- NativeParser invokeMapParser = new NativeParser(invokeMapReader, 0);
- NativeHashtable invokeHashtable = new NativeHashtable(invokeMapParser);
- ExternalReferencesTable externalReferences = new ExternalReferencesTable(moduleHandle, ReflectionMapBlob.CommonFixupsTable);
-
- RuntimeTypeHandle definitionType = GetTypeDefinition(methodHandleDeclaringType);
-
- MethodBase method = ReflectionCoreExecution.ExecutionDomain.GetMethod(definitionType, methodHandle, Array.Empty<RuntimeTypeHandle>());
-
- int hashcode = definitionType.GetHashCode();
-
- var lookup = invokeHashtable.Lookup(hashcode);
- NativeParser entryParser;
- while (!(entryParser = lookup.GetNext()).IsNull)
- {
- // Grammar of an entry in the hash table:
- // Virtual Method uses a normal slot
- // OpenType + NameAndSig metadata offset into the native layout metadata + (NumberOfStepsUpParentHierarchyToType << 1) + slot
- // OR
- // Generic Virtual Method
- // OpenType + NameAndSig metadata offset into the native layout metadata + (NumberOfStepsUpParentHierarchyToType << 1 + 1)
-
- RuntimeTypeHandle entryType = externalReferences.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
- if (!entryType.Equals(definitionType))
- continue;
-
- uint nameAndSigPointerToken = externalReferences.GetRvaFromIndex(entryParser.GetUnsigned());
-
- MethodNameAndSignature nameAndSig;
- if (!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutOffset(moduleHandle, nameAndSigPointerToken, out nameAndSig))
- {
- Debug.Assert(false);
- continue;
- }
-
- if (!IsMatchingMethodEntry(method, nameAndSig))
- continue;
-
- uint parentHierarchyAndFlag = entryParser.GetUnsigned();
- uint parentHierarchy = parentHierarchyAndFlag >> 1;
- RuntimeTypeHandle declaringTypeOfVirtualInvoke = methodHandleDeclaringType;
- for (uint iType = 0; iType < parentHierarchy; iType++)
- {
- if (!RuntimeAugments.TryGetBaseType(declaringTypeOfVirtualInvoke, out declaringTypeOfVirtualInvoke))
- {
- Debug.Assert(false); // This will only fail if the virtual invoke data is malformed as specifies that a type
- // has a deeper inheritance hierarchy than it actually does.
- return IntPtr.Zero;
- }
- }
-
- bool isGenericVirtualMethod = ((parentHierarchyAndFlag & VirtualInvokeTableEntry.FlagsMask) == VirtualInvokeTableEntry.GenericVirtualMethod);
-
- Debug.Assert(isGenericVirtualMethod == ((genericArgs != null) && genericArgs.Length > 0));
-
- if (isGenericVirtualMethod)
- {
- IntPtr methodName;
- IntPtr methodSignature;
-
- if (!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignaturePointersFromNativeLayoutSignature(moduleHandle, nameAndSigPointerToken, out methodName, out methodSignature))
- {
- Debug.Assert(false);
- return IntPtr.Zero;
- }
-
- RuntimeMethodHandle gvmSlot;
- if (!TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleForComponents(declaringTypeOfVirtualInvoke, methodName, methodSignature, genericArgs, out gvmSlot))
- {
- return IntPtr.Zero;
- }
-
- return (new OpenMethodResolver(declaringTypeOfVirtualInvoke, gvmSlot, methodHandle.AsInt())).ToIntPtr();
- }
- else
- {
- uint slot = entryParser.GetUnsigned();
-
- RuntimeTypeHandle searchForSharedGenericTypesInParentHierarchy = declaringTypeOfVirtualInvoke;
- while (!searchForSharedGenericTypesInParentHierarchy.IsNull())
- {
- // See if this type is shared generic. If so, adjust the slot by 1.
- if (RuntimeAugments.IsGenericType(searchForSharedGenericTypesInParentHierarchy))
- {
- if (RuntimeAugments.IsInterface(searchForSharedGenericTypesInParentHierarchy))
- {
- // Generic interfaces always have a dictionary slot in the vtable (see binder code in MdilModule::SaveMethodTable)
- // Interfaces do not have base types, so we can just break out of the loop here ...
- slot++;
- break;
- }
-
- RuntimeTypeHandle genericDefinition;
- RuntimeTypeHandle[] genericTypeArgs;
- bool success = TypeLoaderEnvironment.Instance.TryGetConstructedGenericTypeComponents(searchForSharedGenericTypesInParentHierarchy,
- out genericDefinition,
- out genericTypeArgs);
- if (TypeLoaderEnvironment.Instance.ConversionToCanonFormIsAChange(genericTypeArgs, CanonicalFormKind.Specific))
- {
- // Shared generic types have a slot dedicated to holding the generic dictionary.
- slot++;
- }
-
- Debug.Assert(success);
- }
-
- // Walk to parent
- if (!RuntimeAugments.TryGetBaseType(searchForSharedGenericTypesInParentHierarchy, out searchForSharedGenericTypesInParentHierarchy))
- {
- break;
- }
- }
-
-
- return (new OpenMethodResolver(declaringTypeOfVirtualInvoke, checked((ushort)slot), methodHandle.AsInt())).ToIntPtr();
- }
- }
- return IntPtr.Zero;
+ throw new NotImplementedException();
}
private unsafe MethodInvokeInfo TryGetDynamicMethodInvokeInfo(IntPtr mappingTableModule, RuntimeTypeHandle declaringTypeHandle, MethodHandle methodHandle, RuntimeTypeHandle[] genericMethodTypeArgumentHandles, CanonicalFormKind canonFormKind)
@@ -1133,9 +973,7 @@ namespace Internal.Reflection.Execution
{
if ((entryFlags & InvokeTableFlags.RequiresInstArg) != 0)
{
- MethodNameAndSignature dummyNameAndSignature;
- bool success = TypeLoaderEnvironment.Instance.TryGetGenericMethodComponents(instantiationArgument, out declaringTypeHandle, out dummyNameAndSignature, out genericMethodTypeArgumentHandles);
- Debug.Assert(success);
+ throw new NotImplementedException();
}
else
genericMethodTypeArgumentHandles = GetTypeSequence(ref externalReferences, ref entryParser);
@@ -1156,19 +994,7 @@ namespace Internal.Reflection.Execution
}
else
{
- uint nameAndSigOffset = externalReferences.GetRvaFromIndex(entryMethodHandleOrNameAndSigRaw);
- MethodNameAndSignature nameAndSig;
- if (!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutOffset(mappingTableModule, nameAndSigOffset, out nameAndSig))
- {
- Debug.Assert(false);
- continue;
- }
-
- if (!TryGetMetadataForTypeMethodNameAndSignature(declaringTypeHandle, nameAndSig, out methodHandle))
- {
- Debug.Assert(false);
- continue;
- }
+ throw new NotImplementedException();
}
return true;
@@ -1259,11 +1085,7 @@ namespace Internal.Reflection.Execution
if (canonFormKind == CanonicalFormKind.Universal)
{
- if (!TypeLoaderEnvironment.Instance.TryGetFieldOffset(declaringTypeHandle, (uint)cookieOrOffsetOrOrdinal, out fieldOffset))
- {
- Debug.Assert(false);
- return null;
- }
+ throw new NotImplementedException();
}
else
{
@@ -1283,10 +1105,7 @@ namespace Internal.Reflection.Execution
if (RuntimeAugments.IsGenericType(declaringTypeHandle))
{
- if (entryFlags.HasFlag(FieldTableFlags.IsGcSection))
- fieldAddress = *(IntPtr*)TypeLoaderEnvironment.Instance.TryGetGcStaticFieldData(declaringTypeHandle) + fieldOffset;
- else
- fieldAddress = *(IntPtr*)TypeLoaderEnvironment.Instance.TryGetNonGcStaticFieldData(declaringTypeHandle) + fieldOffset;
+ throw new NotImplementedException();
}
else
{
@@ -1371,12 +1190,7 @@ namespace Internal.Reflection.Execution
//
public unsafe sealed override bool TryGetMethodFromHandle(RuntimeMethodHandle runtimeMethodHandle, out RuntimeTypeHandle declaringTypeHandle, out MethodHandle methodHandle, out RuntimeTypeHandle[] genericMethodTypeArgumentHandles)
{
- MethodNameAndSignature nameAndSignature;
- methodHandle = default(MethodHandle);
- if (!TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleComponents(runtimeMethodHandle, out declaringTypeHandle, out nameAndSignature, out genericMethodTypeArgumentHandles))
- return false;
-
- return TryGetMetadataForTypeMethodNameAndSignature(declaringTypeHandle, nameAndSignature, out methodHandle);
+ throw new NotImplementedException();
}
//
@@ -1393,41 +1207,7 @@ namespace Internal.Reflection.Execution
//
public unsafe sealed override bool TryGetFieldFromHandle(RuntimeFieldHandle runtimeFieldHandle, out RuntimeTypeHandle declaringTypeHandle, out FieldHandle fieldHandle)
{
- declaringTypeHandle = default(RuntimeTypeHandle);
- fieldHandle = default(FieldHandle);
-
- string fieldName;
- if (!TypeLoaderEnvironment.Instance.TryGetRuntimeFieldHandleComponents(runtimeFieldHandle, out declaringTypeHandle, out fieldName))
- return false;
-
- MetadataReader reader;
- TypeDefinitionHandle typeDefinitionHandle;
- RuntimeTypeHandle metadataLookupTypeHandle = declaringTypeHandle;
-
- // For generic instantiations, get the declaring type def to do the metadata lookup with, as TryGetMetadataForNamedType expects
- // this as a pre-condition
- if (RuntimeAugments.IsGenericType(declaringTypeHandle))
- {
- RuntimeTypeHandle[] components;
- if (!TryGetConstructedGenericTypeComponents(declaringTypeHandle, out metadataLookupTypeHandle, out components))
- return false;
- }
-
- if (!TryGetMetadataForNamedType(metadataLookupTypeHandle, out reader, out typeDefinitionHandle))
- return false;
-
- TypeDefinition typeDefinition = typeDefinitionHandle.GetTypeDefinition(reader);
- foreach (FieldHandle fh in typeDefinition.Fields)
- {
- Field field = fh.GetField(reader);
- if (field.Name.StringEquals(fieldName, reader))
- {
- fieldHandle = fh;
- return true;
- }
- }
-
- return false;
+ throw new NotImplementedException();
}
//
@@ -1843,9 +1623,7 @@ namespace Internal.Reflection.Execution
if (needsCallingConventionConverter)
{
- if (!TypeLoaderEnvironment.Instance.TryComputeHasInstantiationDeterminedSize(type.TypeHandle, out needsCallingConventionConverter))
- Environment.FailFast("Unable to setup calling convention converter correctly");
- return needsCallingConventionConverter;
+ throw new NotImplementedException();
}
}
}
@@ -1859,6 +1637,10 @@ namespace Internal.Reflection.Execution
struct InvokeMapEntryDataEnumerator
{
+ // The field '_entryMethodInstantiation' is assigned but its value is never used
+ // The field '_nameAndSignature' is assigned but its value is never used
+ #pragma warning disable 414
+
// Read-only inputs
readonly private RuntimeTypeHandle _declaringTypeHandle;
readonly private RuntimeTypeHandle[] _genericMethodTypeArgumentHandles;
@@ -1884,7 +1666,8 @@ namespace Internal.Reflection.Execution
private bool _isMatchingMethodHandleAndDeclaringType;
private MethodNameAndSignature _nameAndSignature;
private RuntimeTypeHandle[] _entryMethodInstantiation;
-
+
+ #pragma warning restore 414
private MethodBase MethodInfoForDefinition
{
@@ -1961,19 +1744,7 @@ namespace Internal.Reflection.Execution
}
else
{
- uint nameAndSigToken = extRefTable.GetRvaFromIndex(entryParser.GetUnsigned());
- MethodNameAndSignature nameAndSig;
- if (!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutOffset(_moduleHandle, nameAndSigToken, out nameAndSig))
- {
- Debug.Assert(false);
- return;
- }
-
- if (nameAndSig.Name != MethodInfoForDefinition.Name)
- return;
-
- if (!CompareNativeLayoutMethodSignatureToMethodInfo(nameAndSig.Signature, MethodInfoForDefinition))
- return;
+ throw new NotImplementedException();
}
_entryType = extRefTable.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
@@ -1996,14 +1767,7 @@ namespace Internal.Reflection.Execution
if ((_flags & InvokeTableFlags.IsUniversalCanonicalEntry) != 0)
{
- Debug.Assert(_hasEntryPoint && ((_flags & InvokeTableFlags.RequiresInstArg) != 0));
-
- uint nameAndSigPointerToken = extRefTable.GetRvaFromIndex(entryParser.GetUnsigned());
- if (!TypeLoaderEnvironment.Instance.TryGetMethodNameAndSignatureFromNativeLayoutOffset(_moduleHandle, nameAndSigPointerToken, out _nameAndSignature))
- {
- Debug.Assert(false); //Error
- _isMatchingMethodHandleAndDeclaringType = false;
- }
+ throw new NotImplementedException();
}
else if (((_flags & InvokeTableFlags.RequiresInstArg) != 0) && _hasEntryPoint)
_entryDictionary = RvaToGenericDictionary(_moduleHandle, extRefTable.GetRvaFromIndex(entryParser.GetUnsigned()));
@@ -2032,8 +1796,7 @@ namespace Internal.Reflection.Execution
if (((_flags & InvokeTableFlags.RequiresInstArg) == 0) || !_hasEntryPoint)
return SequenceEqual(_genericMethodTypeArgumentHandles, _methodInstantiation);
- // Generic shareable method: check for canonical equivalency of the method instantiation arguments
- return GetNameAndSignatureAndMethodInstantiation() && TypeLoaderEnvironment.Instance.CanInstantiationsShareCode(_entryMethodInstantiation, _genericMethodTypeArgumentHandles, _canonFormKind);
+ throw new NotImplementedException();
}
public bool GetMethodEntryPoint(MetadataReader metadataReader, RuntimeTypeHandle declaringTypeHandle, out IntPtr methodEntrypoint, out IntPtr dictionaryComponent, out IntPtr rawMethodEntrypoint)
@@ -2068,20 +1831,7 @@ namespace Internal.Reflection.Execution
private bool GetDictionaryComponent(out IntPtr dictionaryComponent)
{
- dictionaryComponent = IntPtr.Zero;
-
- if (((_flags & InvokeTableFlags.RequiresInstArg) == 0) || !_hasEntryPoint)
- return true;
-
- // Dictionary for non-generic method is the type handle of the declaring type
- if ((_flags & InvokeTableFlags.IsGenericMethod) == 0)
- {
- dictionaryComponent = RuntimeAugments.GetPointerFromTypeHandle(_declaringTypeHandle);
- return true;
- }
-
- // Dictionary for generic method (either found statically or constructed dynamically)
- return GetNameAndSignatureAndMethodInstantiation() && TypeLoaderEnvironment.Instance.TryGetGenericMethodDictionaryForComponents(_declaringTypeHandle, _genericMethodTypeArgumentHandles, _nameAndSignature, out dictionaryComponent);
+ throw new NotImplementedException();
}
private bool GetMethodEntryPointComponent(IntPtr dictionaryComponent, out IntPtr methodEntrypoint)
@@ -2101,52 +1851,7 @@ namespace Internal.Reflection.Execution
private IntPtr GetCallingConventionConverterForMethodEntrypoint(MetadataReader metadataReader, RuntimeTypeHandle declaringType, IntPtr methodEntrypoint, IntPtr dictionary, MethodBase methodBase, MethodHandle mdHandle)
{
- MethodParametersInfo methodParamsInfo = new MethodParametersInfo(metadataReader, methodBase, mdHandle);
-
- bool[] forcedByRefParameters;
- if (methodParamsInfo.RequiresCallingConventionConverter(out forcedByRefParameters))
- {
- RuntimeTypeHandle[] parameterTypeHandles = methodParamsInfo.ReturnTypeAndParameterTypeHandles.ToArray();
- bool[] byRefParameters = methodParamsInfo.ReturnTypeAndParametersByRefFlags;
-
- Debug.Assert(parameterTypeHandles.Length == byRefParameters.Length && byRefParameters.Length == forcedByRefParameters.Length);
-
- bool isMethodOnStructure = RuntimeAugments.IsValueType(declaringType);
-
- return CallConverterThunk.MakeThunk(
- (methodBase.IsGenericMethod || isMethodOnStructure ? ThunkKind.StandardToGenericInstantiating : ThunkKind.StandardToGenericInstantiatingIfNotHasThis),
- methodEntrypoint,
- dictionary,
- !methodBase.IsStatic,
- parameterTypeHandles,
- byRefParameters,
- forcedByRefParameters);
- }
- else
- {
- return FunctionPointerOps.GetGenericMethodFunctionPointer(methodEntrypoint, dictionary);
- }
- }
-
- private bool GetNameAndSignatureAndMethodInstantiation()
- {
- if (_nameAndSignature != null)
- {
- Debug.Assert(((_flags & InvokeTableFlags.IsUniversalCanonicalEntry) != 0) || (_entryMethodInstantiation != null && _entryMethodInstantiation.Length > 0));
- return true;
- }
-
- if ((_flags & InvokeTableFlags.IsUniversalCanonicalEntry) != 0)
- {
- // _nameAndSignature should have been read from the InvokeMap entry directly!
- Debug.Assert(false, "Universal canonical entries do NOT have dictionary entries!");
- return false;
- }
-
- RuntimeTypeHandle dummy1;
- bool success = TypeLoaderEnvironment.Instance.TryGetGenericMethodComponents(_entryDictionary, out dummy1, out _nameAndSignature, out _entryMethodInstantiation);
- Debug.Assert(success && dummy1.Equals(_entryType) && _nameAndSignature != null && _entryMethodInstantiation != null && _entryMethodInstantiation.Length > 0);
- return success;
+ throw new NotImplementedException();
}
}
}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/SignatureParsing.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/SignatureParsing.cs
index 76cc9737a..40015d327 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/SignatureParsing.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/SignatureParsing.cs
@@ -13,16 +13,7 @@ namespace Internal.Reflection.Execution
{
public static RuntimeTypeHandle GetTypeFromNativeLayoutSignature(ref NativeParser parser, uint offset)
{
- IntPtr remainingSignature;
- RuntimeTypeHandle typeHandle;
-
- IntPtr signatureAddress = parser.Reader.OffsetToAddress(offset);
- bool success = TypeLoaderEnvironment.Instance.GetTypeFromSignatureAndContext(signatureAddress, null, null, out typeHandle, out remainingSignature);
-
- // Reset the parser to after the type
- parser = new NativeParser(parser.Reader, parser.Reader.AddressToOffset(remainingSignature));
-
- return typeHandle;
+ throw new NotImplementedException();
}
}
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/TypeLoaderDependencies.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/TypeLoaderDependencies.cs
new file mode 100644
index 000000000..49aed634b
--- /dev/null
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/TypeLoaderDependencies.cs
@@ -0,0 +1,47 @@
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using Internal.Reflection.Core.Execution;
+
+// This file contains System.Private.TypeLoader dependencies. Since we're not porting that for now,
+// we declare the dependencies here.
+
+namespace Internal.TypeSystem
+{
+ public enum CanonicalFormKind
+ {
+ Specific,
+ Universal,
+ }
+}
+
+namespace Internal.Runtime.TypeLoader
+{
+ using Internal.TypeSystem;
+
+ public struct CanonicallyEquivalentEntryLocator
+ {
+ RuntimeTypeHandle _typeToFind;
+
+ public CanonicallyEquivalentEntryLocator(RuntimeTypeHandle typeToFind, CanonicalFormKind kind)
+ {
+ _typeToFind = typeToFind;
+ }
+
+ public int LookupHashCode
+ {
+ get
+ {
+ return _typeToFind.GetHashCode();
+ }
+ }
+
+ public bool IsCanonicallyEquivalent(RuntimeTypeHandle other)
+ {
+ return _typeToFind.Equals(other);
+ }
+ }
+} \ No newline at end of file
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
index 87bf12ec3..737b94c70 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
@@ -53,13 +53,7 @@ namespace Internal.Reflection.Extensions.NonPortable
{
System.Diagnostics.Debug.Assert(resolver->ResolverType == OpenMethodResolver.GVMResolve);
- callTryGetMethod = false;
- methodHandle = resolver->Handle.AsMethodHandle();
-
- RuntimeTypeHandle declaringTypeHandleIgnored;
- MethodNameAndSignature nameAndSignatureIgnored;
- if (!TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleComponents(resolver->GVMMethodHandle, out declaringTypeHandleIgnored, out nameAndSignatureIgnored, out genericMethodTypeArgumentHandles))
- return null;
+ throw new NotImplementedException();
}
}
}
diff --git a/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj b/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
index d638f32bf..9129578a0 100644
--- a/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
+++ b/src/System.Private.Reflection.Execution/src/System.Private.Reflection.Execution.csproj
@@ -1,26 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
- <Import Project="..\dir.settings.targets" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>System.Private.Reflection.Execution</AssemblyName>
+ <AssemblyVersion>4.0.0.0</AssemblyVersion>
<OutputType>Library</OutputType>
<ProjectGuid>{306A4D48-0ACF-41C4-BBA0-BCDAD9253E2D}</ProjectGuid>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <IsProjectNLibrary>true</IsProjectNLibrary>
- <ShipWithProjectNToolset>true</ShipWithProjectNToolset>
- <ExcludeDefaultReferences>true</ExcludeDefaultReferences>
- <CoreRTProjectRelativePath>$(MSBuildThisFileDirectory)..\..\CoreRT\src</CoreRTProjectRelativePath>
-
- <DefineConstants Condition="'$(REFLECTION_EXECUTION_TRACE)' != ''">REFLECTION_EXECUTION_TRACE;$(DefineConstants)</DefineConstants>
- <DefineConstants Condition="'$(GENERICS_FORCE_USG)' != ''">GENERICS_FORCE_USG;$(DefineConstants)</DefineConstants>
-
- <!-- Disable warning MSB3270 -->
- <ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
- <!-- Setup the rigth references -->
+ <!-- Default configurations to help VS understand the options -->
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" />
+
+ <!-- Setup the right references -->
<ItemGroup>
- <ProjectReference Include="..\..\CoreRT\src\AotPackageReference\AotPackageReference.depproj">
+ <ProjectReference Include="..\..\AotPackageReference\AotPackageReference.depproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
@@ -35,22 +30,22 @@
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="$(CoreRTProjectRelativePath)\System.Private.CoreLib\src\System.Private.CoreLib.csproj" />
- <ProjectReference Include="$(CoreRTProjectRelativePath)\System.Private.Reflection\src\System.Private.Reflection.csproj" />
- <ProjectReference Include="$(CoreRTProjectRelativePath)\System.Private.Reflection.Core\src\System.Private.Reflection.Core.csproj" />
- <ProjectReference Include="$(CoreRTProjectRelativePath)\System.Private.Reflection.Metadata\src\System.Private.Reflection.Metadata.csproj" />
- <ProjectReference Include="..\System.Private.TypeLoader\System.Private.TypeLoader.csproj" />
- <ProjectReference Include="..\System.Private.Interop\System.Private.Interop.NetNative.csproj" />
+ <ProjectReference Include="..\..\System.Private.CoreLib\src\System.Private.CoreLib.csproj" />
+ <ProjectReference Include="..\..\System.Private.Reflection\src\System.Private.Reflection.csproj" />
+ <ProjectReference Include="..\..\System.Private.Reflection.Core\src\System.Private.Reflection.Core.csproj" />
+ <ProjectReference Include="..\..\System.Private.Reflection.Metadata\src\System.Private.Reflection.Metadata.csproj" />
+
+ <ProjectReference Include="..\..\System.Private.Interop\src\System.Private.Interop.csproj" />
</ItemGroup>
<PropertyGroup>
- <NativeFormatInternalAPIs>$(EnlistmentRootPath)InternalAPIs\PnToolChain\NativeFormat</NativeFormatInternalAPIs>
+ <NativeFormatCommonPath>..\..\Common\src\Internal\NativeFormat</NativeFormatCommonPath>
</PropertyGroup>
<ItemGroup>
- <Compile Include="$(NativeFormatInternalAPIs)\NativeFormat.cs" />
- <Compile Include="$(NativeFormatInternalAPIs)\NativeFormatReader.cs" />
- <Compile Include="$(NativeFormatInternalAPIs)\NativeFormatReader.Metadata.cs" />
- <Compile Include="$(NativeFormatInternalAPIs)\NativeFormatReader.String.cs" />
+ <Compile Include="$(NativeFormatCommonPath)\NativeFormat.cs" />
+ <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.cs" />
+ <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.Metadata.cs" />
+ <Compile Include="$(NativeFormatCommonPath)\NativeFormatReader.String.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="Internal\Reflection\Execution\TypeLoader\ConstraintValidator.cs" />
@@ -62,7 +57,7 @@
<Compile Include="Internal\Reflection\Execution\AssemblyBinderImplementation.cs" />
<Compile Include="Internal\Reflection\Execution\ReflectionDomainSetupImplementation.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.cs" />
- <Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.Interop.cs" />
+ <Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.Interop.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.Runtime.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.GVMResolution.cs" />
<Compile Include="Internal\Reflection\Execution\ExecutionEnvironmentImplementation.MappingTables.cs" />
@@ -101,18 +96,19 @@
<Compile Include="Internal\Reflection\Extensions\NonPortable\CustomAttributeInstantiator.cs" />
<Compile Include="Internal\Reflection\Extensions\NonPortable\DelegateMethodInfoRetriever.cs" />
<Compile Include="System\Reflection\MissingRuntimeArtifactException.cs" />
+ <Compile Include="Internal\Reflection\Execution\TypeLoaderDependencies.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Include="..\Common\Internal\Reflection\Execution\Binder\DefaultBinder.cs" />
- <Compile Include="..\Common\Internal\Runtime\MetadataBlob.cs" />
- <Compile Include="..\Common\System\CommonRuntimeTypes.cs" />
- <Compile Include="..\Common\System\NotImplemented.cs" />
- <Compile Include="..\Common\System\Collections\Generic\LowLevelList.cs" />
- <Compile Include="..\Common\System\Collections\Generic\LowLevelDictionary.cs" />
- <Compile Include="..\Common\System\Linq\LowLevelEnumerable.cs" />
- <Compile Include="..\Common\System\Collections\HashHelpers.cs" />
- <Compile Include="..\Common\System\Collections\Generic\Empty.cs" />
- <Compile Include="..\Common\System\Runtime\CompilerServices\DeveloperExperienceModeOnlyAttribute.cs" />
+ <Compile Include="..\..\Common\src\Internal\Reflection\Execution\Binder\DefaultBinder.cs" />
+ <Compile Include="..\..\Common\src\Internal\Runtime\MetadataBlob.cs" />
+ <Compile Include="..\..\Common\src\System\CommonRuntimeTypes.cs" />
+ <Compile Include="..\..\Common\src\System\NotImplemented.cs" />
+ <Compile Include="..\..\Common\src\System\Collections\Generic\LowLevelList.cs" />
+ <Compile Include="..\..\Common\src\System\Collections\Generic\LowLevelDictionary.cs" />
+ <Compile Include="..\..\Common\src\System\Linq\LowLevelEnumerable.cs" />
+ <Compile Include="..\..\Common\src\System\Collections\HashHelpers.cs" />
+ <Compile Include="..\..\Common\src\System\Collections\Generic\Empty.cs" />
+ <Compile Include="..\..\Common\src\System\Runtime\CompilerServices\DeveloperExperienceModeOnlyAttribute.cs" />
</ItemGroup>
- <Import Project="..\dir.targets" />
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>