-
Couldn't load subscription status.
- Fork 5.2k
Add disasm comments for field data addresses and code addresses #70437
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsThis adds disassembly comments for field addresses and function addresses. To make this more useful, it also supports displaying the comments for x64 instructions with addressing modes. For example, for public class Program
{
public static int s_primitive;
private static Guid s_guid;
public static void Main()
{
Console.WriteLine(s_primitive);
Console.WriteLine(s_guid);
Action a = Main;
}
}the diff in the disasm on x64 is mov rcx, 0xD1FFAB1E
mov edx, 1
call CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE
- mov ecx, dword ptr [(reloc)]
+ mov ecx, dword ptr [(reloc)] ; data for Program:s_primitive
call [System.Console:WriteLine(int)]
mov rcx, 0xD1FFAB1E ; System.Guid
call CORINFO_HELP_NEWSFAST
- mov rcx, 0xD1FFAB1E
+ mov rcx, 0xD1FFAB1E ; box for Program:s_guid
mov rcx, gword ptr [rcx]
vmovupd xmm0, xmmword ptr [rcx+8]
vmovupd xmmword ptr [rax+8], xmm0
mov rcx, rax
call [System.Console:WriteLine(System.Object)]
- mov rcx, 0xD1FFAB1E
+ mov rcx, 0xD1FFAB1E ; data for <>O:<0>__Main
cmp gword ptr [rcx], 0
jne SHORT G_M27646_IG04
;; size=95 bbWeight=1 PerfScore 23.50
G_M27646_IG03:
- mov rcx, 0xD1FFAB1E
+ mov rcx, 0xD1FFAB1E ; token handle
call CORINFO_HELP_NEWSFAST
mov rsi, rax
lea rcx, bword ptr [rsi+8]
mov rdx, rsi
call CORINFO_HELP_ASSIGN_REF
- mov rdx, 0xD1FFAB1E
+ mov rdx, 0xD1FFAB1E ; function address
mov qword ptr [rsi+24], rdx
- mov rdx, 0xD1FFAB1E
+ mov rdx, 0xD1FFAB1E ; code address for Program:Main
mov qword ptr [rsi+32], rdx
- mov rcx, 0xD1FFAB1E
+ mov rcx, 0xD1FFAB1E ; data for <>O:<0>__Main
mov rdx, rsi
call CORINFO_HELP_ASSIGN_REF
;; size=76 bbWeight=0.50 PerfScore 3.62For ARM64 it looks like (due to CSE not all of the static field accesses show up): mov w1, #1
bl CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE
ldr w0, [x19,#56]
- movz x1, #0xd1ffab1e
+ movz x1, #0xd1ffab1e // code address for System.Console:WriteLine
movk x1, #0xd1ffab1e LSL #16
movk x1, #0xd1ffab1e LSL #32
ldr x1, [x1]
@@ -40,13 +40,13 @@ G_M27646_IG02:
movk x0, #0xd1ffab1e LSL #16
movk x0, #0xd1ffab1e LSL #32
bl CORINFO_HELP_NEWSFAST
- movz x19, #0xd1ffab1e
+ movz x19, #0xd1ffab1e // box for Program:s_guid
movk x19, #0xd1ffab1e LSL #16
movk x19, #0xd1ffab1e LSL #32
ldr x1, [x19]
ldr q16, [x1,#8]
str q16, [x0,#8]
- movz x1, #0xd1ffab1e
+ movz x1, #0xd1ffab1e // code address for System.Console:WriteLine
movk x1, #0xd1ffab1e LSL #16
movk x1, #0xd1ffab1e LSL #32
ldr x1, [x1]
@@ -66,7 +66,7 @@ G_M27646_IG03:
movk x14, #0xd1ffab1e LSL #16
movk x14, #0xd1ffab1e LSL #32
str x14, [x0,#24]
- movz x14, #0xd1ffab1e
+ movz x14, #0xd1ffab1e // code address for Program:Main
movk x14, #0xd1ffab1e LSL #16
movk x14, #0xd1ffab1e LSL #32
str x14, [x0,#32]
|
|
cc @dotnet/jit-contrib PTAL @kunalspathak @BruceForstall |
This was mistakenly creating a handle for the parent (always a class) but specifying the handle type of the child (e.g. constructor method handle).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
|
Running the tests with |
|
|
This adds disassembly comments for field addresses and function addresses. To make this more useful, it also supports displaying the comments for x64 instructions with addressing modes.
For example, for
the diff in the disasm on x64 is
mov rcx, 0xD1FFAB1E mov edx, 1 call CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE - mov ecx, dword ptr [(reloc)] + mov ecx, dword ptr [(reloc)] ; data for Program:s_primitive call [System.Console:WriteLine(int)] mov rcx, 0xD1FFAB1E ; System.Guid call CORINFO_HELP_NEWSFAST - mov rcx, 0xD1FFAB1E + mov rcx, 0xD1FFAB1E ; box for Program:s_guid mov rcx, gword ptr [rcx] vmovupd xmm0, xmmword ptr [rcx+8] vmovupd xmmword ptr [rax+8], xmm0 mov rcx, rax call [System.Console:WriteLine(System.Object)] - mov rcx, 0xD1FFAB1E + mov rcx, 0xD1FFAB1E ; data for <>O:<0>__Main cmp gword ptr [rcx], 0 jne SHORT G_M27646_IG04 ;; size=95 bbWeight=1 PerfScore 23.50 G_M27646_IG03: - mov rcx, 0xD1FFAB1E + mov rcx, 0xD1FFAB1E ; token handle call CORINFO_HELP_NEWSFAST mov rsi, rax lea rcx, bword ptr [rsi+8] mov rdx, rsi call CORINFO_HELP_ASSIGN_REF - mov rdx, 0xD1FFAB1E + mov rdx, 0xD1FFAB1E ; function address mov qword ptr [rsi+24], rdx - mov rdx, 0xD1FFAB1E + mov rdx, 0xD1FFAB1E ; code address for Program:Main mov qword ptr [rsi+32], rdx - mov rcx, 0xD1FFAB1E + mov rcx, 0xD1FFAB1E ; data for <>O:<0>__Main mov rdx, rsi call CORINFO_HELP_ASSIGN_REF ;; size=76 bbWeight=0.50 PerfScore 3.62For ARM64 it looks like (due to CSE not all of the static field accesses show up):
mov w1, #1 bl CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE ldr w0, [x19,#56] - movz x1, #0xd1ffab1e + movz x1, #0xd1ffab1e // code address for System.Console:WriteLine movk x1, #0xd1ffab1e LSL #16 movk x1, #0xd1ffab1e LSL #32 ldr x1, [x1] @@ -40,13 +40,13 @@ G_M27646_IG02: movk x0, #0xd1ffab1e LSL #16 movk x0, #0xd1ffab1e LSL #32 bl CORINFO_HELP_NEWSFAST - movz x19, #0xd1ffab1e + movz x19, #0xd1ffab1e // box for Program:s_guid movk x19, #0xd1ffab1e LSL #16 movk x19, #0xd1ffab1e LSL #32 ldr x1, [x19] ldr q16, [x1,#8] str q16, [x0,#8] - movz x1, #0xd1ffab1e + movz x1, #0xd1ffab1e // code address for System.Console:WriteLine movk x1, #0xd1ffab1e LSL #16 movk x1, #0xd1ffab1e LSL #32 ldr x1, [x1] @@ -66,7 +66,7 @@ G_M27646_IG03: movk x14, #0xd1ffab1e LSL #16 movk x14, #0xd1ffab1e LSL #32 str x14, [x0,#24] - movz x14, #0xd1ffab1e + movz x14, #0xd1ffab1e // code address for Program:Main movk x14, #0xd1ffab1e LSL #16 movk x14, #0xd1ffab1e LSL #32 str x14, [x0,#32]