public static DependencyList GetGenericMethodsHashtableDependenciesForMethod(NodeFactory factory, MethodDesc method)
        {
            Debug.Assert(method.HasInstantiation && !method.IsCanonicalMethod(CanonicalFormKind.Any));

            DependencyList dependencies = new DependencyList();

            // Method's containing type
            IEETypeNode containingTypeNode = factory.NecessaryTypeSymbol(method.OwningType);

            dependencies.Add(new DependencyListEntry(containingTypeNode, "GenericMethodsHashtable entry containing type"));

            // Method's instantiation arguments
            for (int i = 0; i < method.Instantiation.Length; i++)
            {
                IEETypeNode argNode = factory.NecessaryTypeSymbol(method.Instantiation[i]);
                dependencies.Add(new DependencyListEntry(argNode, "GenericMethodsHashtable entry instantiation argument"));
            }

            // Method name and signature
            NativeLayoutVertexNode      nameAndSig       = factory.NativeLayout.MethodNameAndSignatureVertex(method.GetTypicalMethodDefinition());
            NativeLayoutSavedVertexNode placedNameAndSig = factory.NativeLayout.PlacedSignatureVertex(nameAndSig);

            dependencies.Add(new DependencyListEntry(placedNameAndSig, "GenericMethodsHashtable entry signature"));

            GenericDictionaryNode dictionaryNode = factory.MethodGenericDictionary(method);

            dependencies.Add(new DependencyListEntry(dictionaryNode, "GenericMethodsHashtable entry dictionary"));

            return(dependencies);
        }
示例#2
0
        public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            TypeDesc instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);
            int      typeSize;

            if (_type.IsDefType)
            {
                typeSize = ((DefType)_type).InstanceFieldSize.AsInt;
            }
            else
            {
                typeSize = factory.TypeSystemContext.Target.PointerSize;
            }

            builder.EmitNaturalInt(typeSize);
        }
示例#3
0
        public virtual void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            ISymbolNode target = GetTarget(factory, typeInstantiation, methodInstantiation, dictionary);

            if (LookupResultReferenceType(factory) == GenericLookupResultReferenceType.ConditionalIndirect)
            {
                builder.EmitPointerRelocOrIndirectionReference(target);
            }
            else
            {
                builder.EmitPointerReloc(target);
            }
        }
示例#4
0
 public override void EmitDictionaryData(ref ObjectDataBuilder builder, NodeFactory factory, GenericDictionaryNode dictionary, bool fixedLayoutOnly) => throw new NotImplementedException();
示例#5
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            // We are getting a constructed type symbol because this might be something passed to newobj.
            TypeDesc instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);

            return(factory.ConstructedTypeSymbol(instantiatedType));
        }
示例#6
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            var instantiatedType = (MetadataType)_type.InstantiateSignature(typeInstantiation, methodInstantiation);

            return(factory.TypeGCStaticsSymbol(instantiatedType));
        }
示例#7
0
        public InterfaceDispatchCellNode GetInterfaceDispatchCell(NodeFactory factory, GenericDictionaryNode dictionary)
        {
            MethodDesc instantiatedMethod = _method.InstantiateSignature(dictionary.TypeInstantiation, dictionary.MethodInstantiation);

            return(factory.InterfaceDispatchCell(instantiatedMethod, dictionary.GetMangledName()));
        }
示例#8
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            if (factory.Target.Abi == TargetAbi.CoreRT)
            {
                MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);

                // https://github.com/dotnet/corert/issues/2342 - we put a pointer to the virtual call helper into the dictionary
                // but this should be something that will let us compute the target of the dipatch (e.g. interface dispatch cell).
                return(factory.ReadyToRunHelper(ReadyToRunHelperId.VirtualCall, instantiatedMethod));
            }
            else
            {
                return(GetInterfaceDispatchCell(factory, dictionary));
            }
        }
