Пример #1
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (TypeDesc type in _module.GetAllTypes())
            {
                try
                {
                    rootProvider.AddCompilationRoot(type, "Library module type");
                }
                catch (TypeSystemException)
                {
                    // TODO: fail compilation if a switch was passed

                    // Swallow type load exceptions while rooting
                    continue;

                    // TODO: Log as a warning
                }

                // If this is not a generic definition, root all methods
                if (!type.HasInstantiation)
                {
                    RootMethods(type, "Library module method", rootProvider);
                    rootProvider.RootStaticBasesForType(type, "Library module type statics");
                }
            }
        }
        private void AddCompilationRootsForMultifileLibrary(EcmaModule module)
        {
            foreach (TypeDesc type in module.GetAllTypes())
            {
                // Skip delegates (since their Invoke methods have no IL) and uninstantiated generic types
                if (type.IsDelegate || type.ContainsGenericVariables)
                {
                    continue;
                }

                EcmaType ecmaType = type as EcmaType;

                if (ecmaType.Attributes.HasFlag(System.Reflection.TypeAttributes.Public))
                {
                    foreach (EcmaMethod method in ecmaType.GetMethods())
                    {
                        // Skip methods with no IL and uninstantiated generic methods
                        if (method.IsIntrinsic || method.IsAbstract || method.ContainsGenericVariables)
                        {
                            continue;
                        }

                        if (method.ImplAttributes.HasFlag(System.Reflection.MethodImplAttributes.InternalCall))
                        {
                            continue;
                        }

                        _rootProvider.AddCompilationRoot(method, "Library module method");
                    }
                }
            }
        }
Пример #3
0
        protected void AddCompilationRootsForExports(EcmaModule module)
        {
            foreach (var type in module.GetAllTypes())
            {
                foreach (var method in type.GetMethods())
                {
                    EcmaMethod ecmaMethod = (EcmaMethod)method;

                    if (ecmaMethod.IsRuntimeExport)
                    {
                        string runtimeExportName = ecmaMethod.GetRuntimeExportName();
                        if (runtimeExportName != null)
                        {
                            _rootProvider.AddCompilationRoot(method, "Runtime export", runtimeExportName);
                        }
                    }

                    if (ecmaMethod.IsNativeCallable)
                    {
                        string nativeCallableExportName = ecmaMethod.GetNativeCallableExportName();
                        if (nativeCallableExportName != null)
                        {
                            _rootProvider.AddCompilationRoot(method, "Native callable", nativeCallableExportName);
                        }
                    }
                }
            }
        }
Пример #4
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (var type in _module.GetAllTypes())
            {
                foreach (var method in type.GetMethods())
                {
                    EcmaMethod ecmaMethod = (EcmaMethod)method;

                    if (ecmaMethod.IsRuntimeExport)
                    {
                        string runtimeExportName = ecmaMethod.GetRuntimeExportName();
                        if (runtimeExportName != null)
                        {
                            rootProvider.AddCompilationRoot(method, "Runtime export", runtimeExportName);
                        }
                    }

                    if (ecmaMethod.IsNativeCallable)
                    {
                        string nativeCallableExportName = ecmaMethod.GetNativeCallableExportName();
                        if (nativeCallableExportName != null)
                        {
                            rootProvider.AddCompilationRoot(method, "Native callable", nativeCallableExportName);
                        }
                    }
                }
            }
        }
Пример #5
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (TypeDesc type in _module.GetAllTypes())
            {
                // Skip delegates (since their Invoke methods have no IL)
                if (type.IsDelegate)
                {
                    continue;
                }

                try
                {
                    rootProvider.AddCompilationRoot(type, "Library module type");
                }
                catch (TypeSystemException)
                {
                    // TODO: fail compilation if a switch was passed

                    // Swallow type load exceptions while rooting
                    continue;

                    // TODO: Log as a warning
                }

                // If this is not a generic definition, root all methods
                if (!type.HasInstantiation)
                {
                    RootMethods(type, "Library module method", rootProvider);
                }
            }
        }
Пример #6
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (TypeDesc type in _module.GetAllTypes())
            {
                // Skip delegates (since their Invoke methods have no IL) and uninstantiated generic types
                if (type.IsDelegate || type.ContainsGenericVariables)
                {
                    continue;
                }

                try
                {
                    rootProvider.AddCompilationRoot(type, "Library module type");
                }
                catch (TypeSystemException)
                {
                    // TODO: fail compilation if a switch was passed

                    // Swallow type load exceptions while rooting
                    continue;

                    // TODO: Log as a warning
                }

                RootMethods(type, "Library module method", rootProvider);
            }
        }
        private void AddCompilationRootsForMultifileLibrary(EcmaModule module)
        {
            foreach (TypeDesc type in module.GetAllTypes())
            {
                // Skip delegates (since their Invoke methods have no IL) and uninstantiated generic types
                if (type.IsDelegate || type.ContainsGenericVariables)
                {
                    continue;
                }

                _rootProvider.AddCompilationRoot(type, "Library module type");
                RootMethods(type, "Library module method");
            }
        }
