Helpers.AppendExpandedPaths(_referenceFilePaths, reference, false);
}
- private int Run()
+ private void ConfigureTarget()
{
- InitializeDefaultOptions();
-
- ProcessCommandLine();
-
- if (_commandLineOptions.OutputFilePath == null)
- throw new CommandLineException(SR.MissingOutputFile);
-
- if (_commandLineOptions.CustomPESectionAlignment != null)
- {
- int alignment = _commandLineOptions.CustomPESectionAlignment.Value;
- bool invalidArgument = false;
- if (alignment <= 4096)
- {
- invalidArgument = true;
- }
- if ((alignment & (alignment - 1)) != 0)
- {
- invalidArgument = true; // Alignment not power of two
- }
-
- if (invalidArgument)
- throw new CommandLineException(SR.InvalidCustomPESectionAlignment);
- }
-
//
// Set target Architecture and OS
//
else
throw new CommandLineException(SR.TargetOSUnsupported);
}
+ }
+ private InstructionSetSupport ConfigureInstructionSetSupport()
+ {
InstructionSetSupportBuilder instructionSetSupportBuilder = new InstructionSetSupportBuilder(_targetArchitecture);
// Ready to run images are built with certain instruction set baselines
optimisticInstructionSet.Remove(unsupportedInstructionSet);
optimisticInstructionSet.Add(supportedInstructionSet);
- var instructionSetSupport = new InstructionSetSupport(supportedInstructionSet,
+ return new InstructionSetSupport(supportedInstructionSet,
unsupportedInstructionSet,
optimisticInstructionSet,
InstructionSetSupportBuilder.GetNonSpecifiableInstructionSetsForArch(_targetArchitecture),
_targetArchitecture);
+ }
+ private void CheckCustomPESectionAlignment()
+ {
+ if (_commandLineOptions.CustomPESectionAlignment != null)
+ {
+ int alignment = _commandLineOptions.CustomPESectionAlignment.Value;
+ bool invalidArgument = false;
+ if (alignment < 4096)
+ {
+ invalidArgument = true;
+ }
+ if ((alignment & (alignment - 1)) != 0)
+ {
+ invalidArgument = true; // Alignment not power of two
+ }
+
+ if (invalidArgument)
+ throw new CommandLineException(SR.InvalidCustomPESectionAlignment);
+ }
+ }
+
+ private int Run()
+ {
using (PerfEventSource.StartStopEvents.CompilationEvents())
{
ICompilation compilation;
using (PerfEventSource.StartStopEvents.LoadingEvents())
{
+ InitializeDefaultOptions();
+
+ ProcessCommandLine();
+
+ if (_commandLineOptions.OutputFilePath == null)
+ throw new CommandLineException(SR.MissingOutputFile);
+
+ CheckCustomPESectionAlignment();
+ ConfigureTarget();
+ InstructionSetSupport instructionSetSupport = ConfigureInstructionSetSupport();
+
//
// Initialize type system context
//
public static async Task<int> Main(string[] args)
{
+ PerfEventSource.StartStopEvents.CommandLineProcessingStart();
var command = CommandLineOptions.RootCommand();
command.Handler = CommandHandler.Create<CommandLineOptions>((CommandLineOptions options) => InnerMain(options));
return await command.InvokeAsync(args);
private static int InnerMain(CommandLineOptions buildOptions)
{
+ PerfEventSource.StartStopEvents.CommandLineProcessingStop();
#if DEBUG
try
{
private ManualResetEvent _doneWarmup = new ManualResetEvent(false);
private ManualResetEvent _doneCompilation = new ManualResetEvent(false);
private const string providerName = "Microsoft-ILCompiler-Perf";
+ private const string graphProviderName = "Microsoft-ILCompiler-Graph-Perf";
private readonly int _totalRealRuns;
private int _doneCompilationCount = 0;
private int _doneWarmupCount = 0;
+ private double _commandlineParseMsec = 0;
private double _compilationMsec = 0;
private double _loadingMsec = 0;
private double _graphProcessingMsec = 0;
{
_totalRealRuns = totalRealRuns;
traceEventSession.EnableProvider(providerName, TraceEventLevel.Verbose);
+ traceEventSession.EnableProvider(graphProviderName, TraceEventLevel.Verbose);
traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "Compilation/Start", delegate (TraceEvent traceEvent)
{
// For all of the events below, we only want to process them after the warmup is complete. We can't just start this listener after
// we have started the warmup because those runs might take some time, and we don't want to erroneously process warmup events when
// trying to measure the real runs.
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "CommandLineProcessing/Start", delegate (TraceEvent traceEvent)
+ {
+ if (_doneWarmup.WaitOne(0))
+ _commandlineParseMsec -= traceEvent.TimeStampRelativeMSec;
+ });
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "CommandLineProcessing/Stop", delegate (TraceEvent traceEvent)
+ {
+ if (_doneWarmup.WaitOne(0))
+ _commandlineParseMsec += traceEvent.TimeStampRelativeMSec;
+ });
traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "Loading/Start", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
_loadingMsec += traceEvent.TimeStampRelativeMSec;
});
- traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "GraphProcessing/Start", delegate (TraceEvent traceEvent)
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(graphProviderName, "GraphProcessing/Start", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
_graphProcessingMsec -= traceEvent.TimeStampRelativeMSec;
});
- traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "GraphProcessing/Stop", delegate (TraceEvent traceEvent)
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(graphProviderName, "GraphProcessing/Stop", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
_graphProcessingMsec += traceEvent.TimeStampRelativeMSec;
});
- traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "DependencyAnalysis/Start", delegate (TraceEvent traceEvent)
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(graphProviderName, "DependencyAnalysis/Start", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
_dependencyAnalysisMsec -= traceEvent.TimeStampRelativeMSec;
});
- traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "DependencyAnalysis/Stop", delegate (TraceEvent traceEvent)
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(graphProviderName, "DependencyAnalysis/Stop", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
_dependencyAnalysisMsec += traceEvent.TimeStampRelativeMSec;
});
- traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(providerName, "AddedNodeToMarkStack", delegate (TraceEvent traceEvent)
+ traceEventSession.Source.Dynamic.AddCallbackForProviderEvent(graphProviderName, "AddedNodeToMarkStack", delegate (TraceEvent traceEvent)
{
if (_doneWarmup.WaitOne(0))
nodesAddedToMarkStack++;
{
_doneCompilation.WaitOne();
IndentedTextWriter writer = new IndentedTextWriter(Console.Out);
+ writer.WriteLine($"Command line processing time: {_commandlineParseMsec / _totalRealRuns:F2} ms");
writer.WriteLine($"Total average compilation time: {_compilationMsec / _totalRealRuns:F2} ms");
writer.WriteLine($"Phase breakdown (average):");
writer.Indent++;