示例#9
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            MethodDesc  instantiatedMethod   = _method.InstantiateSignature(typeInstantiation, methodInstantiation);
            ISymbolNode methodDictionaryNode = factory.MethodGenericDictionary(instantiatedMethod);

            if (methodDictionaryNode.RepresentsIndirectionCell)
            {
                // Imported method dictionary needs another indirection. Setting the lowest bit to indicate that.
                Debug.Assert(LookupResultReferenceType(factory) == GenericLookupResultReferenceType.ConditionalIndirect);
                return(factory.Indirection(methodDictionaryNode, 1));
            }
            else
            {
                return(methodDictionaryNode);
            }
        }
示例#10
0
        public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            FieldDesc instantiatedField = _field.InstantiateSignature(typeInstantiation, methodInstantiation);
            int       offset            = instantiatedField.Offset.AsInt;

            builder.EmitNaturalInt(offset);
        }
示例#11
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            MethodDesc instantiatedConstrainedMethod = _constrainedMethod.InstantiateSignature(typeInstantiation, methodInstantiation);
            TypeDesc   instantiatedConstraintType    = _constraintType.InstantiateSignature(typeInstantiation, methodInstantiation);

            MethodDesc implMethod = instantiatedConstraintType.GetClosestDefType().ResolveInterfaceMethodToVirtualMethodOnType(instantiatedConstrainedMethod);

            // AOT use of this generic lookup is restricted to finding methods on valuetypes (runtime usage of this slot in universal generics is more flexible)
            Debug.Assert(instantiatedConstraintType.IsValueType);
            Debug.Assert(implMethod.OwningType == instantiatedConstraintType);

            if (implMethod.HasInstantiation && implMethod.GetCanonMethodTarget(CanonicalFormKind.Specific) != implMethod)
            {
                return(factory.FatFunctionPointer(implMethod));
            }
            else
            {
                return(factory.MethodEntrypoint(implMethod));
            }
        }
示例#12
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            var instantiatedType = (MetadataType)_type.InstantiateSignature(typeInstantiation, methodInstantiation);

            // TODO The ProjectN abi should have an indirection here.
            return(factory.TypeGCStaticsSymbol(instantiatedType));
        }
示例#13
0
 public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     if (factory.Target.Abi == TargetAbi.CoreRT)
     {
         MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);
         return(factory.InterfaceDispatchCell(instantiatedMethod));
     }
     else
     {
         MethodDesc instantiatedMethod = _method.InstantiateSignature(dictionary.TypeInstantiation, dictionary.MethodInstantiation);
         return(factory.InterfaceDispatchCell(instantiatedMethod, dictionary.GetMangledName(factory.NameMangler)));
     }
 }
示例#14
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);

            return(factory.FatFunctionPointer(instantiatedMethod, _isUnboxingThunk));
        }
示例#15
0
 public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     builder.EmitPointerReloc(GetTarget(factory, typeInstantiation, methodInstantiation, dictionary), FatFunctionPointerConstants.Offset);
 }
示例#16
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            var         instantiatedType = (MetadataType)_type.InstantiateSignature(typeInstantiation, methodInstantiation);
            ISymbolNode target           = factory.TypeNonGCStaticsSymbol(instantiatedType);

            // The dictionary entry always points to the beginning of the data.
            if (factory.TypeSystemContext.HasLazyStaticConstructor(instantiatedType))
            {
                return(factory.Indirection(target, NonGCStaticsNode.GetClassConstructorContextStorageSize(factory.Target, instantiatedType)));
            }
            else
            {
                return(factory.Indirection(target));
            }
        }
示例#17
0
 public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     if (factory.Target.Abi == TargetAbi.CoreRT)
     {
         MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);
         return(factory.ReadyToRunHelper(ReadyToRunHelperId.VirtualCall, instantiatedMethod));
     }
     else
     {
         return(GetInterfaceDispatchCell(factory, dictionary));
     }
 }
