Exemplo n.º 1
0
        public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory)
        {
            DependencyList dependencies = new DependencyList();

            // Make sure the canonical body gets generated
            dependencies.Add(new DependencyListEntry(CanonicalMethodNode, "Canonical body"));

            // Instantiate the runtime determined dependencies of the canonical method body
            // with the concrete instantiation of the method to get concrete dependencies.
            Instantiation typeInst   = Method.OwningType.Instantiation;
            Instantiation methodInst = Method.Instantiation;
            IEnumerable <DependencyListEntry> staticDependencies = CanonicalMethodNode.GetStaticDependencies(factory);

            if (staticDependencies != null)
            {
                foreach (DependencyListEntry canonDep in staticDependencies)
                {
                    var runtimeDep = canonDep.Node as INodeWithRuntimeDeterminedDependencies;
                    if (runtimeDep != null)
                    {
                        dependencies.AddRange(runtimeDep.InstantiateDependencies(factory, typeInst, methodInst));
                    }
                }
            }

            if (factory.Target.Abi == TargetAbi.CoreRT)
            {
                // TODO: https://github.com/dotnet/corert/issues/3224
                // Reflection invoke stub handling is here because in the current reflection model we reflection-enable
                // all methods that are compiled. Ideally the list of reflection enabled methods should be known before
                // we even start the compilation process (with the invocation stubs being compilation roots like any other).
                // The existing model has it's problems: e.g. the invocability of the method depends on inliner decisions.
                if (factory.MetadataManager.HasReflectionInvokeStub(Method))
                {
                    MethodDesc canonInvokeStub = factory.MetadataManager.GetCanonicalReflectionInvokeStub(Method);
                    if (canonInvokeStub.IsSharedByGenericInstantiations)
                    {
                        dependencies.Add(new DependencyListEntry(factory.MetadataManager.DynamicInvokeTemplateData, "Reflection invoke template data"));
                        factory.MetadataManager.DynamicInvokeTemplateData.AddDependenciesDueToInvokeTemplatePresence(ref dependencies, factory, canonInvokeStub);
                    }
                    else
                    {
                        dependencies.Add(new DependencyListEntry(factory.MethodEntrypoint(canonInvokeStub), "Reflection invoke"));
                    }
                }
            }

            if (Method.HasInstantiation)
            {
                if (Method.IsVirtual)
                {
                    dependencies.Add(new DependencyListEntry(factory.GVMDependencies(Method), "GVM Dependencies Support for method dictionary"));
                }

                // Dictionary dependency
                dependencies.Add(new DependencyListEntry(factory.MethodGenericDictionary(Method), "Method dictionary"));
            }

            return(dependencies);
        }
Exemplo n.º 2
0
        public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory)
        {
            DependencyList dependencies = new DependencyList();

            // Make sure the canonical body gets generated
            dependencies.Add(new DependencyListEntry(CanonicalMethodNode, "Canonical body"));

            // Instantiate the runtime determined dependencies of the canonical method body
            // with the concrete instantiation of the method to get concrete dependencies.
            Instantiation typeInst   = Method.OwningType.Instantiation;
            Instantiation methodInst = Method.Instantiation;
            IEnumerable <DependencyListEntry> staticDependencies = CanonicalMethodNode.GetStaticDependencies(factory);

            if (staticDependencies != null)
            {
                foreach (DependencyListEntry canonDep in staticDependencies)
                {
                    var runtimeDep = canonDep.Node as INodeWithRuntimeDeterminedDependencies;
                    if (runtimeDep != null)
                    {
                        dependencies.AddRange(runtimeDep.InstantiateDependencies(factory, typeInst, methodInst));
                    }
                }
            }

            return(dependencies);
        }
Exemplo n.º 3
0
        public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory)
        {
            // Make sure the canonical body gets generated
            yield return(new DependencyListEntry(CanonicalMethodNode, "Canonical body"));

            // Instantiate the runtime determined dependencies of the canonical method body
            // with the concrete instantiation of the method to get concrete dependencies.
            Instantiation typeInst   = Method.OwningType.Instantiation;
            Instantiation methodInst = Method.Instantiation;
            IEnumerable <DependencyListEntry> staticDependencies = CanonicalMethodNode.GetStaticDependencies(factory);

            if (staticDependencies != null)
            {
                foreach (DependencyListEntry canonDep in staticDependencies)
                {
                    var runtimeDep = canonDep.Node as INodeWithRuntimeDeterminedDependencies;
                    if (runtimeDep != null)
                    {
                        foreach (var d in runtimeDep.InstantiateDependencies(factory, typeInst, methodInst))
                        {
                            yield return(d);
                        }
                    }
                }
            }

            if (factory.Target.Abi == TargetAbi.CoreRT)
            {
                // Reflection invoke stub handling is here because in the current reflection model we reflection-enable
                // all methods that are compiled. Ideally the list of reflection enabled methods should be known before
                // we even start the compilation process (with the invocation stubs being compilation roots like any other).
                // The existing model has it's problems: e.g. the invocability of the method depends on inliner decisions.
                if (factory.MetadataManager.HasReflectionInvokeStub(Method))
                {
                    MethodDesc invokeStub      = factory.MetadataManager.GetReflectionInvokeStub(Method);
                    MethodDesc canonInvokeStub = invokeStub.GetCanonMethodTarget(CanonicalFormKind.Specific);
                    if (invokeStub != canonInvokeStub)
                    {
                        yield return(new DependencyListEntry(factory.FatFunctionPointer(invokeStub), "Reflection invoke"));
                    }
                    else
                    {
                        yield return(new DependencyListEntry(factory.MethodEntrypoint(invokeStub), "Reflection invoke"));
                    }
                }
            }

            if (Method.HasInstantiation)
            {
                if (Method.IsVirtual)
                {
                    yield return(new DependencyListEntry(factory.GVMDependencies(Method), "GVM Dependencies Support for method dictionary"));
                }

                // Dictionary dependency
                yield return(new DependencyListEntry(factory.MethodGenericDictionary(Method), "Method dictionary"));
            }
        }
Exemplo n.º 4
0
 // Implementation of ISymbolNode that makes this node act as a symbol for the canonical body
 public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
 {
     CanonicalMethodNode.AppendMangledName(nameMangler, sb);
 }
Exemplo n.º 5
0
 protected override string GetName(NodeFactory factory) => $"{Method.ToString()} backed by {CanonicalMethodNode.GetMangledName(factory.NameMangler)}";
Exemplo n.º 6
0
 protected override string GetName() => $"{Method.ToString()} backed by {CanonicalMethodNode.GetMangledName()}";