Skip to content

Commit

Permalink
Update to latest Iced (#1502)
Browse files Browse the repository at this point in the history
* Update BenchmarkDotNet.Disassembler.x64.csproj

* Update BenchmarkDotNet.Disassembler.x86.csproj

* Update BenchmarkDotNet.csproj

* Replace obsoletes
  • Loading branch information
Symbai authored Jul 18, 2020
1 parent 13ee8be commit b356ac8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RootNamespace>BenchmarkDotNet.Disassembler</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Iced" Version="1.7.0" />
<PackageReference Include="Iced" Version="1.8.0" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="1.1.126102" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Compile Include="..\BenchmarkDotNet.Disassembler.x64\Program.cs" Link="Program.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Iced" Version="1.7.0" />
<PackageReference Include="Iced" Version="1.8.0" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="1.1.126102" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.4.3" />
<PackageReference Include="Iced" Version="1.4.0" />
<PackageReference Include="Iced" Version="1.8.0" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="1.1.126102" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.5.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Disassemblers/DisassemblyDiagnoser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private static IEnumerable<IExporter> GetExporters(Dictionary<BenchmarkCase, Dis
}

private static long SumNativeCodeSize(DisassemblyResult disassembly)
=> disassembly.Methods.Sum(method => method.Maps.Sum(map => map.SourceCodes.OfType<Asm>().Sum(asm => asm.Instruction.ByteLength)));
=> disassembly.Methods.Sum(method => method.Maps.Sum(map => map.SourceCodes.OfType<Asm>().Sum(asm => asm.Instruction.Length)));

private class NativeCodeSizeMetricDescriptor : IMetricDescriptor
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ internal Formatter GetFormatterWithSymbolSolver(IReadOnlyDictionary<ulong, strin
switch (Formatter)
{
case MasmFormatter masmFormatter:
return new MasmFormatter(masmFormatter.MasmOptions, symbolSolver);
return new MasmFormatter(masmFormatter.Options, symbolSolver);
case NasmFormatter nasmFormatter:
return new NasmFormatter(nasmFormatter.NasmOptions, symbolSolver);
return new NasmFormatter(nasmFormatter.Options, symbolSolver);
case GasFormatter gasFormatter:
return new GasFormatter(gasFormatter.GasOptions, symbolSolver);
return new GasFormatter(gasFormatter.Options, symbolSolver);
case IntelFormatter intelFormatter:
return new IntelFormatter(intelFormatter.IntelOptions, symbolSolver);
return new IntelFormatter(intelFormatter.Options, symbolSolver);
default:
// we don't know how to translate it so we just return the original one
// it's better not to solve symbols rather than throw exception ;)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal static void Export(ILogger logger, DisassemblyResult disassemblyResult,
{
checked
{
totalSizeInBytes += (uint)asm.Instruction.ByteLength;
totalSizeInBytes += (uint)asm.Instruction.Length;
}

logger.WriteLine($" {element.TextRepresentation}");
Expand Down
8 changes: 4 additions & 4 deletions src/BenchmarkDotNet/Disassemblers/InstructionFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal static class InstructionFormatter
{
internal static string Format(Instruction instruction, Formatter formatter, bool printInstructionAddresses, uint pointerSize)
{
var output = new StringBuilderFormatterOutput();
var output = new StringOutput();

if (printInstructionAddresses)
{
Expand All @@ -37,14 +37,14 @@ internal static string Format(Instruction instruction, Formatter formatter, bool
return output.ToString();
}

private static void FormatInstructionPointer(Instruction instruction, Formatter formatter, uint pointerSize, StringBuilderFormatterOutput output)
private static void FormatInstructionPointer(Instruction instruction, Formatter formatter, uint pointerSize, StringOutput output)
{
string ipFormat = formatter.Options.LeadingZeroes
? pointerSize == 4 ? "X8" : "X16"
: "X";

output.Write(instruction.IP.ToString(ipFormat), FormatterOutputTextKind.Text);
output.Write(" ", FormatterOutputTextKind.Text);
output.Write(instruction.IP.ToString(ipFormat), FormatterTextKind.Text);
output.Write(" ", FormatterTextKind.Text);
}
}
}
4 changes: 2 additions & 2 deletions src/BenchmarkDotNet/Exporters/InstructionPointerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private string Export(Summary summary, BenchmarkCase benchmarkCase, DisassemblyR
IEnumerable<ulong> Range(Asm asm)
{
// most probably asm.StartAddress would be enough, but I don't want to miss any edge case
for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong)asm.Instruction.ByteLength; instructionPointer++)
for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong)asm.Instruction.Length; instructionPointer++)
yield return instructionPointer;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ private static IReadOnlyList<MethodWithCounters> SumHardwareCountersPerMethod(Di
foreach (var hardwareCounter in pmcStats.Counters)
{
// most probably asm.StartAddress would be enough, but I don't want to miss any edge case
for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong)asm.Instruction.ByteLength; instructionPointer++)
for (ulong instructionPointer = asm.InstructionPointer; instructionPointer < asm.InstructionPointer + (ulong)asm.Instruction.Length; instructionPointer++)
if (hardwareCounter.Value.PerInstructionPointer.TryGetValue(instructionPointer, out ulong value))
totalsPerCounter[hardwareCounter.Key] = totalsPerCounter[hardwareCounter.Key] + value;
}
Expand Down

0 comments on commit b356ac8

Please sign in to comment.