Delete .NET Native leftovers from type loader (part 5 of X) (#79260)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Tue, 6 Dec 2022 08:22:33 +0000 (17:22 +0900)
committerGitHub <noreply@github.com>
Tue, 6 Dec 2022 08:22:33 +0000 (17:22 +0900)
20 files changed:
src/coreclr/nativeaot/System.Private.Reflection.Execution/src/Internal/Reflection/Execution/ExecutionEnvironmentImplementation.MappingTables.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/LowLevelStringConverter.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/NativeLayoutFieldDesc.cs [deleted file]
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/PermanentAllocatedMemoryBlobs.cs [deleted file]
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TemplateLocator.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeBuilder.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeBuilderState.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericMethodsLookup.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericTypesLookup.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.ConstructedGenericsRegistration.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.FieldAccess.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.Metadata.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.MethodAddress.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.NamedTypeLookup.cs [deleted file]
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.StaticsLookup.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderTypeSystemContext.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeSystemExtensions.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/TypeSystem/TypeSystemContext.Runtime.cs
src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj

index df058308a8f40548c29c8b1d0679a7274d5becaf..98b779a11fbf34781f5a208f0049a993c64f392e 100644 (file)
@@ -167,7 +167,7 @@ namespace Internal.Reflection.Execution
         /// <param name="runtimeTypeHandle">Runtime type handle (MethodTable) for the given type</param>
         public sealed override unsafe bool TryGetNamedTypeForMetadata(QTypeDefinition qTypeDefinition, out RuntimeTypeHandle runtimeTypeHandle)
         {
-            return TypeLoaderEnvironment.Instance.TryGetOrCreateNamedTypeForMetadata(qTypeDefinition, out runtimeTypeHandle);
+            return TypeLoaderEnvironment.Instance.TryGetNamedTypeForMetadata(qTypeDefinition, out runtimeTypeHandle);
         }
 
         /// <summary>
index 1bd1f93cce5849d6cb9b6245989520cb0851d691..f03ac5101a045564e39dc621d2e503d9f7dd50b8 100644 (file)
@@ -117,23 +117,8 @@ namespace Internal.Runtime.TypeLoader
         public static string LowLevelToString(this RuntimeTypeHandle rtth)
         {
             TypeReferenceHandle typeRefHandle;
-            QTypeDefinition qTypeDefinition;
             MetadataReader reader;
 
-            // Try to get the name from metadata
-            if (TypeLoaderEnvironment.Instance.TryGetMetadataForNamedType(rtth, out qTypeDefinition))
-            {
-#if ECMA_METADATA_SUPPORT
-                string result = EcmaMetadataFullName(qTypeDefinition);
-                if (result != null)
-                    return result;
-#endif
-
-                reader = qTypeDefinition.NativeFormatReader;
-                TypeDefinitionHandle typeDefHandle = qTypeDefinition.NativeFormatHandle;
-                return typeDefHandle.GetFullName(reader);
-            }
-
             // Try to get the name from diagnostic metadata
             if (TypeLoaderEnvironment.TryGetTypeReferenceForNamedType(rtth, out reader, out typeRefHandle))
             {
diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/NativeLayoutFieldDesc.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/NativeLayoutFieldDesc.cs
deleted file mode 100644 (file)
index b658f1d..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-using System;
-using Internal.TypeSystem;
-using Internal.NativeFormat;
-
-namespace Internal.Runtime.TypeLoader
-{
-    /// <summary>
-    /// Represents a field defined in native layout data, but without metadata
-    /// </summary>
-    internal class NativeLayoutFieldDesc : FieldDesc
-    {
-        private DefType _owningType;
-        private TypeDesc _fieldType;
-        private FieldStorage _fieldStorage;
-
-        public NativeLayoutFieldDesc(DefType owningType, TypeDesc fieldType, FieldStorage fieldStorage)
-        {
-            _owningType = owningType;
-            _fieldType = fieldType;
-            _fieldStorage = fieldStorage;
-        }
-
-        public override TypeSystemContext Context
-        {
-            get
-            {
-                return _owningType.Context;
-            }
-        }
-
-        public override TypeDesc FieldType
-        {
-            get
-            {
-                return _fieldType;
-            }
-        }
-
-        public override EmbeddedSignatureData[] GetEmbeddedSignatureData() => null;
-
-        public override bool HasRva
-        {
-            get
-            {
-                throw NotImplemented.ByDesign;
-            }
-        }
-
-        public override bool IsInitOnly
-        {
-            get
-            {
-                throw NotImplemented.ByDesign;
-            }
-        }
-
-        public override bool IsLiteral
-        {
-            get
-            {
-                return false;
-            }
-        }
-
-        public override bool IsStatic
-        {
-            get
-            {
-                return _fieldStorage != FieldStorage.Instance;
-            }
-        }
-
-        public override bool IsThreadStatic
-        {
-            get
-            {
-                return _fieldStorage == FieldStorage.TLSStatic;
-            }
-        }
-
-        internal FieldStorage FieldStorage
-        {
-            get
-            {
-                return _fieldStorage;
-            }
-        }
-
-        public override DefType OwningType
-        {
-            get
-            {
-                return _owningType;
-            }
-        }
-
-        public override bool HasCustomAttribute(string attributeNamespace, string attributeName)
-        {
-            throw NotImplemented.ByDesign;
-        }
-    }
-}
diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/PermanentAllocatedMemoryBlobs.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/PermanentAllocatedMemoryBlobs.cs
deleted file mode 100644 (file)
index b77d750..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-
-using System;
-using System.Runtime;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-using Internal.Runtime;
-using Internal.Runtime.Augments;
-
-using Internal.NativeFormat;
-
-namespace Internal.Runtime.TypeLoader
-{
-    public sealed partial class PermanentAllocatedMemoryBlobs
-    {
-        // Various functions in the type loader need to create permanent pointers for various purposes.
-
-        private static PermanentlyAllocatedMemoryRegions_Uint_In_IntPtr s_uintCellValues = new PermanentlyAllocatedMemoryRegions_Uint_In_IntPtr();
-        private static PermanentlyAllocatedMemoryRegions_IntPtr_In_IntPtr s_pointerIndirectionCellValues = new PermanentlyAllocatedMemoryRegions_IntPtr_In_IntPtr();
-
-        private class PermanentlyAllocatedMemoryRegions_Uint_In_IntPtr
-        {
-            private LowLevelDictionary<uint, IntPtr> _allocatedBlocks = new LowLevelDictionary<uint, IntPtr>();
-            private Lock _lock = new Lock();
-
-            public unsafe IntPtr GetMemoryBlockForValue(uint value)
-            {
-                using (LockHolder.Hold(_lock))
-                {
-                    IntPtr result;
-                    if (_allocatedBlocks.TryGetValue(value, out result))
-                    {
-                        return result;
-                    }
-                    result = MemoryHelpers.AllocateMemory(IntPtr.Size);
-                    *(uint*)(result.ToPointer()) = value;
-                    _allocatedBlocks.Add(value, result);
-                    return result;
-                }
-            }
-        }
-
-        private class PermanentlyAllocatedMemoryRegions_IntPtr_In_IntPtr
-        {
-            private LowLevelDictionary<IntPtr, IntPtr> _allocatedBlocks = new LowLevelDictionary<IntPtr, IntPtr>();
-            private Lock _lock = new Lock();
-
-            public unsafe IntPtr GetMemoryBlockForValue(IntPtr value)
-            {
-                using (LockHolder.Hold(_lock))
-                {
-                    IntPtr result;
-                    if (_allocatedBlocks.TryGetValue(value, out result))
-                    {
-                        return result;
-                    }
-                    result = MemoryHelpers.AllocateMemory(IntPtr.Size);
-                    *(IntPtr*)(result.ToPointer()) = value;
-                    _allocatedBlocks.Add(value, result);
-                    return result;
-                }
-            }
-        }
-
-        public static IntPtr GetPointerToUInt(uint value)
-        {
-            return s_uintCellValues.GetMemoryBlockForValue(value);
-        }
-
-        public static IntPtr GetPointerToIntPtr(IntPtr value)
-        {
-            return s_pointerIndirectionCellValues.GetMemoryBlockForValue(value);
-        }
-    }
-}
index 625eefe2a4c14a23ce17b0834f2786d988b92ce7..d3fd2dd8b24a18a6a752122e5ebb41fa3f8a6ae5 100644 (file)
@@ -4,11 +4,6 @@
 
 using System;
 using System.Diagnostics;
-using System.Collections.Generic;
-using System.Runtime.InteropServices;
-
-using Internal.Runtime;
-using Internal.Runtime.Augments;
 
 using Internal.NativeFormat;
 using Internal.TypeSystem;
@@ -24,85 +19,8 @@ namespace Internal.Runtime.TypeLoader
         //
         public static TypeDesc TryGetTypeTemplate(TypeDesc concreteType, ref NativeLayoutInfo nativeLayoutInfo)
         {
-#if GENERICS_FORCE_USG
-            return TryGetUniversalTypeTemplate(concreteType, ref nativeLayoutInfo);
-#else
-            // First, see if there is a specific canonical template
-            TypeDesc result = TryGetTypeTemplate_Internal(concreteType, CanonicalFormKind.Specific, out nativeLayoutInfo.Module, out nativeLayoutInfo.Offset);
-
-            // If not found, see if there's a universal canonical template
-            result ??= TryGetUniversalTypeTemplate(concreteType, ref nativeLayoutInfo);
-
-            return result;
-#endif
-        }
-
-        public static TypeDesc TryGetUniversalTypeTemplate(TypeDesc concreteType, ref NativeLayoutInfo nativeLayoutInfo)
-        {
-            return TryGetTypeTemplate_Internal(concreteType, CanonicalFormKind.Universal, out nativeLayoutInfo.Module, out nativeLayoutInfo.Offset);
-        }
-
-#if GENERICS_FORCE_USG
-        public TypeDesc TryGetNonUniversalTypeTemplate(TypeDesc concreteType, ref NativeLayoutInfo nativeLayoutInfo)
-        {
             return TryGetTypeTemplate_Internal(concreteType, CanonicalFormKind.Specific, out nativeLayoutInfo.Module, out nativeLayoutInfo.Offset);
         }
-#endif
-
-        /// <summary>
-        /// Get the NativeLayout for a method from a ReadyToRun image.
-        /// </summary>
-        public static bool TryGetMetadataNativeLayout(MethodDesc concreteMethod, out NativeFormatModuleInfo nativeLayoutInfoModule, out uint nativeLayoutInfoToken)
-        {
-            nativeLayoutInfoModule = null;
-            nativeLayoutInfoToken = 0;
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            var nativeMetadataType = concreteMethod.GetTypicalMethodDefinition() as TypeSystem.NativeFormat.NativeFormatMethod;
-            if (nativeMetadataType == null)
-                return false;
-
-            var canonForm = concreteMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);
-            var hashCode = canonForm.GetHashCode();
-
-#if SUPPORTS_R2R_LOADING
-            foreach (var moduleInfo in ModuleList.EnumerateModules())
-            {
-                if (moduleInfo.MetadataReader == null)
-                    continue;
-
-                ExternalReferencesTable externalFixupsTable;
-                NativeHashtable methodTemplatesHashtable = LoadHashtable(moduleInfo.Handle, ReflectionMapBlob.MetadataBasedGenericMethodsTemplateMap, out externalFixupsTable);
-
-                if (methodTemplatesHashtable.IsNull)
-                    continue;
-
-                var enumerator = methodTemplatesHashtable.Lookup(hashCode);
-                var nativeMetadataUnit = nativeMetadataType.Context.ResolveMetadataUnit(moduleInfo);
-
-                NativeParser entryParser;
-                while (!(entryParser = enumerator.GetNext()).IsNull)
-                {
-                    var entryTypeHandle = entryParser.GetUnsigned().AsHandle();
-                    MethodDesc methodDesc = nativeMetadataUnit.GetMethod(entryTypeHandle, null);
-                    Debug.Assert(methodDesc != null);
-                    if (methodDesc == canonForm)
-                    {
-                        TypeLoaderLogger.WriteLine("Found metadata template for method " + concreteMethod.ToString() + ": " + methodDesc.ToString());
-                        nativeLayoutInfoToken = entryParser.GetUnsigned();
-                        if (nativeLayoutInfoToken == BadTokenFixupValue)
-                        {
-                            throw new BadImageFormatException();
-                        }
-
-                        nativeLayoutInfoModule = moduleInfo;
-                        return true;
-                    }
-                }
-            }
-#endif
-#endif
-            return false;
-        }
 
         private static TypeDesc TryGetTypeTemplate_Internal(TypeDesc concreteType, CanonicalFormKind kind, out NativeFormatModuleInfo nativeLayoutInfoModule, out uint nativeLayoutInfoToken)
         {
@@ -157,13 +75,7 @@ namespace Internal.Runtime.TypeLoader
         //
         public static InstantiatedMethod TryGetGenericMethodTemplate(InstantiatedMethod concreteMethod, out NativeFormatModuleInfo nativeLayoutInfoModule, out uint nativeLayoutInfoToken)
         {
-            // First, see if there is a specific canonical template
-            InstantiatedMethod result = TryGetGenericMethodTemplate_Internal(concreteMethod, CanonicalFormKind.Specific, out nativeLayoutInfoModule, out nativeLayoutInfoToken);
-
-            // If not found, see if there's a universal canonical template
-            result ??= TryGetGenericMethodTemplate_Internal(concreteMethod, CanonicalFormKind.Universal, out nativeLayoutInfoModule, out nativeLayoutInfoToken);
-
-            return result;
+            return TryGetGenericMethodTemplate_Internal(concreteMethod, CanonicalFormKind.Specific, out nativeLayoutInfoModule, out nativeLayoutInfoToken);
         }
         private static InstantiatedMethod TryGetGenericMethodTemplate_Internal(InstantiatedMethod concreteMethod, CanonicalFormKind kind, out NativeFormatModuleInfo nativeLayoutInfoModule, out uint nativeLayoutInfoToken)
         {
index 820354d6dfbf8d7cb58b2edc09544786fe058b8f..d4704895ce9a8eedc68609e30ce6a119ea5a0a4d 100644 (file)
@@ -5,34 +5,20 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Reflection;
-using System.Runtime;
-using System.Text;
-
-using System.Reflection.Runtime.General;
 
 using Internal.Runtime.Augments;
 using Internal.Runtime.CompilerServices;
 
-using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
-using Internal.TypeSystem.NoMetadata;
 
 namespace Internal.Runtime.TypeLoader
 {
     using DynamicGenericsRegistrationData = TypeLoaderEnvironment.DynamicGenericsRegistrationData;
     using GenericTypeEntry = TypeLoaderEnvironment.GenericTypeEntry;
-    using TypeEntryToRegister = TypeLoaderEnvironment.TypeEntryToRegister;
     using GenericMethodEntry = TypeLoaderEnvironment.GenericMethodEntry;
-    using HandleBasedGenericTypeLookup = TypeLoaderEnvironment.HandleBasedGenericTypeLookup;
-    using DefTypeBasedGenericTypeLookup = TypeLoaderEnvironment.DefTypeBasedGenericTypeLookup;
     using HandleBasedGenericMethodLookup = TypeLoaderEnvironment.HandleBasedGenericMethodLookup;
     using MethodDescBasedGenericMethodLookup = TypeLoaderEnvironment.MethodDescBasedGenericMethodLookup;
-#if FEATURE_UNIVERSAL_GENERICS
-    using ThunkKind = CallConverterThunk.ThunkKind;
-#endif
 
     internal static class LowLevelListExtensions
     {
@@ -57,23 +43,6 @@ namespace Internal.Runtime.TypeLoader
         }
     }
 
-    [Flags]
-    internal enum FieldLoadState
-    {
-        None = 0,
-        Instance = 1,
-        Statics = 2,
-    }
-
-    public static class TypeBuilderApi
-    {
-        public static void ResolveMultipleCells(GenericDictionaryCell [] cells, out IntPtr[] fixups)
-        {
-            TypeBuilder.ResolveMultipleCells(cells, out fixups);
-        }
-    }
-
-
     internal class TypeBuilder
     {
         public TypeBuilder()
@@ -81,8 +50,6 @@ namespace Internal.Runtime.TypeLoader
             TypeLoaderEnvironment.Instance.VerifyTypeLoaderLockHeld();
         }
 
-        private const int MinimumValueTypeSize = 0x1;
-
         /// <summary>
         /// The StaticClassConstructionContext for a type is encoded in the negative space
         /// of the NonGCStatic fields of a type.
@@ -95,8 +62,6 @@ namespace Internal.Runtime.TypeLoader
 
         private LowLevelList<TypeDesc> _typesThatNeedPreparation;
 
-        private object _epoch = new object();
-
 #if DEBUG
         private bool _finalTypeBuilding;
 #endif
@@ -938,7 +903,7 @@ namespace Internal.Runtime.TypeLoader
             }
         }
 
-        private IEnumerable<TypeEntryToRegister> TypesToRegister()
+        private IEnumerable<GenericTypeEntry> TypesToRegister()
         {
             for (int i = 0; i < _typesThatNeedTypeHandles.Count; i++)
             {
@@ -946,25 +911,12 @@ namespace Internal.Runtime.TypeLoader
                 if (typeAsDefType == null)
                     continue;
 
-                if (typeAsDefType.HasInstantiation && !typeAsDefType.IsTypeDefinition)
+                yield return new GenericTypeEntry
                 {
-                    yield return new TypeEntryToRegister
-                    {
-                        GenericTypeEntry = new GenericTypeEntry
-                        {
-                            _genericTypeDefinitionHandle = GetRuntimeTypeHandle(typeAsDefType.GetTypeDefinition()),
-                            _genericTypeArgumentHandles = GetRuntimeTypeHandles(typeAsDefType.Instantiation),
-                            _instantiatedTypeHandle = typeAsDefType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle
-                        }
-                    };
-                }
-                else
-                {
-                    yield return new TypeEntryToRegister
-                    {
-                        MetadataDefinitionType = (MetadataType)typeAsDefType
-                    };
-                }
+                    _genericTypeDefinitionHandle = GetRuntimeTypeHandle(typeAsDefType.GetTypeDefinition()),
+                    _genericTypeArgumentHandles = GetRuntimeTypeHandles(typeAsDefType.Instantiation),
+                    _instantiatedTypeHandle = typeAsDefType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle
+                };
             }
         }
 
index 052ba336779b80a2222a3b38b3b51059bd68e268..e16517a118424a3d2e742832fb865e134d98fe34 100644 (file)
@@ -4,18 +4,9 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Reflection;
-using System.Text;
 
-using Internal.Runtime;
-using Internal.Runtime.Augments;
-using Internal.Runtime.CompilerServices;
-
-using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
-using Internal.TypeSystem.NoMetadata;
 
 namespace Internal.Runtime.TypeLoader
 {
index ea35dfd51064fd3f4bcf31558f98faf742c83157..648366faecae4204385b44d3fa33e02c651ee0e8 100644 (file)
@@ -3,14 +3,9 @@
 
 
 using System;
-using System.Runtime;
-using System.Collections.Generic;
 using System.Diagnostics;
-using System.Runtime.InteropServices;
 using System.Threading;
 
-using Internal.Runtime;
-using Internal.Runtime.Augments;
 using Internal.Runtime.CompilerServices;
 
 using Internal.NativeFormat;
@@ -386,43 +381,6 @@ namespace Internal.Runtime.TypeLoader
 
             Debug.Assert(methodPointer != IntPtr.Zero && dictionaryPointer != IntPtr.Zero);
 
-#if FEATURE_UNIVERSAL_GENERICS
-            if (templateMethod.IsCanonicalMethod(CanonicalFormKind.Universal))
-            {
-                // Check if we need to wrap the method pointer into a calling convention converter thunk
-                if (!TypeLoaderEnvironment.Instance.MethodSignatureHasVarsNeedingCallingConventionConverter(context, nameAndSignature.Signature))
-                {
-                    TypeSystemContextFactory.Recycle(context);
-                    return true;
-                }
-
-                RuntimeTypeHandle[] typeArgs = Array.Empty<RuntimeTypeHandle>();
-
-                if (RuntimeAugments.IsGenericType(targetTypeHandle))
-                {
-                    RuntimeAugments.GetGenericInstantiation(targetTypeHandle, out typeArgs);
-                }
-
-                // Create a CallingConventionConverter to call the method correctly
-                IntPtr thunkPtr = CallConverterThunk.MakeThunk(
-                    CallConverterThunk.ThunkKind.StandardToGenericInstantiating,
-                    methodPointer,
-                    nameAndSignature.Signature,
-                    dictionaryPointer,
-                    typeArgs,
-                    genericMethodArgumentHandles);
-
-                Debug.Assert(thunkPtr != IntPtr.Zero);
-
-                methodPointer = thunkPtr;
-                // Set dictionaryPointer to null so we don't make a fat function pointer around the whole thing.
-                dictionaryPointer = IntPtr.Zero;
-
-                // 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.
-            }
-#endif
-
             TypeSystemContextFactory.Recycle(context);
             return true;
         }
index aa54690ca942dfc3b53ec61aacf09910df724779..5c918fc26cc327d35f3a0aa0997ae6576696bc2c 100644 (file)
@@ -19,12 +19,6 @@ namespace Internal.Runtime.TypeLoader
 {
     public sealed partial class TypeLoaderEnvironment
     {
-        internal struct TypeEntryToRegister
-        {
-            public GenericTypeEntry GenericTypeEntry;
-            public MetadataType MetadataDefinitionType;
-        }
-
         internal class GenericTypeEntry
         {
             private int? _hashCode;
index 6cee4bd31abd5f3ec4f2f421c4710eca27c82680..8c9922d1a29c73c9f4b3d3eabbf9365be1d4bf1a 100644 (file)
@@ -3,19 +3,11 @@
 
 
 using System;
-using System.Runtime;
 using System.Collections.Generic;
 using System.Diagnostics;
-using System.Runtime.InteropServices;
 using System.Threading;
 
-using Internal.Runtime;
-using Internal.Runtime.Augments;
-using Internal.Runtime.CompilerServices;
-
-using Internal.NativeFormat;
 using Internal.TypeSystem;
-using System.Reflection.Runtime.General;
 
 namespace Internal.Runtime.TypeLoader
 {
@@ -26,7 +18,7 @@ namespace Internal.Runtime.TypeLoader
         internal struct DynamicGenericsRegistrationData
         {
             public int TypesToRegisterCount;
-            public IEnumerable<TypeEntryToRegister> TypesToRegister;
+            public IEnumerable<GenericTypeEntry> TypesToRegister;
             public int MethodsToRegisterCount;
             public IEnumerable<GenericMethodEntry> MethodsToRegister;
         }
@@ -40,17 +32,16 @@ namespace Internal.Runtime.TypeLoader
             {
                 int registeredTypesCount = 0;
                 int registeredMethodsCount = 0;
-                int nativeFormatTypesRegisteredCount = 0;
-                TypeEntryToRegister[] registeredTypes = null;
+                GenericTypeEntry[] registeredTypes = null;
                 GenericMethodEntry[] registeredMethods = null;
 
                 try
                 {
                     if (registrationData.TypesToRegister != null)
                     {
-                        registeredTypes = new TypeEntryToRegister[registrationData.TypesToRegisterCount];
+                        registeredTypes = new GenericTypeEntry[registrationData.TypesToRegisterCount];
 
-                        foreach (TypeEntryToRegister typeEntry in registrationData.TypesToRegister)
+                        foreach (GenericTypeEntry typeEntry in registrationData.TypesToRegister)
                         {
                             // Keep track of registered type handles so that we can rollback the registration on exception.
                             registeredTypes[registeredTypesCount++] = typeEntry;
@@ -59,69 +50,12 @@ namespace Internal.Runtime.TypeLoader
                             // We can save a bit of memory by avoiding the redundancy where possible. For now, we are keeping it simple.
 
                             // Register type -> components mapping first so that we can use it during rollback below
-                            if (typeEntry.GenericTypeEntry != null)
-                            {
-                                GenericTypeEntry registeredTypeEntry = _dynamicGenericTypes.AddOrGetExisting(typeEntry.GenericTypeEntry);
-                                if (registeredTypeEntry != typeEntry.GenericTypeEntry && registeredTypeEntry._isRegisteredSuccessfully)
-                                    throw new ArgumentException(SR.Argument_AddingDuplicate);
-
-                                registeredTypeEntry._instantiatedTypeHandle = typeEntry.GenericTypeEntry._instantiatedTypeHandle;
-                                registeredTypeEntry._isRegisteredSuccessfully = true;
-                            }
-                            else
-                            {
-                                MetadataType metadataType = typeEntry.MetadataDefinitionType;
-                                IntPtr nonGcStaticFields = IntPtr.Zero;
-                                IntPtr gcStaticFields = IntPtr.Zero;
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-#if SUPPORTS_R2R_LOADING
-                                uint nonGcStaticsRva = 0;
-                                uint gcStaticsRva = 0;
-
-                                // For images where statics are directly embedded in the image, store the information about where
-                                // to find statics info
-                                if (TypeLoaderEnvironment.TryGetStaticsTableEntry(metadataType, out nonGcStaticsRva, out gcStaticsRva))
-                                {
-                                    ModuleInfo moduleInfo = TypeLoaderEnvironment.GetModuleInfoForType(metadataType);
-
-                                    if (nonGcStaticsRva == 0)
-                                        nonGcStaticFields = TypeLoaderEnvironment.NoStaticsData;
-                                    else
-                                        nonGcStaticFields = moduleInfo.Handle + checked((int)nonGcStaticsRva);
-
-                                    if (gcStaticsRva == 0)
-                                        gcStaticFields = TypeLoaderEnvironment.NoStaticsData;
-                                    else
-                                        gcStaticFields = moduleInfo.Handle + checked((int)gcStaticsRva);
-                                }
-#endif
-
-                                TypeSystem.NativeFormat.NativeFormatType nativeFormatType = metadataType as TypeSystem.NativeFormat.NativeFormatType;
-                                if (nativeFormatType != null)
-                                {
-                                    RegisterNewNamedTypeRuntimeTypeHandle(new QTypeDefinition(nativeFormatType.MetadataReader,
-                                                                                nativeFormatType.Handle),
-                                        nativeFormatType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle,
-                                        nonGcStaticFields,
-                                        gcStaticFields);
-                                }
-#if ECMA_METADATA_SUPPORT
-                                TypeSystem.Ecma.EcmaType ecmaFormatType = metadataType as TypeSystem.Ecma.EcmaType;
-                                if (ecmaFormatType != null)
-                                {
-                                    RegisterNewNamedTypeRuntimeTypeHandle(new QTypeDefinition(ecmaFormatType.MetadataReader,
-                                                                                ecmaFormatType.Handle),
-                                        ecmaFormatType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle,
-                                        nonGcStaticFields,
-                                        gcStaticFields);
-                                }
-#endif
-
-                                nativeFormatTypesRegisteredCount++;
-#else
-                                Environment.FailFast("Ready to Run module type?");
-#endif
-                            }
+                            GenericTypeEntry registeredTypeEntry = _dynamicGenericTypes.AddOrGetExisting(typeEntry);
+                            if (registeredTypeEntry != typeEntry && registeredTypeEntry._isRegisteredSuccessfully)
+                                throw new ArgumentException(SR.Argument_AddingDuplicate);
+
+                            registeredTypeEntry._instantiatedTypeHandle = typeEntry._instantiatedTypeHandle;
+                            registeredTypeEntry._isRegisteredSuccessfully = true;
                         }
                     }
                     Debug.Assert(registeredTypesCount == registrationData.TypesToRegisterCount);
@@ -167,35 +101,9 @@ namespace Internal.Runtime.TypeLoader
                         {
                             var typeEntry = registeredTypes[i];
                             // There is no Remove feature in the LockFreeReaderHashtable...
-                            if (typeEntry.GenericTypeEntry != null)
-                            {
-                                GenericTypeEntry failedEntry = _dynamicGenericTypes.GetValueIfExists(typeEntry.GenericTypeEntry);
-                                if (failedEntry != null)
-                                    failedEntry._isRegisteredSuccessfully = false;
-                            }
-                            else
-                            {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-                                TypeSystem.NativeFormat.NativeFormatType nativeFormatType = typeEntry.MetadataDefinitionType as TypeSystem.NativeFormat.NativeFormatType;
-                                if (nativeFormatType != null)
-                                {
-                                    UnregisterNewNamedTypeRuntimeTypeHandle(new QTypeDefinition(nativeFormatType.MetadataReader,
-                                                                                nativeFormatType.Handle),
-                                                                            nativeFormatType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle);
-                                }
-#if ECMA_METADATA_SUPPORT
-                                TypeSystem.Ecma.EcmaType ecmaFormatType = typeEntry.MetadataDefinitionType as TypeSystem.Ecma.EcmaType;
-                                if (ecmaFormatType != null)
-                                {
-                                    UnregisterNewNamedTypeRuntimeTypeHandle(new QTypeDefinition(ecmaFormatType.MetadataReader,
-                                                                                ecmaFormatType.Handle),
-                                                                            ecmaFormatType.GetTypeBuilderState().HalfBakedRuntimeTypeHandle);
-                                }
-#endif
-#else
-                                Environment.FailFast("Ready to Run module type?");
-#endif
-                            }
+                            GenericTypeEntry failedEntry = _dynamicGenericTypes.GetValueIfExists(typeEntry);
+                            if (failedEntry != null)
+                                failedEntry._isRegisteredSuccessfully = false;
                         }
                         for (int i = 0; i < registeredMethodsCount; i++)
                         {
@@ -217,9 +125,6 @@ namespace Internal.Runtime.TypeLoader
 
                     throw;
                 }
-
-                if (nativeFormatTypesRegisteredCount > 0)
-                    FinishAddingNewNamedTypes();
             }
         }
 
index 45ddc417bad75b5c63ca2e58b8b7390da38d1595..98c84ddc0ca512105b955e7cae6e30e0e69391b4 100644 (file)
@@ -95,8 +95,6 @@ namespace Internal.Runtime.TypeLoader
             ref FieldAccessMetadata fieldAccessMetadata)
         {
             CanonicallyEquivalentEntryLocator canonWrapper = new CanonicallyEquivalentEntryLocator(declaringTypeHandle, canonFormKind);
-            string fieldName = null;
-            RuntimeTypeHandle declaringTypeHandleDefinition = TypeLoaderEnvironment.GetTypeDefinition(declaringTypeHandle);
 
             foreach (NativeFormatModuleInfo mappingTableModule in ModuleList.EnumerateModules(RuntimeAugments.GetModuleFromTypeHandle(declaringTypeHandle)))
             {
@@ -139,24 +137,7 @@ namespace Internal.Runtime.TypeLoader
                     }
                     else
                     {
-                        if (fieldName == null)
-                        {
-                            QTypeDefinition qTypeDefinition;
-
-                            bool success = Instance.TryGetMetadataForNamedType(
-                                declaringTypeHandleDefinition,
-                                out qTypeDefinition);
-                            Debug.Assert(success);
-
-                            MetadataReader nativeFormatMetadataReader = qTypeDefinition.NativeFormatReader;
-
-                            fieldName = nativeFormatMetadataReader.GetString(fieldHandle.GetField(nativeFormatMetadataReader).Name);
-                        }
-
-                        string entryFieldName = entryParser.GetString();
-
-                        if (fieldName != entryFieldName)
-                            continue;
+                        Debug.Fail("Multifile path");
                     }
 
                     int fieldOffset;
@@ -187,12 +168,5 @@ namespace Internal.Runtime.TypeLoader
 
             return false;
         }
-
-        private enum FieldAccessStaticDataKind
-        {
-            NonGC,
-            GC,
-            TLS
-        }
     }
 }
index 367ff35a59f0afc6aff7e382be41e63255516108..4468cec95b5203971c71a3d80a95bb23952ff5e5 100644 (file)
@@ -3,22 +3,17 @@
 
 
 using System;
-using System.Runtime;
-using System.Collections.Generic;
 using System.Diagnostics;
-using System.Runtime.InteropServices;
 using System.Threading;
 
 using System.Reflection.Runtime.General;
 
-using Internal.Runtime;
 using Internal.Runtime.Augments;
 using Internal.Runtime.CompilerServices;
 
 using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
 #if ECMA_METADATA_SUPPORT
 using Internal.TypeSystem.Ecma;
 #endif
@@ -102,6 +97,104 @@ namespace Internal.Runtime.TypeLoader
             return default(NativeReader);
         }
 
+        /// <summary>
+        /// Return the metadata handle for a TypeDef if the pay-for-policy enabled this type as browsable. This is used to obtain name and other information for types
+        /// obtained via typeof() or Object.GetType(). This can include generic types (not to be confused with generic instances).
+        ///
+        /// Preconditions:
+        ///    runtimeTypeHandle is a typedef (not a constructed type such as an array or generic instance.)
+        /// </summary>
+        /// <param name="runtimeTypeHandle">Runtime handle of the type in question</param>
+        /// <param name="qTypeDefinition">TypeDef handle for the type</param>
+        public unsafe bool TryGetMetadataForNamedType(RuntimeTypeHandle runtimeTypeHandle, out QTypeDefinition qTypeDefinition)
+        {
+            int hashCode = runtimeTypeHandle.GetHashCode();
+
+            // Iterate over all modules, starting with the module that defines the MethodTable
+            foreach (NativeFormatModuleInfo module in ModuleList.EnumerateModules(RuntimeAugments.GetModuleFromTypeHandle(runtimeTypeHandle)))
+            {
+                NativeReader typeMapReader;
+                if (TryGetNativeReaderForBlob(module, ReflectionMapBlob.TypeMap, out typeMapReader))
+                {
+                    NativeParser typeMapParser = new NativeParser(typeMapReader, 0);
+                    NativeHashtable typeHashtable = new NativeHashtable(typeMapParser);
+
+                    ExternalReferencesTable externalReferences = default(ExternalReferencesTable);
+                    externalReferences.InitializeCommonFixupsTable(module);
+
+                    var lookup = typeHashtable.Lookup(hashCode);
+                    NativeParser entryParser;
+                    while (!(entryParser = lookup.GetNext()).IsNull)
+                    {
+                        RuntimeTypeHandle foundType = externalReferences.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
+                        if (foundType.Equals(runtimeTypeHandle))
+                        {
+                            Handle entryMetadataHandle = entryParser.GetUnsigned().AsHandle();
+                            if (entryMetadataHandle.HandleType == HandleType.TypeDefinition)
+                            {
+                                MetadataReader metadataReader = module.MetadataReader;
+                                qTypeDefinition = new QTypeDefinition(metadataReader, entryMetadataHandle.ToTypeDefinitionHandle(metadataReader));
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+
+            qTypeDefinition = default;
+            return false;
+        }
+
+        /// <summary>
+        /// Return the RuntimeTypeHandle for the named type described in metadata. This is used to implement the Create and Invoke
+        /// apis for types.
+        ///
+        /// Preconditions:
+        ///    metadataReader + typeDefHandle  - a valid metadata reader + typeDefinitionHandle where "metadataReader" is one
+        ///                                      of the metadata readers returned by ExecutionEnvironment.MetadataReaders.
+        ///
+        /// Note: Although this method has a "bool" return value like the other mapping table accessors, the pay-for-play design
+        /// guarantees that any type enabled for metadata also has a RuntimeTypeHandle underneath.
+        /// </summary>
+        /// <param name="qTypeDefinition">TypeDef handle for the type to look up</param>
+        /// <param name="runtimeTypeHandle">Runtime type handle (MethodTable) for the given type</param>
+        public unsafe bool TryGetNamedTypeForMetadata(QTypeDefinition qTypeDefinition, out RuntimeTypeHandle runtimeTypeHandle)
+        {
+            if (qTypeDefinition.IsNativeFormatMetadataBased)
+            {
+                MetadataReader metadataReader = qTypeDefinition.NativeFormatReader;
+                TypeDefinitionHandle typeDefHandle = qTypeDefinition.NativeFormatHandle;
+                int hashCode = typeDefHandle.ComputeHashCode(metadataReader);
+
+                NativeFormatModuleInfo module = ModuleList.Instance.GetModuleInfoForMetadataReader(metadataReader);
+
+                NativeReader typeMapReader;
+                if (TryGetNativeReaderForBlob(module, ReflectionMapBlob.TypeMap, out typeMapReader))
+                {
+                    NativeParser typeMapParser = new NativeParser(typeMapReader, 0);
+                    NativeHashtable typeHashtable = new NativeHashtable(typeMapParser);
+
+                    ExternalReferencesTable externalReferences = default(ExternalReferencesTable);
+                    externalReferences.InitializeCommonFixupsTable(module);
+
+                    var lookup = typeHashtable.Lookup(hashCode);
+                    NativeParser entryParser;
+                    while (!(entryParser = lookup.GetNext()).IsNull)
+                    {
+                        var foundTypeIndex = entryParser.GetUnsigned();
+                        if (entryParser.GetUnsigned().AsHandle().Equals(typeDefHandle))
+                        {
+                            runtimeTypeHandle = externalReferences.GetRuntimeTypeHandleFromIndex(foundTypeIndex);
+                            return true;
+                        }
+                    }
+                }
+            }
+
+            runtimeTypeHandle = default;
+            return false;
+        }
+
         /// <summary>
         /// Return the metadata handle for a TypeRef if this type was referenced indirectly by other type that pay-for-play has denoted as browsable
         /// (for example, as part of a method signature.)
index d43a4dc2891eceb371192e5db3e8034c2ee101e7..c33338cd9124d2accff25efde34dd07e36e7e576 100644 (file)
@@ -17,7 +17,6 @@ using Internal.Runtime.CompilerServices;
 using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
 
 namespace Internal.Runtime.TypeLoader
 {
diff --git a/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.NamedTypeLookup.cs b/src/coreclr/nativeaot/System.Private.TypeLoader/src/Internal/Runtime/TypeLoader/TypeLoaderEnvironment.NamedTypeLookup.cs
deleted file mode 100644 (file)
index c8aec12..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-
-
-using System;
-using System.Runtime;
-using System.Runtime.CompilerServices;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Threading;
-
-using System.Reflection.Runtime.General;
-
-using Internal.Runtime;
-using Internal.Runtime.Augments;
-
-using Internal.Metadata.NativeFormat;
-using Internal.NativeFormat;
-using Internal.TypeSystem;
-
-namespace Internal.Runtime.TypeLoader
-{
-    public sealed partial class TypeLoaderEnvironment
-    {
-        private class NamedTypeLookupResult
-        {
-            public int RuntimeTypeHandleHashcode;
-            public RuntimeTypeHandle RuntimeTypeHandle;
-            public QTypeDefinition QualifiedTypeDefinition;
-            public IntPtr GcStaticFields;
-            public IntPtr NonGcStaticFields;
-            public volatile int VersionNumber;
-        }
-
-        private volatile int _namedTypeLookupLiveVersion;
-
-        private NamedTypeRuntimeTypeHandleToMetadataHashtable _runtimeTypeHandleToMetadataHashtable = new NamedTypeRuntimeTypeHandleToMetadataHashtable();
-
-        public static IntPtr NoStaticsData { get; } = (IntPtr)1;
-
-        private class NamedTypeRuntimeTypeHandleToMetadataHashtable : LockFreeReaderHashtable<RuntimeTypeHandle, NamedTypeLookupResult>
-        {
-            protected override unsafe int GetKeyHashCode(RuntimeTypeHandle key)
-            {
-                return (int)key.ToEETypePtr()->HashCode;
-            }
-            protected override bool CompareKeyToValue(RuntimeTypeHandle key, NamedTypeLookupResult value)
-            {
-                return key.Equals(value.RuntimeTypeHandle);
-            }
-
-            protected override unsafe int GetValueHashCode(NamedTypeLookupResult value)
-            {
-                return value.RuntimeTypeHandleHashcode;
-            }
-
-            protected override bool CompareValueToValue(NamedTypeLookupResult value1, NamedTypeLookupResult value2)
-            {
-                if (value1.RuntimeTypeHandle.IsNull() || value2.RuntimeTypeHandle.IsNull())
-                {
-                    return value1.QualifiedTypeDefinition.Token.Equals(value2.QualifiedTypeDefinition.Token) &&
-                           value1.QualifiedTypeDefinition.Reader.Equals(value2.QualifiedTypeDefinition.Reader);
-                }
-                return value1.RuntimeTypeHandle.Equals(value2.RuntimeTypeHandle);
-            }
-
-            protected override NamedTypeLookupResult CreateValueFromKey(RuntimeTypeHandle key)
-            {
-                int hashCode = GetKeyHashCode(key);
-
-                // Iterate over all modules, starting with the module that defines the MethodTable
-                foreach (NativeFormatModuleInfo module in ModuleList.EnumerateModules(RuntimeAugments.GetModuleFromTypeHandle(key)))
-                {
-                    NativeReader typeMapReader;
-                    if (TryGetNativeReaderForBlob(module, ReflectionMapBlob.TypeMap, out typeMapReader))
-                    {
-                        NativeParser typeMapParser = new NativeParser(typeMapReader, 0);
-                        NativeHashtable typeHashtable = new NativeHashtable(typeMapParser);
-
-                        ExternalReferencesTable externalReferences = default(ExternalReferencesTable);
-                        externalReferences.InitializeCommonFixupsTable(module);
-
-                        var lookup = typeHashtable.Lookup(hashCode);
-                        NativeParser entryParser;
-                        while (!(entryParser = lookup.GetNext()).IsNull)
-                        {
-                            RuntimeTypeHandle foundType = externalReferences.GetRuntimeTypeHandleFromIndex(entryParser.GetUnsigned());
-                            if (foundType.Equals(key))
-                            {
-                                Handle entryMetadataHandle = entryParser.GetUnsigned().AsHandle();
-                                if (entryMetadataHandle.HandleType == HandleType.TypeDefinition)
-                                {
-                                    MetadataReader metadataReader = module.MetadataReader;
-                                    return new NamedTypeLookupResult()
-                                    {
-                                        QualifiedTypeDefinition = new QTypeDefinition(metadataReader, entryMetadataHandle.ToTypeDefinitionHandle(metadataReader)),
-                                        RuntimeTypeHandle = key,
-                                        RuntimeTypeHandleHashcode = hashCode
-                                    };
-                                }
-                            }
-                        }
-                    }
-                }
-
-                return new NamedTypeLookupResult()
-                {
-                    RuntimeTypeHandle = key,
-                    RuntimeTypeHandleHashcode = hashCode
-                };
-            }
-        }
-
-        private QTypeDefinitionToRuntimeTypeHandleHashtable _metadataToRuntimeTypeHandleHashtable = new QTypeDefinitionToRuntimeTypeHandleHashtable();
-
-        private class QTypeDefinitionToRuntimeTypeHandleHashtable : LockFreeReaderHashtable<QTypeDefinition, NamedTypeLookupResult>
-        {
-            [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            private static int _rotl(int value, int shift)
-            {
-                return (int)(((uint)value << shift) | ((uint)value >> (32 - shift)));
-            }
-
-            protected override unsafe int GetKeyHashCode(QTypeDefinition key)
-            {
-                return key.Token.GetHashCode() ^ _rotl(key.Reader.GetHashCode(), 8);
-            }
-            protected override bool CompareKeyToValue(QTypeDefinition key, NamedTypeLookupResult value)
-            {
-                return key.Token.Equals(value.QualifiedTypeDefinition.Token) &&
-                       key.Reader.Equals(value.QualifiedTypeDefinition.Reader);
-            }
-
-            protected override unsafe int GetValueHashCode(NamedTypeLookupResult value)
-            {
-                return value.QualifiedTypeDefinition.Token.GetHashCode() ^ _rotl(value.QualifiedTypeDefinition.Reader.GetHashCode(), 8);
-            }
-
-            protected override bool CompareValueToValue(NamedTypeLookupResult value1, NamedTypeLookupResult value2)
-            {
-                return value1.QualifiedTypeDefinition.Token.Equals(value2.QualifiedTypeDefinition.Token) &&
-                        value1.QualifiedTypeDefinition.Reader.Equals(value2.QualifiedTypeDefinition.Reader);
-            }
-
-            protected override NamedTypeLookupResult CreateValueFromKey(QTypeDefinition key)
-            {
-                RuntimeTypeHandle foundRuntimeTypeHandle = default(RuntimeTypeHandle);
-
-                if (key.IsNativeFormatMetadataBased)
-                {
-                    MetadataReader metadataReader = key.NativeFormatReader;
-                    TypeDefinitionHandle typeDefHandle = key.NativeFormatHandle;
-                    int hashCode = typeDefHandle.ComputeHashCode(metadataReader);
-
-                    NativeFormatModuleInfo module = ModuleList.Instance.GetModuleInfoForMetadataReader(metadataReader);
-
-                    NativeReader typeMapReader;
-                    if (TryGetNativeReaderForBlob(module, ReflectionMapBlob.TypeMap, out typeMapReader))
-                    {
-                        NativeParser typeMapParser = new NativeParser(typeMapReader, 0);
-                        NativeHashtable typeHashtable = new NativeHashtable(typeMapParser);
-
-                        ExternalReferencesTable externalReferences = default(ExternalReferencesTable);
-                        externalReferences.InitializeCommonFixupsTable(module);
-
-                        var lookup = typeHashtable.Lookup(hashCode);
-                        NativeParser entryParser;
-                        while (!(entryParser = lookup.GetNext()).IsNull)
-                        {
-                            var foundTypeIndex = entryParser.GetUnsigned();
-                            if (entryParser.GetUnsigned().AsHandle().Equals(typeDefHandle))
-                            {
-                                foundRuntimeTypeHandle = externalReferences.GetRuntimeTypeHandleFromIndex(foundTypeIndex);
-                                break;
-                            }
-                        }
-                    }
-                }
-
-                return new NamedTypeLookupResult()
-                {
-                    QualifiedTypeDefinition = key,
-                    RuntimeTypeHandle = foundRuntimeTypeHandle,
-                    VersionNumber = TypeLoaderEnvironment.Instance._namedTypeLookupLiveVersion
-                };
-            }
-        }
-
-        /// <summary>
-        /// Return the metadata handle for a TypeDef if the pay-for-policy enabled this type as browsable. This is used to obtain name and other information for types
-        /// obtained via typeof() or Object.GetType(). This can include generic types (not to be confused with generic instances).
-        ///
-        /// Preconditions:
-        ///    runtimeTypeHandle is a typedef (not a constructed type such as an array or generic instance.)
-        /// </summary>
-        /// <param name="runtimeTypeHandle">Runtime handle of the type in question</param>
-        /// <param name="qTypeDefinition">TypeDef handle for the type</param>
-        public unsafe bool TryGetMetadataForNamedType(RuntimeTypeHandle runtimeTypeHandle, out QTypeDefinition qTypeDefinition)
-        {
-            NamedTypeLookupResult result = _runtimeTypeHandleToMetadataHashtable.GetOrCreateValue(runtimeTypeHandle);
-            qTypeDefinition = result.QualifiedTypeDefinition;
-            return qTypeDefinition.Reader != null;
-        }
-
-        /// <summary>
-        /// Get the static addresses of a type if it is in the table
-        /// </summary>
-        /// <param name="runtimeTypeHandle">Runtime handle of the type in question</param>
-        /// <param name="nonGcStaticsData">non-gc static field address</param>
-        /// <param name="gcStaticsData">gc static field address</param>
-        /// <returns>true if nonGcStaticsData/gcStaticsData are valid, false if not</returns>
-        public unsafe bool TryGetStaticsInfoForNamedType(RuntimeTypeHandle runtimeTypeHandle, out IntPtr nonGcStaticsData, out IntPtr gcStaticsData)
-        {
-            NamedTypeLookupResult result;
-
-            if (!_runtimeTypeHandleToMetadataHashtable.TryGetValue(runtimeTypeHandle, out result))
-            {
-                gcStaticsData = IntPtr.Zero;
-                nonGcStaticsData = IntPtr.Zero;
-                return false;
-            }
-
-            gcStaticsData = result.GcStaticFields;
-            nonGcStaticsData = result.NonGcStaticFields;
-
-            bool noResults = gcStaticsData == IntPtr.Zero || gcStaticsData == IntPtr.Zero;
-
-            if (gcStaticsData == (IntPtr)1)
-                gcStaticsData = IntPtr.Zero;
-
-            if (nonGcStaticsData == (IntPtr)1)
-                nonGcStaticsData = IntPtr.Zero;
-
-            return result.QualifiedTypeDefinition.Reader != null && !noResults;
-        }
-
-        /// <summary>
-        /// Return the RuntimeTypeHandle for the named type described in metadata. This is used to implement the Create and Invoke
-        /// apis for types.
-        ///
-        /// Preconditions:
-        ///    metadataReader + typeDefHandle  - a valid metadata reader + typeDefinitionHandle where "metadataReader" is one
-        ///                                      of the metadata readers returned by ExecutionEnvironment.MetadataReaders.
-        ///
-        /// Note: Although this method has a "bool" return value like the other mapping table accessors, the pay-for-play design
-        /// guarantees that any type enabled for metadata also has a RuntimeTypeHandle underneath.
-        /// </summary>
-        /// <param name="qTypeDefinition">TypeDef handle for the type to look up</param>
-        /// <param name="runtimeTypeHandle">Runtime type handle (MethodTable) for the given type</param>
-        public unsafe bool TryGetNamedTypeForMetadata(QTypeDefinition qTypeDefinition, out RuntimeTypeHandle runtimeTypeHandle)
-        {
-            runtimeTypeHandle = default(RuntimeTypeHandle);
-            NamedTypeLookupResult result = _metadataToRuntimeTypeHandleHashtable.GetOrCreateValue(qTypeDefinition);
-
-            if (result.VersionNumber <= _namedTypeLookupLiveVersion)
-                runtimeTypeHandle = result.RuntimeTypeHandle;
-
-            return !runtimeTypeHandle.IsNull();
-        }
-
-        public void RegisterNewNamedTypeRuntimeTypeHandle(QTypeDefinition qTypeDefinition, RuntimeTypeHandle runtimeTypeHandle, IntPtr nonGcStaticFields, IntPtr gcStaticFields)
-        {
-            TypeLoaderLogger.WriteLine("Register new type with MethodTable = " + runtimeTypeHandle.ToIntPtr().LowLevelToString() + " nonGcStaticFields " + nonGcStaticFields.LowLevelToString() + " gcStaticFields " + gcStaticFields.LowLevelToString());
-            NamedTypeLookupResult result = _metadataToRuntimeTypeHandleHashtable.GetOrCreateValue(qTypeDefinition);
-
-            result.VersionNumber = _namedTypeLookupLiveVersion + 1;
-            result.RuntimeTypeHandle = runtimeTypeHandle;
-            result.GcStaticFields = gcStaticFields;
-            result.NonGcStaticFields = nonGcStaticFields;
-            unsafe
-            {
-                result.RuntimeTypeHandleHashcode = (int)runtimeTypeHandle.ToEETypePtr()->HashCode;
-            }
-
-            NamedTypeLookupResult rthToMetadataResult = _runtimeTypeHandleToMetadataHashtable.AddOrGetExisting(result);
-
-            if (!object.ReferenceEquals(rthToMetadataResult, result))
-            {
-                rthToMetadataResult.QualifiedTypeDefinition = qTypeDefinition;
-                rthToMetadataResult.GcStaticFields = gcStaticFields;
-                rthToMetadataResult.NonGcStaticFields = nonGcStaticFields;
-            }
-        }
-
-        public void UnregisterNewNamedTypeRuntimeTypeHandle(QTypeDefinition qTypeDefinition, RuntimeTypeHandle runtimeTypeHandle)
-        {
-            NamedTypeLookupResult metadataLookupResult;
-            if (_metadataToRuntimeTypeHandleHashtable.TryGetValue(qTypeDefinition, out metadataLookupResult))
-            {
-                metadataLookupResult.RuntimeTypeHandle = default(RuntimeTypeHandle);
-                metadataLookupResult.VersionNumber = -1;
-            }
-
-            if (_runtimeTypeHandleToMetadataHashtable.TryGetValue(runtimeTypeHandle, out _))
-            {
-                metadataLookupResult.GcStaticFields = IntPtr.Zero;
-                metadataLookupResult.NonGcStaticFields = IntPtr.Zero;
-                metadataLookupResult.RuntimeTypeHandle = default(RuntimeTypeHandle);
-            }
-        }
-
-        public void FinishAddingNewNamedTypes()
-        {
-            _namedTypeLookupLiveVersion++;
-            if (_namedTypeLookupLiveVersion == int.MaxValue)
-                Environment.FailFast("Too many types loaded");
-        }
-    }
-}
index 22675a16af85da8b0d36e684d5a37cd43dbe7e76..4a28836cb33ce9aef7866d1bacda3182edfe0046 100644 (file)
@@ -30,13 +30,6 @@ namespace Internal.Runtime.TypeLoader
         /// </summary>
         public IntPtr TryGetNonGcStaticFieldData(RuntimeTypeHandle runtimeTypeHandle)
         {
-            IntPtr nonGcStaticsAddress;
-            IntPtr gcStaticsAddress;
-            if (TryGetStaticsInfoForNamedType(runtimeTypeHandle, out nonGcStaticsAddress, out gcStaticsAddress))
-            {
-                return nonGcStaticsAddress;
-            }
-
             unsafe
             {
                 // Non-generic, non-dynamic static data is found via the FieldAccessMap
@@ -76,13 +69,6 @@ namespace Internal.Runtime.TypeLoader
         /// </summary>
         public IntPtr TryGetGcStaticFieldData(RuntimeTypeHandle runtimeTypeHandle)
         {
-            IntPtr nonGcStaticsAddress;
-            IntPtr gcStaticsAddress;
-            if (TryGetStaticsInfoForNamedType(runtimeTypeHandle, out nonGcStaticsAddress, out gcStaticsAddress))
-            {
-                return gcStaticsAddress;
-            }
-
             unsafe
             {
                 // Non-generic, non-dynamic static data is found via the FieldAccessMap
@@ -262,11 +248,6 @@ namespace Internal.Runtime.TypeLoader
 
             return new NativeParser();
         }
-
-        private static unsafe IntPtr TryCreateDictionaryCellWithValue(uint value)
-        {
-            return PermanentAllocatedMemoryBlobs.GetPointerToUInt(value);
-        }
         #endregion
     }
 }
index 9adae880ecf854cd398fad76d41ed25716b746fc..21ee20c6231224eb15bf793190711e25c2ccad6c 100644 (file)
@@ -5,19 +5,15 @@
 using System;
 using System.Threading;
 using System.Collections.Generic;
-using System.Runtime;
-using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Reflection.Runtime.General;
 
-using Internal.Runtime;
 using Internal.Runtime.Augments;
 using Internal.Runtime.CompilerServices;
 
 using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
 
 using Debug = System.Diagnostics.Debug;
 
@@ -645,28 +641,6 @@ namespace Internal.Runtime.TypeLoader
             }
         }
 
-        public unsafe bool TryGetOrCreateNamedTypeForMetadata(
-            QTypeDefinition qTypeDefinition,
-            out RuntimeTypeHandle runtimeTypeHandle)
-        {
-            if (TryGetNamedTypeForMetadata(qTypeDefinition, out runtimeTypeHandle))
-            {
-                return true;
-            }
-
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            using (LockHolder.Hold(_typeLoaderLock))
-            {
-                IntPtr runtimeTypeHandleAsIntPtr;
-                TypeBuilder.ResolveSingleTypeDefinition(qTypeDefinition, out runtimeTypeHandleAsIntPtr);
-                runtimeTypeHandle = *(RuntimeTypeHandle*)&runtimeTypeHandleAsIntPtr;
-                return true;
-            }
-#else
-            return false;
-#endif
-        }
-
         public static IntPtr ConvertUnboxingFunctionPointerToUnderlyingNonUnboxingPointer(IntPtr unboxingFunctionPointer, RuntimeTypeHandle declaringType)
         {
             if (FunctionPointerOps.IsGenericMethodPointer(unboxingFunctionPointer))
index e28f575ca841f7d78f859867c08e4fa67a828767..7dd6bbc01a326c250a1151ef7536910ce796c1dc 100644 (file)
@@ -2,17 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 
 using System;
-using System.Reflection;
 using System.Diagnostics;
 
-using Internal.Metadata.NativeFormat;
-using Internal.Runtime.Augments;
-using Internal.Runtime.CompilerServices;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NativeFormat;
-using Internal.TypeSystem.NoMetadata;
-using Internal.Reflection.Core;
-using Internal.Reflection.Execution;
 
 namespace Internal.Runtime.TypeLoader
 {
@@ -22,11 +14,6 @@ namespace Internal.Runtime.TypeLoader
     /// </summary>
     public partial class TypeLoaderTypeSystemContext : TypeSystemContext
     {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-        private static readonly MetadataFieldLayoutAlgorithm s_metadataFieldLayoutAlgorithm = new MetadataFieldLayoutAlgorithm();
-        private static readonly MetadataVirtualMethodAlgorithm s_metadataVirtualMethodAlgorithm = new MetadataVirtualMethodAlgorithm();
-        private static readonly MetadataRuntimeInterfacesAlgorithm s_metadataRuntimeInterfacesAlgorithm = new MetadataRuntimeInterfacesAlgorithm();
-#endif
         private static readonly NoMetadataFieldLayoutAlgorithm s_noMetadataFieldLayoutAlgorithm = new NoMetadataFieldLayoutAlgorithm();
         private static readonly NoMetadataRuntimeInterfacesAlgorithm s_noMetadataRuntimeInterfacesAlgorithm = new NoMetadataRuntimeInterfacesAlgorithm();
         private static readonly NativeLayoutFieldAlgorithm s_nativeLayoutFieldAlgorithm = new NativeLayoutFieldAlgorithm();
@@ -34,27 +21,11 @@ namespace Internal.Runtime.TypeLoader
 
         public TypeLoaderTypeSystemContext(TargetDetails targetDetails) : base(targetDetails)
         {
-            ModuleDesc systemModule = null;
-
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            systemModule = ((MetadataType)GetWellKnownType(WellKnownType.Object)).Module;
-#endif
-
-            InitializeSystemModule(systemModule);
         }
 
         public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
         {
-            if ((type == UniversalCanonType)
-#if SUPPORT_DYNAMIC_CODE
-                || (type.IsRuntimeDeterminedType && (((RuntimeDeterminedType)type).CanonicalType == UniversalCanonType)))
-#else
-                )
-#endif
-            {
-                return UniversalCanonLayoutAlgorithm.Instance;
-            }
-            else if (type.RetrieveRuntimeTypeHandleIfPossible())
+            if (type.RetrieveRuntimeTypeHandleIfPossible())
             {
                 // If the type is already constructed, use the NoMetadataFieldLayoutAlgorithm.
                 // its more efficient than loading from native layout or metadata.
@@ -64,24 +35,12 @@ namespace Internal.Runtime.TypeLoader
             {
                 return s_nativeLayoutFieldAlgorithm;
             }
-            else if (type is NoMetadataType)
-            {
-                return s_noMetadataFieldLayoutAlgorithm;
-            }
-            else
-            {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-                return s_metadataFieldLayoutAlgorithm;
-#else
-                Debug.Assert(false);
-                return null;
-#endif
-            }
+            return s_noMetadataFieldLayoutAlgorithm;
         }
 
         protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForDefType(DefType type)
         {
-            if (type.RetrieveRuntimeTypeHandleIfPossible() && !type.IsGenericDefinition)
+            if (type.RetrieveRuntimeTypeHandleIfPossible())
             {
                 // If the type is already constructed, use the NoMetadataRuntimeInterfacesAlgorithm.
                 // its more efficient than loading from native layout or metadata.
@@ -91,21 +50,7 @@ namespace Internal.Runtime.TypeLoader
             {
                 return s_nativeLayoutInterfacesAlgorithm;
             }
-            else if (type is NoMetadataType)
-            {
-                return s_noMetadataRuntimeInterfacesAlgorithm;
-            }
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            else if (type is MetadataType)
-            {
-                return s_metadataRuntimeInterfacesAlgorithm;
-            }
-#endif
-            else
-            {
-                Debug.Assert(false);
-                return null;
-            }
+            return s_noMetadataRuntimeInterfacesAlgorithm;
         }
 
         protected internal sealed override bool IsIDynamicInterfaceCastableInterface(DefType type)
@@ -210,55 +155,6 @@ namespace Internal.Runtime.TypeLoader
             }
         }
 
-        public override ModuleDesc ResolveAssembly(AssemblyName name, bool throwErrorIfNotFound)
-        {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            AssemblyBindResult bindResult;
-            Exception failureException;
-            if (!AssemblyBinderImplementation.Instance.Bind(name.ToRuntimeAssemblyName(), cacheMissedLookups: true, out bindResult, out failureException))
-            {
-                if (throwErrorIfNotFound)
-                    throw failureException;
-                return null;
-            }
-
-            var moduleList = Internal.Runtime.TypeLoader.ModuleList.Instance;
-
-            if (bindResult.Reader != null)
-            {
-                NativeFormatModuleInfo primaryModule = moduleList.GetModuleInfoForMetadataReader(bindResult.Reader);
-                NativeFormatMetadataUnit metadataUnit = ResolveMetadataUnit(primaryModule);
-                return metadataUnit.GetModule(bindResult.ScopeDefinitionHandle);
-            }
-#if ECMA_METADATA_SUPPORT
-            else if (bindResult.EcmaMetadataReader != null)
-            {
-                EcmaModuleInfo ecmaModule = moduleList.GetModuleInfoForMetadataReader(bindResult.EcmaMetadataReader);
-                return ResolveEcmaModule(ecmaModule);
-            }
-#endif
-            else
-            {
-                // Should not be possible to reach here
-                throw new Exception();
-            }
-#else
-            return null;
-#endif
-        }
-
-        public override VirtualMethodAlgorithm GetVirtualMethodAlgorithmForType(TypeDesc type)
-        {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            Debug.Assert(!type.IsArray, "Wanted to call GetClosestMetadataType?");
-
-            return s_metadataVirtualMethodAlgorithm;
-#else
-            Debug.Assert(false);
-            return null;
-#endif
-        }
-
         protected internal override Instantiation ConvertInstantiationToCanonForm(Instantiation instantiation, CanonicalFormKind kind, out bool changed)
         {
             return StandardCanonicalizationAlgorithm.ConvertInstantiationToCanonForm(instantiation, kind, out changed);
@@ -269,33 +165,6 @@ namespace Internal.Runtime.TypeLoader
             return StandardCanonicalizationAlgorithm.ConvertToCanon(typeToConvert, kind);
         }
 
-        protected internal override bool ComputeHasGCStaticBase(FieldDesc field)
-        {
-            Debug.Assert(field.IsStatic);
-
-            if (field is NativeLayoutFieldDesc)
-            {
-                return ((NativeLayoutFieldDesc)field).FieldStorage == Internal.NativeFormat.FieldStorage.GCStatic;
-            }
-
-            TypeDesc fieldType = field.FieldType;
-            if (fieldType.IsValueType)
-            {
-                FieldDesc typicalField = field.GetTypicalFieldDefinition();
-
-                if (field != typicalField)
-                {
-                    if (typicalField.FieldType.IsSignatureVariable)
-                        return true;
-                }
-                if (fieldType.IsEnum || fieldType.IsPrimitive)
-                    return false;
-                return true;
-            }
-            else
-                return fieldType.IsGCPointer;
-        }
-
         protected internal override bool ComputeHasStaticConstructor(TypeDesc type)
         {
             if (type.RetrieveRuntimeTypeHandleIfPossible())
@@ -305,14 +174,11 @@ namespace Internal.Runtime.TypeLoader
                     return type.RuntimeTypeHandle.ToEETypePtr()->HasCctor;
                 }
             }
-            else if (type is MetadataType)
-            {
-                return ((MetadataType)type).GetStaticConstructor() != null;
-            }
+            Debug.Assert(type is not DefType);
             return false;
         }
 
-        public override bool SupportsUniversalCanon => true;
+        public override bool SupportsUniversalCanon => false;
         public override bool SupportsCanon => true;
     }
 }
index a97b75c0c150a306af4c5901b9437cc95b467693..e727444745fe414d5d62eb835229a5fe54117ef3 100644 (file)
@@ -3,26 +3,9 @@
 
 
 using System;
-using System.Reflection;
-using System.Collections.Generic;
-using System.Diagnostics;
 
-using Internal.NativeFormat;
-using Internal.TypeSystem.NativeFormat;
-#if ECMA_METADATA_SUPPORT
-using Internal.TypeSystem.Ecma;
-#endif
 using Internal.Runtime.Augments;
-using Internal.Runtime.CompilerServices;
 using Internal.TypeSystem;
-using Internal.TypeSystem.NoMetadata;
-using System.Reflection.Runtime.General;
-
-namespace Internal.TypeSystem.NativeFormat
-{
-    // When SUPPORTS_NATIVE_METADATA_TYPE_LOADING is not set we may see compile errors from using statements.
-    // Add a namespace definition for Internal.TypeSystem.NativeFormat
-}
 
 namespace Internal.Runtime.TypeLoader
 {
@@ -38,14 +21,6 @@ namespace Internal.Runtime.TypeLoader
             DefType typeAsDefType = type as DefType;
             return typeAsDefType != null && typeAsDefType.HasInstantiation;
         }
-
-        public static DefType GetClosestDefType(this TypeDesc type)
-        {
-            if (type is DefType)
-                return (DefType)type;
-            else
-                return type.BaseType;
-        }
     }
 
     internal static class MethodDescExtensions
@@ -75,84 +50,4 @@ namespace Internal.Runtime.TypeLoader
             return (rtfhValue.ToInt64() & 0x1) == 0x1;
         }
     }
-
-    public static partial class RuntimeSignatureHelper
-    {
-        public static bool TryCreate(MethodDesc method, out RuntimeSignature methodSignature)
-        {
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-            MethodDesc typicalMethod = method.GetTypicalMethodDefinition();
-
-            if (typicalMethod is TypeSystem.NativeFormat.NativeFormatMethod)
-            {
-                TypeSystem.NativeFormat.NativeFormatMethod nativeFormatMethod = (TypeSystem.NativeFormat.NativeFormatMethod)typicalMethod;
-                methodSignature = RuntimeSignature.CreateFromMethodHandle(nativeFormatMethod.MetadataUnit.RuntimeModule, nativeFormatMethod.Handle.ToInt());
-                return true;
-            }
-#if ECMA_METADATA_SUPPORT
-            if (typicalMethod is TypeSystem.Ecma.EcmaMethod)
-            {
-                unsafe
-                {
-                    TypeSystem.Ecma.EcmaMethod ecmaMethod = (TypeSystem.Ecma.EcmaMethod)typicalMethod;
-                    methodSignature = RuntimeSignature.CreateFromMethodHandle(new IntPtr(ecmaMethod.Module.RuntimeModuleInfo.DynamicModulePtr), System.Reflection.Metadata.Ecma335.MetadataTokens.GetToken(ecmaMethod.Handle));
-                }
-                return true;
-            }
-#endif
-#endif
-            methodSignature = default(RuntimeSignature);
-            return false;
-        }
-
-#if SUPPORTS_NATIVE_METADATA_TYPE_LOADING
-        public static MethodDesc ToMethodDesc(this RuntimeMethodHandle rmh, TypeSystemContext typeSystemContext)
-        {
-            RuntimeTypeHandle declaringTypeHandle;
-            MethodNameAndSignature nameAndSignature;
-            RuntimeTypeHandle[] genericMethodArgs;
-
-            if (!TypeLoaderEnvironment.Instance.TryGetRuntimeMethodHandleComponents(rmh, out declaringTypeHandle, out nameAndSignature, out genericMethodArgs))
-            {
-                return null;
-            }
-
-            QMethodDefinition methodHandle;
-            if (!TypeLoaderEnvironment.Instance.TryGetMetadataForTypeMethodNameAndSignature(declaringTypeHandle, nameAndSignature, out methodHandle))
-            {
-                return null;
-            }
-
-            TypeDesc declaringType = typeSystemContext.ResolveRuntimeTypeHandle(declaringTypeHandle);
-
-            TypeDesc declaringTypeDefinition = declaringType.GetTypeDefinition();
-            MethodDesc typicalMethod = null;
-            if (methodHandle.IsNativeFormatMetadataBased)
-            {
-                var nativeFormatType = (NativeFormatType)declaringTypeDefinition;
-                typicalMethod = nativeFormatType.MetadataUnit.GetMethod(methodHandle.NativeFormatHandle, nativeFormatType);
-            }
-            else if (methodHandle.IsEcmaFormatMetadataBased)
-            {
-                var ecmaFormatType = (EcmaType)declaringTypeDefinition;
-                typicalMethod = ecmaFormatType.EcmaModule.GetMethod(methodHandle.EcmaFormatHandle);
-            }
-            Debug.Assert(typicalMethod != null);
-
-            MethodDesc methodOnInstantiatedType = typicalMethod;
-            if (declaringType != declaringTypeDefinition)
-                methodOnInstantiatedType = typeSystemContext.GetMethodForInstantiatedType(typicalMethod, (InstantiatedType)declaringType);
-
-            MethodDesc instantiatedMethod = methodOnInstantiatedType;
-            if (genericMethodArgs != null)
-            {
-                Debug.Assert(genericMethodArgs.Length > 0);
-                Instantiation genericMethodInstantiation = typeSystemContext.ResolveRuntimeTypeHandles(genericMethodArgs);
-                typeSystemContext.GetInstantiatedMethod(methodOnInstantiatedType, genericMethodInstantiation);
-            }
-
-            return instantiatedMethod;
-        }
-#endif
-    }
 }
index 08b444d0280fc0ecc5f9b4165ce644b94a771631..c903dc1849a02f96646ed3809f21b177f33de377 100644 (file)
@@ -14,7 +14,6 @@ using Internal.Runtime;
 using Internal.Runtime.Augments;
 using Internal.Runtime.CompilerServices;
 using Internal.Runtime.TypeLoader;
-using Internal.TypeSystem.NativeFormat;
 using Internal.TypeSystem.NoMetadata;
 using Internal.Metadata.NativeFormat;
 using Internal.NativeFormat;
index fea0a58061282ce54233786f89533ef431b181a4..b658cc35b155cc363745b839607cd6c053c4d490 100644 (file)
     <Compile Include="$(CompilerCommonPath)\TypeSystem\Common\TypeSystemHelpers.cs">
       <Link>Internal\TypeSystem\TypeSystemHelpers.cs</Link>
     </Compile>
-    <Compile Include="$(CompilerCommonPath)\TypeSystem\Common\UniversalCanonLayoutAlgorithm.cs">
-      <Link>UniversalCanonLayoutAlgorithm.cs</Link>
-    </Compile>
     <Compile Include="$(CompilerCommonPath)\TypeSystem\Common\Utilities\LockFreeReaderHashtableOfPointers.cs">
       <Link>LockFreeReaderHashtableOfPointers.cs</Link>
     </Compile>
     <Compile Include="Internal\Runtime\TypeLoader\MetadataReaderHelpers.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\ModuleList.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\NativeLayoutFieldAlgorithm.cs" />
-    <Compile Include="Internal\Runtime\TypeLoader\NativeLayoutFieldDesc.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\NativeLayoutInfoLoadContext.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\NativeLayoutInterfacesAlgorithm.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\NoMetadataFieldLayoutAlgorithm.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\NoMetadataRuntimeInterfacesAlgorithm.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\OptionalFields.cs" />
-    <Compile Include="Internal\Runtime\TypeLoader\PermanentAllocatedMemoryBlobs.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TemplateLocator.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeBuilder.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeBuilderState.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.Metadata.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.MetadataSignatureParsing.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.MethodAddress.cs" />
-    <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.NamedTypeLookup.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.SignatureParsing.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderEnvironment.StaticsLookup.cs" />
     <Compile Include="Internal\Runtime\TypeLoader\TypeLoaderLogger.cs" />