public ReadyToRunRootProvider(EcmaModule module, ProfileDataManager profileDataManager) { _module = module; _profileData = profileDataManager.GetDataForModuleDesc(module); }
private void MergeProfileData(ref bool partialNgen, Dictionary <MethodDesc, MethodProfileData> mergedProfileData, ProfileData profileData) { if (profileData.PartialNGen) { partialNgen = true; } foreach (MethodProfileData data in profileData.GetAllMethodProfileData()) { MethodProfileData dataToMerge; if (mergedProfileData.TryGetValue(data.Method, out dataToMerge)) { mergedProfileData[data.Method] = new MethodProfileData(data.Method, dataToMerge.Flags | data.Flags, dataToMerge.ScenarioMask | data.ScenarioMask); } else { mergedProfileData.Add(data.Method, data); } } }
public static void MergeProfileData(ref bool partialNgen, Dictionary <MethodDesc, MethodProfileData> mergedProfileData, ProfileData profileData) { if (profileData.PartialNGen) { partialNgen = true; } PgoSchemaElem[][] schemaElemMergerArray = new PgoSchemaElem[2][]; foreach (MethodProfileData data in profileData.GetAllMethodProfileData()) { MethodProfileData dataToMerge; if (mergedProfileData.TryGetValue(data.Method, out dataToMerge)) { var mergedCallWeights = data.CallWeights; if (mergedCallWeights == null) { mergedCallWeights = dataToMerge.CallWeights; } else if (dataToMerge.CallWeights != null) { mergedCallWeights = new Dictionary <MethodDesc, int>(data.CallWeights); foreach (var entry in dataToMerge.CallWeights) { if (mergedCallWeights.TryGetValue(entry.Key, out var initialWeight)) { mergedCallWeights[entry.Key] = initialWeight + entry.Value; } else { mergedCallWeights[entry.Key] = entry.Value; } } } PgoSchemaElem[] mergedSchemaData; if (data.SchemaData == null) { mergedSchemaData = dataToMerge.SchemaData; } else if (dataToMerge.SchemaData == null) { mergedSchemaData = data.SchemaData; } else { // Actually merge schemaElemMergerArray[0] = dataToMerge.SchemaData; schemaElemMergerArray[1] = data.SchemaData; mergedSchemaData = PgoProcessor.Merge <TypeSystemEntityOrUnknown, TypeSystemEntityOrUnknown>(schemaElemMergerArray); } mergedProfileData[data.Method] = new MethodProfileData(data.Method, dataToMerge.Flags | data.Flags, data.ExclusiveWeight + dataToMerge.ExclusiveWeight, mergedCallWeights, dataToMerge.ScenarioMask | data.ScenarioMask, mergedSchemaData); } else { mergedProfileData.Add(data.Method, data); } } }
public ProfileDataManager(Logger logger, IEnumerable <ModuleDesc> possibleReferenceModules, IEnumerable <ModuleDesc> inputModules, IEnumerable <ModuleDesc> versionBubbleModules, ModuleDesc nonLocalGenericsHome, IReadOnlyList <string> mibcFiles, CallChainProfile callChainProfile, CompilerTypeSystemContext context, ReadyToRunCompilationModuleGroupBase compilationGroup, bool embedPgoDataInR2RImage) { EmbedPgoDataInR2RImage = embedPgoDataInR2RImage; _ibcParser = new IBCProfileParser(logger, possibleReferenceModules); _compilationGroup = compilationGroup; _callChainProfile = callChainProfile; HashSet <ModuleDesc> versionBubble = new HashSet <ModuleDesc>(versionBubbleModules); { // Parse MIbc Data string onlyParseItemsDefinedInAssembly = null; if (nonLocalGenericsHome == null && !compilationGroup.IsCompositeBuildMode) { onlyParseItemsDefinedInAssembly = inputModules.First().Assembly.GetName().Name; } HashSet <string> versionBubbleModuleStrings = new HashSet <string>(); foreach (ModuleDesc versionBubbleModule in versionBubble) { versionBubbleModuleStrings.Add(versionBubbleModule.Assembly.GetName().Name); } foreach (string file in mibcFiles) { using (PEReader peReader = MIbcProfileParser.OpenMibcAsPEReader(file)) { _inputData.Add(MIbcProfileParser.ParseMIbcFile(context, peReader, 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) { ProfileData.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); } } } } }
private void MergeProfileData(ref bool partialNgen, Dictionary <MethodDesc, MethodProfileData> mergedProfileData, ProfileData profileData) { if (profileData.PartialNGen) { partialNgen = true; } foreach (MethodProfileData data in profileData.GetAllMethodProfileData()) { MethodProfileData dataToMerge; if (mergedProfileData.TryGetValue(data.Method, out dataToMerge)) { var mergedCallWeights = data.CallWeights; if (mergedCallWeights == null) { mergedCallWeights = dataToMerge.CallWeights; } else if (dataToMerge.CallWeights != null) { mergedCallWeights = new Dictionary <MethodDesc, int>(data.CallWeights); foreach (var entry in dataToMerge.CallWeights) { if (mergedCallWeights.TryGetValue(entry.Key, out var initialWeight)) { mergedCallWeights[entry.Key] = initialWeight + entry.Value; } else { mergedCallWeights[entry.Key] = entry.Value; } } } mergedProfileData[data.Method] = new MethodProfileData(data.Method, dataToMerge.Flags | data.Flags, data.ExclusiveWeight + dataToMerge.ExclusiveWeight, mergedCallWeights, dataToMerge.ScenarioMask | data.ScenarioMask); } else { mergedProfileData.Add(data.Method, data); } } }