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

Add annotations for diassembler output #545

Open
adamsitnik opened this Issue Sep 10, 2017 · 16 comments

Comments

Projects
None yet
4 participants
@adamsitnik
Member

adamsitnik commented Sep 10, 2017

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

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Dec 13, 2017

Collaborator

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.

Collaborator

GeorgePlotnikov commented Dec 13, 2017

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.

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Dec 13, 2017

Member

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?

Member

adamsitnik commented Dec 13, 2017

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?

@JosephTremoulet

This comment has been minimized.

Show comment
Hide comment
@JosephTremoulet

JosephTremoulet Dec 13, 2017

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.

JosephTremoulet commented Dec 13, 2017

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.

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Dec 13, 2017

Collaborator

@adamsitnik, @JosephTremoulet great! thanks a lot!

Collaborator

GeorgePlotnikov commented Dec 13, 2017

@adamsitnik, @JosephTremoulet great! thanks a lot!

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Dec 13, 2017

Member

@AndreyAkinshin could you assign @GeorgePlotnikov to this issue?

Member

adamsitnik commented Dec 13, 2017

@AndreyAkinshin could you assign @GeorgePlotnikov to this issue?

@AndreyAkinshin

This comment has been minimized.

Show comment
Hide comment
@AndreyAkinshin

AndreyAkinshin Dec 14, 2017

Member

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

Member

AndreyAkinshin commented Dec 14, 2017

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

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Dec 14, 2017

Collaborator

@AndreyAkinshin done. Thanks.

Collaborator

GeorgePlotnikov commented Dec 14, 2017

@AndreyAkinshin done. Thanks.

@AndreyAkinshin

This comment has been minimized.

Show comment
Hide comment
@AndreyAkinshin
Member

AndreyAkinshin commented Dec 14, 2017

@GeorgePlotnikov, assigned.

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Dec 28, 2017

Collaborator

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.

Collaborator

GeorgePlotnikov commented Dec 28, 2017

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.

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Dec 30, 2017

Member

@GeorgePlotnikov great, thanks for the update!

Member

adamsitnik commented Dec 30, 2017

@GeorgePlotnikov great, thanks for the update!

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Dec 31, 2017

Collaborator

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?

Collaborator

GeorgePlotnikov commented Dec 31, 2017

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?

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Dec 31, 2017

Member

@JosephTremoulet could you give some feedback to @GeorgePlotnikov ?

Member

adamsitnik commented Dec 31, 2017

@JosephTremoulet could you give some feedback to @GeorgePlotnikov ?

@JosephTremoulet

This comment has been minimized.

Show comment
Hide comment
@JosephTremoulet

JosephTremoulet Jan 2, 2018

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.

JosephTremoulet commented Jan 2, 2018

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.

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Jan 8, 2018

Collaborator

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

Collaborator

GeorgePlotnikov commented Jan 8, 2018

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

@adamsitnik

This comment has been minimized.

Show comment
Hide comment
@adamsitnik

adamsitnik Feb 5, 2018

Member

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

Member

adamsitnik commented Feb 5, 2018

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

@GeorgePlotnikov

This comment has been minimized.

Show comment
Hide comment
@GeorgePlotnikov

GeorgePlotnikov Feb 17, 2018

Collaborator

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

Collaborator

GeorgePlotnikov commented Feb 17, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment