dotnet / dotnet/BenchmarkDotNet

Migrate arm64 disassembler implementation to AsmArm64

Open
#3,246 2 comments 0 reactions 0 assignees View on GitHub
Area:Diagnosers
Dominant language
C#
Stars
11.5k
Forks
1.1k
Avg merge
4d 11h
Merged PRs (30d)
11

Description

Currently, BenchmarkDotNet using `Gee.External.Capstone` package for `arm64` disassembler.
And `Iced` for x86/x64 disassemblers.

`Gee.External.Capstone` package contains a lot of native dependency DLLs.
So It's better to migrate to use [AsmArm64](https://github.com/xoofx/AsmArm64).

### Support newer instruction
Currently, `Gee.External.Capstone` using capstone v4.0.2 binaries. and it looks like some instruction support are missing.

On .NET 11, arm64 minimum instruction requirement is updated.
So it might need to handle additional instructions that are emitted by JIT.
https://github.com/dotnet/docs/blob/main/docs/core/whats-new/dotnet-11/runtime.md#arm64-requirements

e.g. .NET 11 JIT looks like emitting `RETAA`/`RETBB`, but current `Gee.External.Capstone` can't handle these instructions.
https://github.com/dotnet/runtime/blob/7e807becb8c6b1917dac0565c674ade7947a8bec/src/coreclr/jit/instrsarm64.h#L1321C21-L1324

### Known Issues when migrated to AsmArm64
- Currently AsmArm64 don't support SVE/SVE2/SME instruction. (`Gee.External.Capstone` also doesn't support these instruction though)
- ~~Disassembler results has some differences (e.g. instructions are resolved to alias (`MOVZ` is printed as `MOV` automatically))~~

Contributor guide

Open the contributing guide

Research direction

Start by locating the arm64 disassembler integration and its current Gee.External.Capstone usage, then compare the required instruction support with AsmArm64. Check the .NET 11 JIT examples, especially RETAA and RETBB, and verify that the migration handles the expected emitted instructions without regressing existing arm64 disassembly behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.