Benchmarkdotnet: Add annotations for diassembler output

Created on 10 Sep 2017  Â·  17Comments  Â·  Source: dotnet/BenchmarkDotNet

From private conversation with @JosephTremoulet

trying to replicate (in some fashion) the various annotations we report in the checked-jit-produced disasm (symbol resolution would be a good start, resolving helper tokens to their symbolic names also important, structured reporting of GC and EH tables, compilation flags, local variable table…) – open question how you’d reconstruct this information after-the-fact (debug info? event [ETW] streams? maybe new ones that we’d add?), where the code should live (e.g. a library that something like PerfView could also tap into would be cool, maybe a lot of this functionality belongs in CLRMD), etc. Everything we’ve put in the COMPlus_JitDisasm output is something we’ve put there because it’s useful to be able to understand and diff the machine code

Diagnosers Exporters enhancement

Most helpful comment

If you want to look at the relevant source code, search in the jit directory for opts.disAsm.

It may be easier to start with examples. If you build a "checked" or "debug" local build of the CoreCLR runtime, and run some code against that with the COMPlus_JitDisasm environment variable set to *, it will emit assembly listings for every method that gets jitted.

All 17 comments

hi @adamsitnik , is this issue still actual? may I grab it? If yes, I would be really appreciated you hinted me where the best point to start.

hi @GeorgePlotnikov !

yes, it's still up for grabs. But the feature itself is rather very BIG.

Personally I would start with some research of what COMPlus_JitDisasm does in Core CLR. Once you know what they are doing and make sure that the data is available outside of CLR itself I would start implementing the features one by one.

@JosephTremoulet do you have any hints? Is there somebody that could point us to the right place?

If you want to look at the relevant source code, search in the jit directory for opts.disAsm.

It may be easier to start with examples. If you build a "checked" or "debug" local build of the CoreCLR runtime, and run some code against that with the COMPlus_JitDisasm environment variable set to *, it will emit assembly listings for every method that gets jitted.

@adamsitnik, @JosephTremoulet great! thanks a lot!

@AndreyAkinshin could you assign @GeorgePlotnikov to this issue?

@GeorgePlotnikov, I added you to the collaborators list. Please, accept the invitation, then I will be able to assign you.

@AndreyAkinshin done. Thanks.

@GeorgePlotnikov, assigned.

small update to track this issue: I'm investigating the coreclr disasm output to compare vs BDN and to figure out how it should look like.

@GeorgePlotnikov great, thanks for the update!

I want to clarify if I'm understanding clearly. Correct me if I'm wrong.

Small example:

c# code

public string Calc()
{
        return "result: " + WithoutStarg(0x11) + WithStarg(0x12);
}

produces via JitDisasm annotation below

; Total bytes of code 23, prolog size 4 for method jitdumptest.Program:Main(ref)
; ============================================================
; Assembly listing for method jitdumptest.Program:Calc():ref
; Emitting BLENDED_CODE for X64 CPU with AVX
; optimized code
; rsp based frame
; partially interruptible
; Final local variable assignments
;
;  V00 tmp0         [V00,T00] (  4,  8   )     ref  ->  rsi         class-hnd exact
;  V01 tmp1         [V01,T01] (  4,  8   )     ref  ->  rdi         class-hnd exact
;  V02 OutArgs      [V02    ] (  1,  1   )  lclBlk (32) [rsp+0x00]
;
; Lcl frame size = 40

that's the goal?

@JosephTremoulet could you give some feedback to @GeorgePlotnikov ?

Yes, as much of that header as can be recreated would be helpful, though I don't know what would still be available on the runtime side in the MethodDesc or GC info or debug info.

Aside from the header, there should have been a dump of the actual disassembly that followed, which likewise may have some useful comments, and may be using symbolic names more than BDN currently is.

@adamsitnik, @JosephTremoulet thank you for replies, will discover the solution

hello @JosephTremoulet

Could you tell us what are the most important things that we should reproduce in BDN?

@GeorgePlotnikov has started working on this issue (draft of the PR #635 ) and we need to know if we can get the most important data

Hi @adamsitnik, @AndreyAkinshin did you see the results, what do you think about it?

No progress since 2017, we have also switched to Iced for instructions decoding (which might add similar feature in the future) so I am closing the issue

Was this page helpful?
0 / 5 - 0 ratings