Closed kunalspathak closed 2 years ago
@adamsitnik
The disassembler does not work on ARM & ARM64 due to the fact that we are internally using Iced
which does not support it yet.
As soon as https://github.com/0xd4d/iced/issues/79 and https://github.com/0xd4d/iced/issues/80 get implemented, we are going to update Iced on our side and add the support. I don't know when it's going to happen.
Currently we can implement it in following ways:
Use DOTNET_JitDisasm
exposed recently by https://github.com/dotnet/runtime/pull/73365 and parse the disassembly from standard output. In #2092 I've extended ExecuteResult
with new StandardOutput
that contains all the lines printed by the benchmark process to standard output.
Advantages:
Disadvantages:
The current x64/x86 disassembler uses ClrMD to get disassembly as byte[]
and Iced
to decode the instructions and format them. Iced does not support arm yet: https://github.com/icedland/iced/issues/72 (the issue is closed, but there is no support).
For arm64/arm we could use https://github.com/capstone-engine/capstone which supports .NET and arm. The .NET library has recently added support for linux and macOS (so far it supported only Windows): https://github.com/9ee1/Capstone.NET/pull/32, but a new NuGet package version was not published to nuget.org yet. However, a fork of it has published the package: https://www.nuget.org/packages/js6pak.Gee.External.Capstone
Advantages:
Disadvantages:
We could contribute to Iced and implement arm64 support. This would require us to establish new abstractions (so far everything assumed x64) and also implement arm64/arm decoding. IMO this would be a lot of work, but I might be wrong.
@janvorli I've done two experiments:
--disasmFilter *
) and it did not throw.Branch that I've been using: https://github.com/dotnet/BenchmarkDotNet/tree/arm64Disasm
Demo:
; BenchmarkDotNet.Samples.IntroDisassembly.SumField()
stp x29, x30, [sp, #-0x10]!
mov x29, sp
mov w1, wzr
mov w2, wzr
ldr x0, [x0, #8]
ldr w3, [x0, #8]
cmp w3, #0
b.le #0x1044
mov x3, x0
ldr w4, [x3, #8]
cmp w2, w4
b.hs #0x1040
sxtw x4, w2
lsl x4, x4, #2
add x4, x4, #0x10
ldr w3, [x3, x4]
add w1, w3, w1
add w2, w2, #1
ldr w3, [x0, #8]
cmp w3, w2
b.gt #0xfd8
mov w0, w1
ldp x29, x30, [sp], #0x10
ret
bl #0xffffffffff8a39b0
brk #0
; Total bytes of code 104
I get following exception when using
--disasm
on ARM64.