Example #1
0
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
                {
                    return(new[] {
                            new DependencyListEntry(
                                factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, typeInstantiation, methodInstantiation),
                                "Dictionary dependency"),
                            new DependencyListEntry(
                                _lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
                                "Dictionary dependency")
                        });
                }
            }
            break;
            }

            // All other generic lookups just depend on the thing they point to
            return(new[] { new DependencyListEntry(
                               _lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
                               "Dictionary dependency") });
        }
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
                {
                    // TODO: Make _dictionaryOwner a RuntimeDetermined type/method and make a substitution with
                    // typeInstantiation/methodInstantiation to get a concrete type. Then pass the generic dictionary
                    // node of the concrete type to the GetTarget call. Also change the signature of GetTarget to
                    // take only the factory and dictionary as input.
                    return(new[] {
                            new DependencyListEntry(
                                factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, typeInstantiation, methodInstantiation, null),
                                "Dictionary dependency"),
                            new DependencyListEntry(
                                _lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation, null),
                                "Dictionary dependency")
                        });
                }
            }
            break;
            }

            // All other generic lookups just depend on the thing they point to
            return(new[] { new DependencyListEntry(
                               _lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation, null),
                               "Dictionary dependency") });
        }
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            ArrayBuilder <DependencyListEntry> result = new ArrayBuilder <DependencyListEntry>();

            var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation);

            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
                {
                    result.Add(
                        new DependencyListEntry(
                            factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext),
                            "Dictionary dependency"));
                }
            }
            break;

            case ReadyToRunHelperId.DelegateCtor:
            {
                DelegateCreationInfo createInfo = (DelegateCreationInfo)_target;
                if (createInfo.NeedsVirtualMethodUseTracking)
                {
                    MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation);
                    if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots)
                    {
                        result.Add(
                            new DependencyListEntry(
                                factory.VirtualMethodUse(instantiatedTargetMethod),
                                "Dictionary dependency"));
                    }

                    // TODO: https://github.com/dotnet/corert/issues/3224
                    if (instantiatedTargetMethod.IsAbstract)
                    {
                        result.Add(new DependencyListEntry(factory.ReflectableMethod(instantiatedTargetMethod), "Abstract reflectable method"));
                    }
                }
            }
            break;
            }

            // All generic lookups depend on the thing they point to
            result.Add(new DependencyListEntry(
                           _lookupSignature.GetTarget(factory, lookupContext),
                           "Dictionary dependency"));

            return(result.ToArray());
        }
Example #4
0
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            DependencyList result = new DependencyList();

            var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation);

            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.PreinitializationManager.HasLazyStaticConstructor(type))
                {
                    result.Add(
                        new DependencyListEntry(
                            factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext),
                            "Dictionary dependency"));
                }
            }
            break;

            case ReadyToRunHelperId.DelegateCtor:
            {
                DelegateCreationInfo createInfo = (DelegateCreationInfo)_target;
                if (createInfo.NeedsVirtualMethodUseTracking)
                {
                    MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation);
                    if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots)
                    {
                        result.Add(
                            new DependencyListEntry(
                                factory.VirtualMethodUse(instantiatedTargetMethod),
                                "Dictionary dependency"));
                    }

                    factory.MetadataManager.GetDependenciesDueToVirtualMethodReflectability(ref result, factory, instantiatedTargetMethod);
                }
            }
            break;
            }

            // All generic lookups depend on the thing they point to
            result.Add(new DependencyListEntry(
                           _lookupSignature.GetTarget(factory, lookupContext),
                           "Dictionary dependency"));

            return(result.ToArray());
        }
        public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            ArrayBuilder <DependencyListEntry> result = new ArrayBuilder <DependencyListEntry>();

            switch (_id)
            {
            case ReadyToRunHelperId.GetGCStaticBase:
            case ReadyToRunHelperId.GetThreadStaticBase:
            {
                // If the type has a lazy static constructor, we also need the non-GC static base
                // because that's where the class constructor context is.
                TypeDesc type = (TypeDesc)_target;

                if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
                {
                    // TODO: Make _dictionaryOwner a RuntimeDetermined type/method and make a substitution with
                    // typeInstantiation/methodInstantiation to get a concrete type. Then pass the generic dictionary
                    // node of the concrete type to the GetTarget call. Also change the signature of GetTarget to
                    // take only the factory and dictionary as input.
                    result.Add(
                        new DependencyListEntry(
                            factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, typeInstantiation, methodInstantiation, null),
                            "Dictionary dependency"));
                }
            }
            break;

            case ReadyToRunHelperId.DelegateCtor:
            {
                DelegateCreationInfo createInfo = (DelegateCreationInfo)_target;
                if (createInfo.NeedsVirtualMethodUseTracking)
                {
                    MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.InstantiateSignature(typeInstantiation, methodInstantiation);
                    if (!factory.CompilationModuleGroup.ShouldProduceFullVTable(instantiatedTargetMethod.OwningType))
                    {
                        result.Add(
                            new DependencyListEntry(
                                factory.VirtualMethodUse(createInfo.TargetMethod.InstantiateSignature(typeInstantiation, methodInstantiation)),
                                "Dictionary dependency"));
                    }

                    // TODO: https://github.com/dotnet/corert/issues/3224
                    if (instantiatedTargetMethod.IsAbstract)
                    {
                        result.Add(new DependencyListEntry(factory.ReflectableMethod(instantiatedTargetMethod), "Abstract reflectable method"));
                    }
                }
            }
            break;

            case ReadyToRunHelperId.ResolveVirtualFunction:
            {
                MethodDesc instantiatedTarget = ((MethodDesc)_target).InstantiateSignature(typeInstantiation, methodInstantiation);
                if (!factory.CompilationModuleGroup.ShouldProduceFullVTable(instantiatedTarget.OwningType))
                {
                    result.Add(
                        new DependencyListEntry(
                            factory.VirtualMethodUse(instantiatedTarget),
                            "Dictionary dependency"));
                }

                // TODO: https://github.com/dotnet/corert/issues/3224
                if (instantiatedTarget.IsAbstract)
                {
                    result.Add(new DependencyListEntry(factory.ReflectableMethod(instantiatedTarget), "Abstract reflectable method"));
                }
            }
            break;
            }

            // All generic lookups depend on the thing they point to
            result.Add(new DependencyListEntry(
                           _lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation, null),
                           "Dictionary dependency"));

            return(result.ToArray());
        }