Skip to content

Commit e457fe3

Browse files
Remove ReadyToRun prefix from image layout code (#115188)
This is now shared with native AOT.
1 parent 1ce95fb commit e457fe3

File tree

9 files changed

+68
-68
lines changed

9 files changed

+68
-68
lines changed
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace ILCompiler
2626
{
27-
public enum ReadyToRunMethodLayoutAlgorithm
27+
public enum MethodLayoutAlgorithm
2828
{
2929
DefaultSort,
3030
ExclusiveWeight,
@@ -37,17 +37,17 @@ public enum ReadyToRunMethodLayoutAlgorithm
3737
Random,
3838
}
3939

40-
public enum ReadyToRunFileLayoutAlgorithm
40+
public enum FileLayoutAlgorithm
4141
{
4242
DefaultSort,
4343
MethodOrder,
4444
}
4545

46-
class ReadyToRunFileLayoutOptimizer
46+
class FileLayoutOptimizer
4747
{
48-
public ReadyToRunFileLayoutOptimizer (Logger logger,
49-
ReadyToRunMethodLayoutAlgorithm methodAlgorithm,
50-
ReadyToRunFileLayoutAlgorithm fileAlgorithm,
48+
public FileLayoutOptimizer (Logger logger,
49+
MethodLayoutAlgorithm methodAlgorithm,
50+
FileLayoutAlgorithm fileAlgorithm,
5151
ProfileDataManager profileData,
5252
NodeFactory nodeFactory)
5353
{
@@ -59,14 +59,14 @@ public ReadyToRunFileLayoutOptimizer (Logger logger,
5959
}
6060

6161
private Logger _logger;
62-
private ReadyToRunMethodLayoutAlgorithm _methodLayoutAlgorithm = ReadyToRunMethodLayoutAlgorithm.DefaultSort;
63-
private ReadyToRunFileLayoutAlgorithm _fileLayoutAlgorithm = ReadyToRunFileLayoutAlgorithm.DefaultSort;
62+
private MethodLayoutAlgorithm _methodLayoutAlgorithm = MethodLayoutAlgorithm.DefaultSort;
63+
private FileLayoutAlgorithm _fileLayoutAlgorithm = FileLayoutAlgorithm.DefaultSort;
6464
private ProfileDataManager _profileData;
6565
private NodeFactory _nodeFactory;
6666

6767
public ImmutableArray<DependencyNodeCore<NodeFactory>> ApplyProfilerGuidedMethodSort(ImmutableArray<DependencyNodeCore<NodeFactory>> nodes)
6868
{
69-
if (_methodLayoutAlgorithm == ReadyToRunMethodLayoutAlgorithm.DefaultSort)
69+
if (_methodLayoutAlgorithm == MethodLayoutAlgorithm.DefaultSort)
7070
return nodes;
7171

7272
List<MethodWithGCInfo> methods = new List<MethodWithGCInfo>();
@@ -97,7 +97,7 @@ public ImmutableArray<DependencyNodeCore<NodeFactory>> ApplyProfilerGuidedMethod
9797
sortOrder++;
9898
}
9999

100-
if (_fileLayoutAlgorithm == ReadyToRunFileLayoutAlgorithm.MethodOrder)
100+
if (_fileLayoutAlgorithm == FileLayoutAlgorithm.MethodOrder)
101101
{
102102
// Sort the dependencies of methods by the method order
103103
foreach (var method in sortedMethodsList)
@@ -132,10 +132,10 @@ private List<MethodWithGCInfo> ApplyMethodSort(List<MethodWithGCInfo> methods)
132132
{
133133
switch (_methodLayoutAlgorithm)
134134
{
135-
case ReadyToRunMethodLayoutAlgorithm.DefaultSort:
135+
case MethodLayoutAlgorithm.DefaultSort:
136136
break;
137137

138-
case ReadyToRunMethodLayoutAlgorithm.ExclusiveWeight:
138+
case MethodLayoutAlgorithm.ExclusiveWeight:
139139
methods.MergeSortAllowDuplicates(sortMethodWithGCInfoByWeight);
140140

141141
int sortMethodWithGCInfoByWeight(MethodWithGCInfo left, MethodWithGCInfo right)
@@ -144,7 +144,7 @@ int sortMethodWithGCInfoByWeight(MethodWithGCInfo left, MethodWithGCInfo right)
144144
}
145145
break;
146146

147-
case ReadyToRunMethodLayoutAlgorithm.HotCold:
147+
case MethodLayoutAlgorithm.HotCold:
148148
methods.MergeSortAllowDuplicates((MethodWithGCInfo left, MethodWithGCInfo right) => ComputeHotColdRegion(left).CompareTo(ComputeHotColdRegion(right)));
149149

150150
int ComputeHotColdRegion(MethodWithGCInfo method)
@@ -153,7 +153,7 @@ int ComputeHotColdRegion(MethodWithGCInfo method)
153153
}
154154
break;
155155

156-
case ReadyToRunMethodLayoutAlgorithm.HotWarmCold:
156+
case MethodLayoutAlgorithm.HotWarmCold:
157157
methods.MergeSortAllowDuplicates((MethodWithGCInfo left, MethodWithGCInfo right) => ComputeHotWarmColdRegion(left).CompareTo(ComputeHotWarmColdRegion(right)));
158158

159159
int ComputeHotWarmColdRegion(MethodWithGCInfo method)
@@ -175,16 +175,16 @@ int ComputeHotWarmColdRegion(MethodWithGCInfo method)
175175
break;
176176

177177
#if READYTORUN
178-
case ReadyToRunMethodLayoutAlgorithm.CallFrequency:
178+
case MethodLayoutAlgorithm.CallFrequency:
179179
methods = MethodCallFrequencySort(methods);
180180
break;
181181
#endif
182182

183-
case ReadyToRunMethodLayoutAlgorithm.PettisHansen:
183+
case MethodLayoutAlgorithm.PettisHansen:
184184
methods = PettisHansenSort(methods);
185185
break;
186186

187-
case ReadyToRunMethodLayoutAlgorithm.Random:
187+
case MethodLayoutAlgorithm.Random:
188188
Random rand = new Random(0);
189189
for (int i = 0; i < methods.Count - 1; i++)
190190
{

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public sealed class ReadyToRunCodegenCompilation : Compilation
294294
private readonly Func<MethodDesc, string> _printReproInstructions;
295295

296296
private readonly ProfileDataManager _profileData;
297-
private readonly ReadyToRunFileLayoutOptimizer _fileLayoutOptimizer;
297+
private readonly FileLayoutOptimizer _fileLayoutOptimizer;
298298
private readonly HashSet<EcmaMethod> _methodsWhichNeedMutableILBodies = new HashSet<EcmaMethod>();
299299
private readonly HashSet<MethodWithGCInfo> _methodsToRecompile = new HashSet<MethodWithGCInfo>();
300300

@@ -334,8 +334,8 @@ internal ReadyToRunCodegenCompilation(
334334
bool generateProfileFile,
335335
int parallelism,
336336
ProfileDataManager profileData,
337-
ReadyToRunMethodLayoutAlgorithm methodLayoutAlgorithm,
338-
ReadyToRunFileLayoutAlgorithm fileLayoutAlgorithm,
337+
MethodLayoutAlgorithm methodLayoutAlgorithm,
338+
FileLayoutAlgorithm fileLayoutAlgorithm,
339339
int customPESectionAlignment,
340340
bool verifyTypeAndFieldLayout)
341341
: base(
@@ -379,7 +379,7 @@ internal ReadyToRunCodegenCompilation(
379379

380380
_profileData = profileData;
381381

382-
_fileLayoutOptimizer = new ReadyToRunFileLayoutOptimizer(logger, methodLayoutAlgorithm, fileLayoutAlgorithm, profileData, _nodeFactory);
382+
_fileLayoutOptimizer = new FileLayoutOptimizer(logger, methodLayoutAlgorithm, fileLayoutAlgorithm, profileData, _nodeFactory);
383383
}
384384

385385
private readonly static string s_folderUpPrefix = ".." + Path.DirectorySeparatorChar;

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public sealed class ReadyToRunCodegenCompilationBuilder : CompilationBuilder
3535
Func<MethodDesc, string> _printReproInstructions;
3636
private InstructionSetSupport _instructionSetSupport;
3737
private ProfileDataManager _profileData;
38-
private ReadyToRunMethodLayoutAlgorithm _r2rMethodLayoutAlgorithm;
39-
private ReadyToRunFileLayoutAlgorithm _r2rFileLayoutAlgorithm;
38+
private MethodLayoutAlgorithm _r2rMethodLayoutAlgorithm;
39+
private FileLayoutAlgorithm _r2rFileLayoutAlgorithm;
4040
private int _customPESectionAlignment;
4141
private bool _verifyTypeAndFieldLayout;
4242
private bool _hotColdSplitting;
@@ -119,7 +119,7 @@ public ReadyToRunCodegenCompilationBuilder UseProfileData(ProfileDataManager pro
119119
return this;
120120
}
121121

122-
public ReadyToRunCodegenCompilationBuilder FileLayoutAlgorithms(ReadyToRunMethodLayoutAlgorithm r2rMethodLayoutAlgorithm, ReadyToRunFileLayoutAlgorithm r2rFileLayoutAlgorithm)
122+
public ReadyToRunCodegenCompilationBuilder FileLayoutAlgorithms(MethodLayoutAlgorithm r2rMethodLayoutAlgorithm, FileLayoutAlgorithm r2rFileLayoutAlgorithm)
123123
{
124124
_r2rMethodLayoutAlgorithm = r2rMethodLayoutAlgorithm;
125125
_r2rFileLayoutAlgorithm = r2rFileLayoutAlgorithm;

src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@
261261
<Compile Include="Compiler\ReadyToRunCompilerContext.cs" />
262262
<Compile Include="Compiler\ReadyToRunCodegenCompilation.cs" />
263263
<Compile Include="Compiler\ReadyToRunCodegenCompilationBuilder.cs" />
264-
<Compile Include="Compiler\ReadyToRunFileLayoutOptimizer.cs" />
264+
<Compile Include="Compiler\FileLayoutOptimizer.cs" />
265265
<Compile Include="Compiler\ReadyToRunMetadataFieldLayoutAlgorithm.cs" />
266266
<Compile Include="Compiler\ReadyToRunSingleAssemblyCompilationModuleGroup.cs" />
267267
<Compile Include="Compiler\ReadyToRunStandaloneMethodMetadata.cs" />

src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public sealed class RyuJitCompilation : Compilation
2525
private readonly ConditionalWeakTable<Thread, CorInfoImpl> _corinfos = new ConditionalWeakTable<Thread, CorInfoImpl>();
2626
internal readonly RyuJitCompilationOptions _compilationOptions;
2727
private readonly ProfileDataManager _profileDataManager;
28-
private readonly ReadyToRunFileLayoutOptimizer _fileLayoutOptimizer;
28+
private readonly FileLayoutOptimizer _fileLayoutOptimizer;
2929
private readonly MethodImportationErrorProvider _methodImportationErrorProvider;
3030
private readonly ReadOnlyFieldPolicy _readOnlyFieldPolicy;
3131
private readonly int _parallelism;
@@ -45,8 +45,8 @@ internal RyuJitCompilation(
4545
MethodImportationErrorProvider errorProvider,
4646
ReadOnlyFieldPolicy readOnlyFieldPolicy,
4747
RyuJitCompilationOptions options,
48-
ReadyToRunMethodLayoutAlgorithm methodLayoutAlgorithm,
49-
ReadyToRunFileLayoutAlgorithm fileLayoutAlgorithm,
48+
MethodLayoutAlgorithm methodLayoutAlgorithm,
49+
FileLayoutAlgorithm fileLayoutAlgorithm,
5050
int parallelism)
5151
: base(dependencyGraph, nodeFactory, roots, ilProvider, debugInformationProvider, inliningPolicy, logger)
5252
{
@@ -61,7 +61,7 @@ internal RyuJitCompilation(
6161

6262
_parallelism = parallelism;
6363

64-
_fileLayoutOptimizer = new ReadyToRunFileLayoutOptimizer(logger, methodLayoutAlgorithm, fileLayoutAlgorithm, profileDataManager, nodeFactory);
64+
_fileLayoutOptimizer = new FileLayoutOptimizer(logger, methodLayoutAlgorithm, fileLayoutAlgorithm, profileDataManager, nodeFactory);
6565
}
6666

6767
public ProfileDataManager ProfileData => _profileDataManager;

src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilationBuilder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public sealed class RyuJitCompilationBuilder : CompilationBuilder
1717
// These need to provide reasonable defaults so that the user can optionally skip
1818
// calling the Use/Configure methods and still get something reasonable back.
1919
private KeyValuePair<string, string>[] _ryujitOptions = Array.Empty<KeyValuePair<string, string>>();
20-
private ReadyToRunMethodLayoutAlgorithm _methodLayoutAlgorithm;
21-
private ReadyToRunFileLayoutAlgorithm _fileLayoutAlgorithm;
20+
private MethodLayoutAlgorithm _methodLayoutAlgorithm;
21+
private FileLayoutAlgorithm _fileLayoutAlgorithm;
2222
private ILProvider _ilProvider = new NativeAotILProvider();
2323
private ProfileDataManager _profileDataManager;
2424
private string _jitPath;
@@ -41,7 +41,7 @@ public RyuJitCompilationBuilder UseJitPath(string jitPath)
4141
return this;
4242
}
4343

44-
public RyuJitCompilationBuilder FileLayoutAlgorithms(ReadyToRunMethodLayoutAlgorithm methodLayoutAlgorithm, ReadyToRunFileLayoutAlgorithm fileLayoutAlgorithm)
44+
public RyuJitCompilationBuilder FileLayoutAlgorithms(MethodLayoutAlgorithm methodLayoutAlgorithm, FileLayoutAlgorithm fileLayoutAlgorithm)
4545
{
4646
_methodLayoutAlgorithm = methodLayoutAlgorithm;
4747
_fileLayoutAlgorithm = fileLayoutAlgorithm;

src/coreclr/tools/aot/ILCompiler.RyuJit/ILCompiler.RyuJit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@
102102
<Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\CallGraphNode.cs" Link="Compiler\PettisHansenSort\CallGraphNode.cs" />
103103
<Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\DisjointSetForest.cs" Link="Compiler\PettisHansenSort\DisjointSetForest.cs" />
104104
<Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\PettisHansen.cs" Link="Compiler\PettisHansenSort\PettisHansen.cs" />
105-
<Compile Include="..\ILCompiler.ReadyToRun\Compiler\ReadyToRunFileLayoutOptimizer.cs" Link="Compiler\ReadyToRunFileLayoutOptimizer.cs" />
105+
<Compile Include="..\ILCompiler.ReadyToRun\Compiler\FileLayoutOptimizer.cs" Link="Compiler\FileLayoutOptimizer.cs" />
106106
</ItemGroup>
107107
</Project>

src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ internal sealed class ILCompilerRootCommand : RootCommand
2727
new("--optimize-time", "--Ot") { Description = "Enable optimizations, favor code speed" };
2828
public Option<string[]> MibcFilePaths { get; } =
2929
new("--mibc", "-m") { DefaultValueFactory = _ => Array.Empty<string>(), Description = "Mibc file(s) for profile guided optimization" };
30-
public Option<ReadyToRunMethodLayoutAlgorithm> MethodLayout { get; } =
31-
new("--method-layout") { CustomParser = MakeReadyToRunMethodLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunMethodLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging methods in a file.", HelpName = "arg" };
32-
public Option<ReadyToRunFileLayoutAlgorithm> FileLayout { get; } =
33-
new("--file-layout") { CustomParser = MakeReadyToRunFileLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunFileLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging non-method contents in a file.", HelpName = "arg" };
30+
public Option<MethodLayoutAlgorithm> MethodLayout { get; } =
31+
new("--method-layout") { CustomParser = MakeMethodLayoutAlgorithm, DefaultValueFactory = MakeMethodLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging methods in a file.", HelpName = "arg" };
32+
public Option<FileLayoutAlgorithm> FileLayout { get; } =
33+
new("--file-layout") { CustomParser = MakeFileLayoutAlgorithm, DefaultValueFactory = MakeFileLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging non-method contents in a file.", HelpName = "arg" };
3434
public Option<string[]> SatelliteFilePaths { get; } =
3535
new("--satellite") { DefaultValueFactory = _ => Array.Empty<string>(), Description = "Satellite assemblies associated with inputs/references" };
3636
public Option<bool> EnableDebugInfo { get; } =
@@ -417,32 +417,32 @@ private static int MakeParallelism(ArgumentResult result)
417417
return parallelism;
418418
}
419419

420-
private static ReadyToRunMethodLayoutAlgorithm MakeReadyToRunMethodLayoutAlgorithm(ArgumentResult result)
420+
private static MethodLayoutAlgorithm MakeMethodLayoutAlgorithm(ArgumentResult result)
421421
{
422422
if (result.Tokens.Count == 0)
423-
return ReadyToRunMethodLayoutAlgorithm.DefaultSort;
423+
return MethodLayoutAlgorithm.DefaultSort;
424424

425425
return result.Tokens[0].Value.ToLowerInvariant() switch
426426
{
427-
"defaultsort" => ReadyToRunMethodLayoutAlgorithm.DefaultSort,
428-
"exclusiveweight" => ReadyToRunMethodLayoutAlgorithm.ExclusiveWeight,
429-
"hotcold" => ReadyToRunMethodLayoutAlgorithm.HotCold,
430-
"hotwarmcold" => ReadyToRunMethodLayoutAlgorithm.HotWarmCold,
431-
"pettishansen" => ReadyToRunMethodLayoutAlgorithm.PettisHansen,
432-
"random" => ReadyToRunMethodLayoutAlgorithm.Random,
427+
"defaultsort" => MethodLayoutAlgorithm.DefaultSort,
428+
"exclusiveweight" => MethodLayoutAlgorithm.ExclusiveWeight,
429+
"hotcold" => MethodLayoutAlgorithm.HotCold,
430+
"hotwarmcold" => MethodLayoutAlgorithm.HotWarmCold,
431+
"pettishansen" => MethodLayoutAlgorithm.PettisHansen,
432+
"random" => MethodLayoutAlgorithm.Random,
433433
_ => throw new CommandLineException(result.Tokens[0].Value)
434434
};
435435
}
436436

437-
private static ReadyToRunFileLayoutAlgorithm MakeReadyToRunFileLayoutAlgorithm(ArgumentResult result)
437+
private static FileLayoutAlgorithm MakeFileLayoutAlgorithm(ArgumentResult result)
438438
{
439439
if (result.Tokens.Count == 0)
440-
return ReadyToRunFileLayoutAlgorithm.DefaultSort;
440+
return FileLayoutAlgorithm.DefaultSort;
441441

442442
return result.Tokens[0].Value.ToLowerInvariant() switch
443443
{
444-
"defaultsort" => ReadyToRunFileLayoutAlgorithm.DefaultSort,
445-
"methodorder" => ReadyToRunFileLayoutAlgorithm.MethodOrder,
444+
"defaultsort" => FileLayoutAlgorithm.DefaultSort,
445+
"methodorder" => FileLayoutAlgorithm.MethodOrder,
446446
_ => throw new CommandLineException(result.Tokens[0].Value)
447447
};
448448
}

0 commit comments

Comments
 (0)