Пример #8
0
 private void AddCompilationRootsForRuntimeExports(EcmaModule module)
 {
     foreach (var type in module.GetAllTypes())
     {
         foreach (var method in type.GetMethods())
         {
             if (method.HasCustomAttribute("System.Runtime", "RuntimeExportAttribute"))
             {
                 string exportName = ((EcmaMethod)method).GetAttributeStringValue("System.Runtime", "RuntimeExportAttribute");
                 AddCompilationRoot(method, "Runtime export", exportName);
             }
         }
     }
 }
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (var methodProfileInfo in _profileData.GetAllMethodProfileData())
            {
                if (!methodProfileInfo.Flags.HasFlag(MethodProfilingDataFlags.ExcludeHotMethodCode) &&
                    !methodProfileInfo.Flags.HasFlag(MethodProfilingDataFlags.ExcludeColdMethodCode))
                {
                    try
                    {
                        MethodDesc method = methodProfileInfo.Method;
                        CheckCanGenerateMethod(method);
                        rootProvider.AddCompilationRoot(method, "Profile triggered method");
                    }
                    catch (TypeSystemException)
                    {
                        // Individual methods can fail to load types referenced in their signatures.
                        // Skip them in library mode since they're not going to be callable.
                        continue;
                    }
                }
            }

            if (!_profileData.PartialNGen)
            {
                foreach (TypeDesc type in _module.GetAllTypes())
                {
                    try
                    {
                        rootProvider.AddCompilationRoot(type, "Library module type");
                    }
                    catch (TypeSystemException)
                    {
                        // Swallow type load exceptions while rooting
                        continue;
                    }

                    // If this is not a generic definition, root all methods
                    if (!type.HasInstantiation)
                    {
                        RootMethods(type, "Library module method", rootProvider);
                    }
                }
            }
        }
Пример #10
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (TypeDesc type in _module.GetAllTypes())
            {
                try
                {
                    rootProvider.AddCompilationRoot(type, "Library module type");
                }
                catch (TypeSystemException)
                {
                    // Swallow type load exceptions while rooting
                    continue;
                }

                // If this is not a generic definition, root all methods
                if (!type.HasInstantiation)
                {
                    RootMethods(type, "Library module method", rootProvider);
                }
            }
        }
Пример #11
0
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (var method in _profileData)
            {
                try
                {
                    // Validate that this method is fully instantiated
                    if (method.OwningType.IsGenericDefinition || method.OwningType.ContainsSignatureVariables())
                    {
                        continue;
                    }

                    if (method.IsGenericMethodDefinition)
                    {
                        continue;
                    }

                    bool containsSignatureVariables = false;
                    foreach (TypeDesc t in method.Instantiation)
                    {
                        if (t.IsGenericDefinition)
                        {
                            containsSignatureVariables = true;
                            break;
                        }

                        if (t.ContainsSignatureVariables())
                        {
                            containsSignatureVariables = true;
                            break;
                        }
                    }
                    if (containsSignatureVariables)
                    {
                        continue;
                    }

                    if (!CorInfoImpl.ShouldSkipCompilation(method))
                    {
                        CheckCanGenerateMethod(method);
                        rootProvider.AddCompilationRoot(method, "Profile triggered method");
                    }
                }
                catch (TypeSystemException)
                {
                    // Individual methods can fail to load types referenced in their signatures.
                    // Skip them in library mode since they're not going to be callable.
                    continue;
                }
            }

            if (!_profileDrivenPartialNGen)
            {
                foreach (MetadataType type in _module.GetAllTypes())
                {
                    MetadataType typeWithMethods = type;
                    if (type.HasInstantiation)
                    {
                        typeWithMethods = InstantiateIfPossible(type);
                        if (typeWithMethods == null)
                        {
                            continue;
                        }
                    }

                    RootMethods(typeWithMethods, "Library module method", rootProvider);
                }
            }
        }
        public void AddCompilationRoots(IRootingServiceProvider rootProvider)
        {
            foreach (var methodProfileInfo in _profileData.GetAllMethodProfileData())
            {
                if (!methodProfileInfo.Flags.HasFlag(MethodProfilingDataFlags.ExcludeHotMethodCode) &&
                    !methodProfileInfo.Flags.HasFlag(MethodProfilingDataFlags.ExcludeColdMethodCode))
                {
                    try
                    {
                        MethodDesc method = methodProfileInfo.Method;

                        // Validate that this method is fully instantiated
                        if (method.OwningType.IsGenericDefinition || method.OwningType.ContainsSignatureVariables())
                        {
                            continue;
                        }

                        if (method.IsGenericMethodDefinition)
                        {
                            continue;
                        }

                        bool containsSignatureVariables = false;
                        foreach (TypeDesc t in method.Instantiation)
                        {
                            if (t.IsGenericDefinition)
                            {
                                containsSignatureVariables = true;
                                break;
                            }

                            if (t.ContainsSignatureVariables())
                            {
                                containsSignatureVariables = true;
                                break;
                            }
                        }
                        if (containsSignatureVariables)
                        {
                            continue;
                        }

                        CheckCanGenerateMethod(method);
                        rootProvider.AddCompilationRoot(method, "Profile triggered method");
                    }
                    catch (TypeSystemException)
                    {
                        // Individual methods can fail to load types referenced in their signatures.
                        // Skip them in library mode since they're not going to be callable.
                        continue;
                    }
                }
            }

            if (!_profileData.PartialNGen)
            {
                foreach (MetadataType type in _module.GetAllTypes())
                {
                    try
                    {
                        rootProvider.AddCompilationRoot(type, "Library module type");
                    }
                    catch (TypeSystemException)
                    {
                        // Swallow type load exceptions while rooting
                        continue;
                    }

                    MetadataType typeWithMethods = type;
                    if (type.HasInstantiation)
                    {
                        typeWithMethods = InstantiateIfPossible(type);
                        if (typeWithMethods == null)
                        {
                            continue;
                        }
                    }

                    RootMethods(typeWithMethods, "Library module method", rootProvider);
                }
            }
        }