Exemple #1
0
 /// <summary>
 /// Set up compilation group needed for proper calculation of base class alignment in auto layout.
 /// </summary>
 /// <param name="compilationGroup"></param>
 public void SetCompilationGroup(ReadyToRunCompilationModuleGroupBase compilationGroup)
 {
     _compilationGroup = compilationGroup;
 }
        public ProfileDataManager(Logger logger,
                                  IEnumerable <ModuleDesc> possibleReferenceModules,
                                  IEnumerable <ModuleDesc> inputModules,
                                  IEnumerable <ModuleDesc> versionBubbleModules,
                                  ModuleDesc nonLocalGenericsHome,
                                  IReadOnlyList <string> mibcFiles,
                                  CompilerTypeSystemContext context,
                                  ReadyToRunCompilationModuleGroupBase compilationGroup)
        {
            _ibcParser        = new IBCProfileParser(logger, possibleReferenceModules);
            _compilationGroup = compilationGroup;
            HashSet <ModuleDesc> versionBubble = new HashSet <ModuleDesc>(versionBubbleModules);

            {
                // Parse MIbc Data

                string onlyParseItemsDefinedInAssembly = nonLocalGenericsHome == null?inputModules.First().Assembly.GetName().Name : null;

                HashSet <string> versionBubbleModuleStrings = new HashSet <string>();
                foreach (ModuleDesc versionBubbleModule in versionBubble)
                {
                    versionBubbleModuleStrings.Add(versionBubbleModule.Assembly.GetName().Name);
                }

                foreach (string file in mibcFiles)
                {
                    _inputData.Add(MIbcProfileParser.ParseMIbcFile(context, file, versionBubbleModuleStrings, onlyParseItemsDefinedInAssembly));
                }
            }

            {
                // Parse Ibc data
                foreach (var module in inputModules)
                {
                    _inputData.Add(_ibcParser.ParseIBCDataFromModule((EcmaModule)module));
                    _placedProfileMethods.Add(module, new HashSet <MethodDesc>());
                }
            }

            // Merge all data together
            foreach (ProfileData profileData in _inputData)
            {
                MergeProfileData(ref _partialNGen, _mergedProfileData, profileData);
            }

            // With the merged data find the set of methods to be placed within this module
            foreach (var profileData in _mergedProfileData)
            {
                // If the method is not excluded from processing
                if (!profileData.Value.Flags.HasFlag(MethodProfilingDataFlags.ExcludeHotMethodCode) &&
                    !profileData.Value.Flags.HasFlag(MethodProfilingDataFlags.ExcludeColdMethodCode))
                {
                    // Check for methods which are defined within the version bubble, and only rely on other modules within the bubble
                    if (!_compilationGroup.VersionsWithMethodBody(profileData.Key))
                    {
                        continue; // Method not contained within version bubble
                    }
                    if (_compilationGroup.ContainsType(profileData.Key.OwningType) &&
                        (profileData.Key.OwningType is MetadataType declaringType))
                    {
                        // In this case the method is placed in its natural home (which is the defining module of the method)
                        _placedProfileMethods[declaringType.Module].Add(profileData.Key);
                        _placedProfileMethodsAll.Add(profileData.Key);
                    }
                    else
                    {
                        // If the defining module is not within the input set, if the nonLocalGenericsHome is provided, place it there
                        if ((nonLocalGenericsHome != null) && (profileData.Key.GetTypicalMethodDefinition() != profileData.Key))
                        {
                            _placedProfileMethods[nonLocalGenericsHome].Add(profileData.Key);
                            _placedProfileMethodsAll.Add(profileData.Key);
                        }
                    }
                }
            }
        }
Exemple #3
0
        internal ReadyToRunCodegenCompilation(
            DependencyAnalyzerBase <NodeFactory> dependencyGraph,
            NodeFactory nodeFactory,
            IEnumerable <ICompilationRootProvider> roots,
            ILProvider ilProvider,
            Logger logger,
            DevirtualizationManager devirtualizationManager,
            IEnumerable <string> inputFiles,
            string compositeRootPath,
            InstructionSetSupport instructionSetSupport,
            bool resilient,
            bool generateMapFile,
            bool generateMapCsvFile,
            bool generatePdbFile,
            Func <MethodDesc, string> printReproInstructions,
            string pdbPath,
            bool generatePerfMapFile,
            string perfMapPath,
            int perfMapFormatVersion,
            bool generateProfileFile,
            int parallelism,
            ProfileDataManager profileData,
            ReadyToRunMethodLayoutAlgorithm methodLayoutAlgorithm,
            ReadyToRunFileLayoutAlgorithm fileLayoutAlgorithm,
            int customPESectionAlignment,
            bool verifyTypeAndFieldLayout)
            : base(
                dependencyGraph,
                nodeFactory,
                roots,
                ilProvider,
                devirtualizationManager,
                modulesBeingInstrumented: nodeFactory.CompilationModuleGroup.CompilationModuleSet,
                logger,
                instructionSetSupport)
        {
            _resilient                = resilient;
            _parallelism              = parallelism;
            _generateMapFile          = generateMapFile;
            _generateMapCsvFile       = generateMapCsvFile;
            _generatePdbFile          = generatePdbFile;
            _pdbPath                  = pdbPath;
            _generatePerfMapFile      = generatePerfMapFile;
            _perfMapPath              = perfMapPath;
            _perfMapFormatVersion     = perfMapFormatVersion;
            _generateProfileFile      = generateProfileFile;
            _customPESectionAlignment = customPESectionAlignment;
            SymbolNodeFactory         = new ReadyToRunSymbolNodeFactory(nodeFactory, verifyTypeAndFieldLayout);
            if (nodeFactory.InstrumentationDataTable != null)
            {
                nodeFactory.InstrumentationDataTable.Initialize(SymbolNodeFactory);
            }
            _corInfoImpls           = new ConditionalWeakTable <Thread, CorInfoImpl>();
            _inputFiles             = inputFiles;
            _compositeRootPath      = compositeRootPath;
            _printReproInstructions = printReproInstructions;
            CompilationModuleGroup  = (ReadyToRunCompilationModuleGroupBase)nodeFactory.CompilationModuleGroup;

            // Generate baseline support specification for InstructionSetSupport. This will prevent usage of the generated
            // code if the runtime environment doesn't support the specified instruction set
            string instructionSetSupportString = ReadyToRunInstructionSetSupportSignature.ToInstructionSetSupportString(instructionSetSupport);
            ReadyToRunInstructionSetSupportSignature instructionSetSupportSig = new ReadyToRunInstructionSetSupportSignature(instructionSetSupportString);

            _dependencyGraph.AddRoot(new Import(NodeFactory.EagerImports, instructionSetSupportSig), "Baseline instruction set support");

            _profileData = profileData;

            _fileLayoutOptimizer = new ReadyToRunFileLayoutOptimizer(logger, methodLayoutAlgorithm, fileLayoutAlgorithm, profileData, _nodeFactory);
        }
 public void SetCompilationGroup(ReadyToRunCompilationModuleGroupBase compilationModuleGroup)
 {
     _r2rFieldLayoutAlgorithm.SetCompilationGroup(compilationModuleGroup);
 }