Skip to content

Commit

Permalink
Add JitDisasmWithGC option
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Dec 1, 2024
1 parent db25626 commit a60c673
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Runner/Helpers/JitDiffUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ private static async Task RunJitDiffAsync(JobBase job, string coreRootFolder, st
bool debugInfo = job.TryGetFlag("debuginfo");
bool gcInfo = job.TryGetFlag("gcinfo");

List<(string, string)> envVars = [];

if (job.TryGetFlag("JitDisasmWithGC"))
{
envVars.Add(("DOTNET_JitDisasmWithGC", "1"));
}

await job.RunProcessAsync("jitutils/bin/jit-diff",
$"diff " +
(debugInfo ? "--debuginfo " : "") +
Expand All @@ -35,7 +42,8 @@ await job.RunProcessAsync("jitutils/bin/jit-diff",
$"{frameworksOrAssembly} --pmi " +
$"--core_root {coreRootFolder} " +
$"--base {checkedClrFolder}",
logPrefix: $"jit-diff {coreRootFolder}");
logPrefix: $"jit-diff {coreRootFolder}",
envVars: envVars);
}

public static async Task<string> RunJitAnalyzeAsync(JobBase job, string mainDirectory, string prDirectory, int count = 100)
Expand Down
21 changes: 16 additions & 5 deletions Runner/JobBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public async Task<int> RunProcessAsync(
bool suppressOutputLogs = false,
bool suppressStartingLog = false,
ProcessPriorityClass priority = ProcessPriorityClass.Normal,
List<(string, string)>? envVars = null,
CancellationToken cancellationToken = default)
{
processLogs ??= i => i;
Expand All @@ -334,14 +335,24 @@ public async Task<int> RunProcessAsync(
await LogAsync($"{logPrefix}{processLogs($"Running '{fileName} {arguments}'{(workDir is null ? null : $" from '{workDir}'")}")}");
}

using var process = new Process
var startInfo = new ProcessStartInfo(fileName, arguments)
{
RedirectStandardError = true,
RedirectStandardOutput = true,
WorkingDirectory = workDir ?? string.Empty,
};

if (envVars is not null)
{
StartInfo = new ProcessStartInfo(fileName, arguments)
foreach ((string key, string value) in envVars)
{
RedirectStandardError = true,
RedirectStandardOutput = true,
WorkingDirectory = workDir ?? string.Empty,
startInfo.EnvironmentVariables.Add(key, value);
}
}

using var process = new Process
{
StartInfo = startInfo
};

using var cts = CancellationTokenSource.CreateLinkedTokenSource(JobTimeout, cancellationToken);
Expand Down

0 comments on commit a60c673

Please sign in to comment.