Skip to content
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

arm64 disassembler #2127

Merged
merged 10 commits into from
Oct 5, 2022
Merged

arm64 disassembler #2127

merged 10 commits into from
Oct 5, 2022

Conversation

adamsitnik
Copy link
Member

@adamsitnik adamsitnik commented Sep 30, 2022

fixes #1422

Sample output:

.NET 6.0.9 (6.0.922.41905), Arm64 RyuJIT AdvSIMD

; BenchmarkDotNet.Samples.IntroDisassembly.SumLocal()
       FFFF228438F0 stp       x29, x30, [sp, #-0x10]!
       FFFF228438F4 mov       x29, sp
       FFFF228438F8 ldr       x0, [x0, #8]
       FFFF228438FC mov       w1, wzr
       FFFF22843900 mov       w2, wzr
       FFFF22843904 ldr       w3, [x0, #8]
       FFFF22843908 cmp       w3, #0
       FFFF2284390C b.le      M00_L01
M00_L00:
       FFFF22843910 sxtw      x4, w2
       FFFF22843914 lsl       x4, x4, #2
       FFFF22843918 add       x4, x4, #0x10
       FFFF2284391C ldr       w4, [x0, x4]
       FFFF22843920 add       w1, w4, w1
       FFFF22843924 add       w2, w2, #1
       FFFF22843928 cmp       w3, w2
       FFFF2284392C b.gt      M00_L00
M00_L01:
       FFFF22843930 mov       w0, w1
       FFFF22843934 ldp       x29, x30, [sp], #0x10
       FFFF22843938 ret
; Total bytes of code 76

.NET 6.0.9 (6.0.922.41905), Arm64 RyuJIT AdvSIMD

; BenchmarkDotNet.Samples.IntroDisassembly.SumField()
       FFFF099738F0 stp       x29, x30, [sp, #-0x10]!
       FFFF099738F4 mov       x29, sp
       FFFF099738F8 mov       w1, wzr
       FFFF099738FC mov       w2, wzr
       FFFF09973900 ldr       x0, [x0, #8]
       FFFF09973904 ldr       w3, [x0, #8]
       FFFF09973908 cmp       w3, #0
       FFFF0997390C b.le      M00_L01
M00_L00:
       FFFF09973910 mov       x3, x0
       FFFF09973914 ldr       w4, [x3, #8]
       FFFF09973918 cmp       w2, w4
       FFFF0997391C b.hs      M00_L02
       FFFF09973920 sxtw      x4, w2
       FFFF09973924 lsl       x4, x4, #2
       FFFF09973928 add       x4, x4, #0x10
       FFFF0997392C ldr       w3, [x3, x4]
       FFFF09973930 add       w1, w3, w1
       FFFF09973934 add       w2, w2, #1
       FFFF09973938 ldr       w3, [x0, #8]
       FFFF0997393C cmp       w3, w2
       FFFF09973940 b.gt      M00_L00
M00_L01:
       FFFF09973944 mov       w0, w1
       FFFF09973948 ldp       x29, x30, [sp], #0x10
       FFFF0997394C ret
M00_L02:
       FFFF09973950 bl        #0xffff09216300
       FFFF09973954 brk       #0
; Total bytes of code 104

cc @janvorli

adamsitnik and others added 7 commits September 19, 2022 16:53
* fold ClrMdV2Disassembler<T> into ClrMdV2Disassembler (we don't need it anymore since the referenced address is stored in the Asm type)

* Update the ClrMdV1 disassembler (used when benchmark process architecture is different than host, example: Full Framework x86 and 64)

* initial version of the Arm64 formatter
@adamsitnik adamsitnik added this to the v0.13.3 milestone Sep 30, 2022
@adamsitnik
Copy link
Member Author

@9ee1 I just wanted to thank you for your work on Capstone. Thanks to your library we were able to implement arm64 disassembler for BenchmarkDotNet!

@9ee1
Copy link

9ee1 commented Oct 3, 2022

@9ee1 I just wanted to thank you for your work on Capstone. Thanks to your library we were able to implement arm64 disassembler for BenchmarkDotNet!

This is great! BenchmarkDotNet is one of my favorite libraries. Thank you very much for the mention.

@adamsitnik adamsitnik merged commit f4d99ab into master Oct 5, 2022
@adamsitnik adamsitnik deleted the arm64Disasm branch October 5, 2022 11:56
mawosoft added a commit to mawosoft/Mawosoft.Extensions.BenchmarkDotNet that referenced this pull request Oct 9, 2022
BDN >= 0.13.2.1930 uses the Arm64 disassembler package Gee.External.Capstone 2.2.0. Unlike BDN itself, the package is not strong-named, therfore causing a ReflectionTypeLoadException on NetFx (strong-named assembly required).
See dotnet/BenchmarkDotNet#2127
Closes #139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--disasm switch on ARM64 throws Exception
3 participants