示例#18
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            // We are getting a constructed type symbol because this might be something passed to newobj.
            TypeDesc    instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);
            IEETypeNode typeNode         = factory.ConstructedTypeSymbol(instantiatedType);

            if (typeNode.RepresentsIndirectionCell)
            {
                // Imported eetype needs another indirection. Setting the lowest bit to indicate that.
                Debug.Assert(LookupResultReferenceType(factory) == GenericLookupResultReferenceType.ConditionalIndirect);
                return(factory.Indirection(typeNode, 1));
            }
            else
            {
                return(typeNode);
            }
        }
示例#19
0
 public abstract ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary);
示例#20
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            UtcNodeFactory utcNodeFactory = factory as UtcNodeFactory;

            Debug.Assert(utcNodeFactory != null);
            TypeDesc instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);

            Debug.Assert(instantiatedType is MetadataType);
            return(factory.Indirection(utcNodeFactory.TypeThreadStaticsOffsetSymbol(instantiatedType as MetadataType)));
        }
示例#21
0
 public virtual void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     builder.EmitPointerReloc(GetTarget(factory, typeInstantiation, methodInstantiation, dictionary));
 }
示例#22
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            TypeDesc   instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);
            MethodDesc defaultCtor      = instantiatedType.GetDefaultConstructor();

            if (defaultCtor == null)
            {
                // If there isn't a default constructor, use the fallback one.
                MetadataType missingCtorType = factory.TypeSystemContext.SystemModule.GetKnownType("System", "Activator");
                missingCtorType = missingCtorType.GetNestedType("ClassWithMissingConstructor");
                Debug.Assert(missingCtorType != null);
                defaultCtor = missingCtorType.GetParameterlessConstructor();
            }
            else
            {
                defaultCtor = defaultCtor.GetCanonMethodTarget(CanonicalFormKind.Specific);
            }

            return(factory.MethodEntrypoint(defaultCtor));
        }
示例#23
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            TypeDesc instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);

            Debug.Assert(instantiatedType.IsArray);
            return(factory.ExternSymbol(JitHelper.GetNewArrayHelperForType(instantiatedType)));
        }
示例#24
0
 public override void EmitDictionaryEntry(ref ObjectDataBuilder builder, NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     Debug.Assert(false, "CallingConventionConverterLookupResult contents should only be generated into generic dictionaries at runtime");
     builder.EmitNaturalInt(0);
 }
示例#25
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);

            return(factory.RuntimeMethodHandle(instantiatedMethod));
        }
示例#26
0
 public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
 {
     Debug.Assert(false, "GetTarget for a TypeSizeLookupResult doesn't make sense. It isn't a pointer being emitted");
     return(null);
 }
示例#27
0
        public virtual void EmitDictionaryData(ref ObjectDataBuilder builder, NodeFactory factory, GenericDictionaryNode dictionary)
        {
            var context = new GenericLookupResultContext(dictionary.OwningEntity, dictionary.TypeInstantiation, dictionary.MethodInstantiation);

            foreach (GenericLookupResult lookupResult in Entries)
            {
#if DEBUG
                int offsetBefore = builder.CountBytes;
#endif

                lookupResult.EmitDictionaryEntry(ref builder, factory, context);

#if DEBUG
                Debug.Assert(builder.CountBytes - offsetBefore == factory.Target.PointerSize);
#endif
            }
        }
示例#28
0
        public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation, GenericDictionaryNode dictionary)
        {
            TypeDesc instantiatedType = _type.InstantiateSignature(typeInstantiation, methodInstantiation);

            // Unwrap the nullable type if necessary
            if (instantiatedType.IsNullable)
            {
                instantiatedType = instantiatedType.Instantiation[0];
            }

            // We are getting a constructed type symbol because this might be something passed to newobj.
            return(factory.ConstructedTypeSymbol(instantiatedType));
        }