Skip to content

feat: Add disassembler support for macos #2781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ public IEnumerable<ValidationError> Validate(ValidationParameters validationPara
private static bool ShouldUseMonoDisassembler(BenchmarkCase benchmarkCase)
=> benchmarkCase.Job.Environment.Runtime is MonoRuntime || RuntimeInformation.IsMono;

// when we add macOS support, RuntimeInformation.IsMacOS() needs to be added here
private static bool ShouldUseClrMdDisassembler(BenchmarkCase benchmarkCase)
=> !ShouldUseMonoDisassembler(benchmarkCase) && (OsDetector.IsWindows() || OsDetector.IsLinux());
=> !ShouldUseMonoDisassembler(benchmarkCase) && (OsDetector.IsWindows() || OsDetector.IsLinux() || OsDetector.IsMacOS());

private static bool ShouldUseSameArchitectureDisassembler(BenchmarkCase benchmarkCase, DiagnoserActionParameters parameters)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,11 @@ public static IEnumerable<object[]> GetAllJits()
{
yield return new object[] { Jit.RyuJit, Platform.X64, CoreRuntime.Core80 }; // .NET Core x64
}
else if (RuntimeInformation.GetCurrentPlatform() is Platform.Arm64 && OsDetector.IsLinux())
else if (RuntimeInformation.GetCurrentPlatform() is Platform.Arm64)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This changes affects windows-11-arm tests also.

{
yield return new object[] { Jit.RyuJit, Platform.Arm64, CoreRuntime.Core80 }; // .NET Core arm64
}
}
if (OsDetector.IsMacOS())
{
// This scope of tests is not supported on macOS
// However, when the MemberData method provides no data, xUnit throws an "No data found" InvalidOperationException
// In order to fix the problem, we should provide at least one input data set
// All the tests check the OS on the first line and stop the test if it's macOS
yield return new object[] { Jit.Default, Platform.AnyCpu, CoreRuntime.Latest };
}

// we could add new object[] { Jit.Llvm, Platform.X64, new MonoRuntime() } here but our CI would need to have Mono installed..
}
Expand Down Expand Up @@ -92,8 +84,6 @@ public void Recursive()
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, Runtime runtime)
{
if (OsDetector.IsMacOS()) return; // currently not supported

var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));

Expand All @@ -111,8 +101,6 @@ public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, Runtime run
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform, Runtime runtime)
{
if (OsDetector.IsMacOS()) return; // currently not supported

var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 1, filters: new[] { "*WithCalls*" }));

Expand All @@ -136,8 +124,6 @@ public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform,
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleGenericTypes(Jit jit, Platform platform, Runtime runtime)
{
if (OsDetector.IsMacOS()) return; // currently not supported

var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));

Expand All @@ -158,8 +144,6 @@ [Benchmark] public void JustReturn() { }
[Trait(Constants.Category, Constants.BackwardCompatibilityCategory)]
public void CanDisassembleInlinableBenchmarks(Jit jit, Platform platform, Runtime runtime)
{
if (OsDetector.IsMacOS()) return; // currently not supported

var disassemblyDiagnoser = new DisassemblyDiagnoser(
new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3));

Expand Down