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

Enable JitDisasm in Release #73365

Merged
merged 35 commits into from
Aug 10, 2022
Merged

Enable JitDisasm in Release #73365

merged 35 commits into from
Aug 10, 2022

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Aug 4, 2022

This PR enables DOTNET_JitDisasm for Release config.

It doesn't print lcl tables, EH and gc info (for now).

Adds ~30kb to the binary size of jit.

The only noticeable impact on Release is that instrDesc struct is now 8bytes bigger (_idDebugOnlyInfo) - but I might fix it with a standalone hash-table which will be populated only when JitDisasm variable is not empty.

Example:

public class Tests
{
    static int staticField;
    string instanceField;

    public virtual void VirtualCall() {}

    public void Test(string[] args, IDisposable d)
    {
        // control flow
        if (args?.Length == 0)
        {
            Console.WriteLine("field: " + staticField);
            Console.WriteLine(instanceField);
        }
        else
        {
            // SIMD (data section)
            Console.WriteLine(Vector128.Create(1, 2, 3, 4));
        }

        // Virtual call
        VirtualCall();

        // Interface call
        d?.Dispose();

        // Jump table
        switch (args.Length)
        {
            case 1:
                Console.WriteLine("1");
                break;
            case 2:
                Console.WriteLine("2");
                break;
            case 3:
                Console.WriteLine("3");
                break;
            case 4:
                Console.WriteLine("5");
                break;
            case 6:
                Console.WriteLine("7");
                break;
        }
        Console.ReadKey();
    }
}

DOTNET_JitDisasm=Test: (DOTNET_JitDiffableDasm is 0 by default, hence, raw bytes, addresses)

; Assembly listing for method Tests:Test(ref,IDisposable):this
; Emitting BLENDED_CODE for X64 CPU with AVX - Windows
; optimized code
; rsp based frame
; partially interruptible
; No PGO data
; 0 inlinees with PGO data; 2 single block inlinees; 0 inlinees without PGO data

G_M000_IG01:                ;; offset=0000H
       57                   push     rdi
       56                   push     rsi
       53                   push     rbx
       4883EC30             sub      rsp, 48
       C5F877               vzeroupper
       488BF1               mov      rsi, rcx
       488BFA               mov      rdi, rdx
       498BD8               mov      rbx, r8

G_M000_IG02:                ;; offset=0013H
       4885FF               test     rdi, rdi
       743D                 je       SHORT G_M000_IG04

G_M000_IG03:                ;; offset=0018H
       837F0800             cmp      dword ptr [rdi+8], 0
       7537                 jne      SHORT G_M000_IG04
       8B0DF8B40C00         mov      ecx, dword ptr [(reloc 0x7ffd9745c06c)]
       FF15560A1100         call     [Number:Int32ToDecStr(int):String]
       488BD0               mov      rdx, rax
       48B9D820804A0C020000 mov      rcx, 0x20C4A8020D8
       488B09               mov      rcx, gword ptr [rcx]
       FF15D0100900         call     [String:Concat(String,String):String]
       488BC8               mov      rcx, rax
       FF15FFAE0F00         call     [Console:WriteLine(String)]
       488B4E08             mov      rcx, gword ptr [rsi+8]
       FF15F5AE0F00         call     [Console:WriteLine(String)]
       EB27                 jmp      SHORT G_M000_IG05

G_M000_IG04:                ;; offset=0055H
       48B978D64797FD7F0000 mov      rcx, 0x7FFD9747D678
       E8FCAEAE5F           call     CORINFO_HELP_NEWSFAST
       C5F91005E4000000     vmovupd  xmm0, xmmword ptr [reloc @RWD00]
       C5F9114008           vmovupd  xmmword ptr [rax+8], xmm0
       488BC8               mov      rcx, rax
       FF15B6AE0F00         call     [Console:WriteLine(Object)]

G_M000_IG05:                ;; offset=007AH
       488BCE               mov      rcx, rsi
       488B06               mov      rax, qword ptr [rsi]
       488B4040             mov      rax, qword ptr [rax+64]
       FF5020               call     [rax+32]Tests:VirtualCall():this
       4885DB               test     rbx, rbx
       7410                 je       SHORT G_M000_IG07

G_M000_IG06:                ;; offset=008CH
       488BCB               mov      rcx, rbx
       49BB08001E97FD7F0000 mov      r11, 0x7FFD971E0008
       41FF13               call     [r11]IDisposable:Dispose():this

G_M000_IG07:                ;; offset=009CH
       8B4F08               mov      ecx, dword ptr [rdi+8]
       FFC9                 dec      ecx
       83F905               cmp      ecx, 5
       0F877F000000         ja       G_M000_IG13
       8BC9                 mov      ecx, ecx
       488D05AD000000       lea      rax, [reloc @RWD16]
       8B0488               mov      eax, dword ptr [rax+4*rcx]
       488D1556FFFFFF       lea      rdx, G_M000_IG02
       4803C2               add      rax, rdx
       FFE0                 jmp      rax

G_M000_IG08:                ;; offset=00C2H
       48B9E020804A0C020000 mov      rcx, 0x20C4A8020E0
       488B09               mov      rcx, gword ptr [rcx]
       FF1573AE0F00         call     [Console:WriteLine(String)]
       EB52                 jmp      SHORT G_M000_IG13

G_M000_IG09:                ;; offset=00D7H
       48B9E820804A0C020000 mov      rcx, 0x20C4A8020E8
       488B09               mov      rcx, gword ptr [rcx]
       FF155EAE0F00         call     [Console:WriteLine(String)]
       EB3D                 jmp      SHORT G_M000_IG13

G_M000_IG10:                ;; offset=00ECH
       48B9F020804A0C020000 mov      rcx, 0x20C4A8020F0
       488B09               mov      rcx, gword ptr [rcx]
       FF1549AE0F00         call     [Console:WriteLine(String)]
       EB28                 jmp      SHORT G_M000_IG13

G_M000_IG11:                ;; offset=0101H
       48B9F820804A0C020000 mov      rcx, 0x20C4A8020F8
       488B09               mov      rcx, gword ptr [rcx]
       FF1534AE0F00         call     [Console:WriteLine(String)]
       EB13                 jmp      SHORT G_M000_IG13

G_M000_IG12:                ;; offset=0116H
       48B90021804A0C020000 mov      rcx, 0x20C4A802100
       488B09               mov      rcx, gword ptr [rcx]
       FF151FAE0F00         call     [Console:WriteLine(String)]

G_M000_IG13:                ;; offset=0129H
       488D4C2420           lea      rcx, bword ptr
       33D2                 xor      edx, edx
       FF158AEE0F00         call     [ConsolePal:ReadKey(bool):ConsoleKeyInfo]
       90                   nop

G_M000_IG14:                ;; offset=0137H
       4883C430             add      rsp, 48
       5B                   pop      rbx
       5E                   pop      rsi
       5F                   pop      rdi
       C3                   ret

RWD00   dq      0000000200000001h, 0000000400000003h
RWD16   dd      000000AFh ; case G_M000_IG08
        dd      000000C4h ; case G_M000_IG09
        dd      000000D9h ; case G_M000_IG10
        dd      000000EEh ; case G_M000_IG11
        dd      00000116h ; case G_M000_IG13
        dd      00000103h ; case G_M000_IG12

; Total bytes of code 319

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 4, 2022
@ghost ghost assigned EgorBo Aug 4, 2022
@ghost
Copy link

ghost commented Aug 4, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR enables DOTNT_JitDisasm, DOTNET_NgenDisasm and DOTNET_JitDiffableDasm for Release config.

It doesn't print lcl tables and gc info (for now).

Adds ~30kb to the binary size of jit.

The only noticeable impact on Release is that instrDesc struct is now 8bytes bigger (_idDebugOnlyInfo) - but I might fix it with a standalone hash-table which will be populated only when JitDisasm variable is not empty.

Example:

public class Tests
{
    static int staticField;
    string instanceField;

    public virtual void VirtualCall() {}

    public void Test(string[] args, IDisposable d)
    {
        // control flow
        if (args?.Length == 0)
        {
            Console.WriteLine("field: " + staticField);
            Console.WriteLine(instanceField);
        }
        else
        {
            // SIMD (data section)
            Console.WriteLine(Vector128.Create(1, 2, 3, 4));
        }

        // Virtual call
        VirtualCall();

        // Interface call
        d?.Dispose();

        // Jump table
        switch (args.Length)
        {
            case 1:
                Console.WriteLine("1");
                break;
            case 2:
                Console.WriteLine("2");
                break;
            case 3:
                Console.WriteLine("3");
                break;
            case 4:
                Console.WriteLine("5");
                break;
            case 6:
                Console.WriteLine("7");
                break;
        }
        Console.ReadKey();
    }
}
; Emitting BLENDED_CODE for X64 CPU with AVX - Windows
; optimized code
; rsp based frame
; partially interruptible
; No PGO data
; 0 inlinees with PGO data; 2 single block inlinees; 0 inlinees without PGO data
IG_01:
       57                   push     rdi
       56                   push     rsi
       53                   push     rbx
       4883EC30             sub      rsp, 48
       C5F877               vzeroupper
       488BF1               mov      rsi, rcx
       488BFA               mov      rdi, rdx
       498BD8               mov      rbx, r8
IG_02:
       4885FF               test     rdi, rdi
       743D                 je       SHORT G_M000_IG04
IG_03:
       837F0800             cmp      dword ptr [rdi+8], 0
       7537                 jne      SHORT G_M000_IG04
       8B0DF8B40C00         mov      ecx, dword ptr [(reloc 0x7ffd2d2dc06c)]
       FF15560A1100         call     [Number:Int32ToDecStr(int):String]
       488BD0               mov      rdx, rax
       48B9D820C0EF74020000 mov      rcx, 0x274EFC020D8
       488B09               mov      rcx, gword ptr [rcx]
       FF15D0100900         call     [String:Concat(String,String):String]
       488BC8               mov      rcx, rax
       FF15FFAE0F00         call     [Console:WriteLine(String)]
       488B4E08             mov      rcx, gword ptr [rsi+8]
       FF15F5AE0F00         call     [Console:WriteLine(String)]
       EB27                 jmp      SHORT G_M000_IG05
IG_04:
       48B978D62F2DFD7F0000 mov      rcx, 0x7FFD2D2FD678
       E8FCAEAF5F           call     CORINFO_HELP_NEWSFAST
       C5F91005E4000000     vmovupd  xmm0, xmmword ptr [reloc @RWD00]
       C5F9114008           vmovupd  xmmword ptr [rax+8], xmm0
       488BC8               mov      rcx, rax
       FF15B6AE0F00         call     [Console:WriteLine(Object)]
IG_05:
       488BCE               mov      rcx, rsi
       488B06               mov      rax, qword ptr [rsi]
       488B4040             mov      rax, qword ptr [rax+64]
       FF5020               call     [rax+32]Tests:VirtualCall():this
       4885DB               test     rbx, rbx
       7410                 je       SHORT G_M000_IG07
IG_06:
       488BCB               mov      rcx, rbx
       49BB0800062DFD7F0000 mov      r11, 0x7FFD2D060008
       41FF13               call     [r11]IDisposable:Dispose():this
IG_07:
       8B4F08               mov      ecx, dword ptr [rdi+8]
       FFC9                 dec      ecx
       83F905               cmp      ecx, 5
       0F877F000000         ja       G_M000_IG13
       8BC9                 mov      ecx, ecx
       488D05AD000000       lea      rax, [reloc @RWD16]
       8B0488               mov      eax, dword ptr [rax+4*rcx]
       488D1556FFFFFF       lea      rdx, G_M000_IG02
       4803C2               add      rax, rdx
       FFE0                 jmp      rax
IG_08:
       48B9E020C0EF74020000 mov      rcx, 0x274EFC020E0
       488B09               mov      rcx, gword ptr [rcx]
       FF1573AE0F00         call     [Console:WriteLine(String)]
       EB52                 jmp      SHORT G_M000_IG13
IG_09:
       48B9E820C0EF74020000 mov      rcx, 0x274EFC020E8
       488B09               mov      rcx, gword ptr [rcx]
       FF155EAE0F00         call     [Console:WriteLine(String)]
       EB3D                 jmp      SHORT G_M000_IG13
IG_10:
       48B9F020C0EF74020000 mov      rcx, 0x274EFC020F0
       488B09               mov      rcx, gword ptr [rcx]
       FF1549AE0F00         call     [Console:WriteLine(String)]
       EB28                 jmp      SHORT G_M000_IG13
IG_11:
       48B9F820C0EF74020000 mov      rcx, 0x274EFC020F8
       488B09               mov      rcx, gword ptr [rcx]
       FF1534AE0F00         call     [Console:WriteLine(String)]
       EB13                 jmp      SHORT G_M000_IG13
IG_12:
       48B90021C0EF74020000 mov      rcx, 0x274EFC02100
       488B09               mov      rcx, gword ptr [rcx]
       FF151FAE0F00         call     [Console:WriteLine(String)]
IG_13:
       488D4C2420           lea      rcx, bword ptr
       33D2                 xor      edx, edx
       FF158AEE0F00         call     [ConsolePal:ReadKey(bool):ConsoleKeyInfo]
       90                   nop
IG_14:
       4883C430             add      rsp, 48
       5B                   pop      rbx
       5E                   pop      rsi
       5F                   pop      rdi
       C3                   ret
RWD00   dq      0000000200000001h, 0000000400000003h
RWD16   dd      000000AFh ; case IG_08
        dd      000000C4h ; case IG_09
        dd      000000D9h ; case IG_10
        dd      000000EEh ; case IG_11
        dd      00000116h ; case IG_13
        dd      00000103h ; case IG_12
; Total bytes of code 319
Author: EgorBo
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@stephentoub
Copy link
Member

This would be super helpful.

@hez2010
Copy link
Contributor

hez2010 commented Aug 4, 2022

Does this PR also cover crossgen2?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

Does this PR also cover crossgen2?

Yes works for R2R. And, probably, for NativeAOT as well but afair it redirects stdout cc @MichalStrehovsky

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

One noticeable advantage over sharplab for end-users is the ability to print names for helper calls, e.g.

public class C
{
    object o;
    
    public void M(object[] a)
    {
        a[0] = 42;
        o = a;
    }
}

Sharplab:

image

JitDisasm:

; Assembly listing for method C:M(ref):this
; Emitting BLENDED_CODE for X64 CPU with AVX - Windows
; optimized code
; rsp based frame
; partially interruptible
; No PGO data

G_M000_IG01:              ;; offset=0000H
       57                   push     rdi
       56                   push     rsi
       4883EC28             sub      rsp, 40
       488BF9               mov      rdi, rcx
       488BF2               mov      rsi, rdx

G_M000_IG02:              ;; offset=000CH
       48B958E4DC2CFD7F0000 mov      rcx, 0x7FFD2CDCE458
       E835AFB15F           call     CORINFO_HELP_NEWSFAST
       C740082A000000       mov      dword ptr [rax+8], 42
       4C8BC0               mov      r8, rax
       488BCE               mov      rcx, rsi
       33D2                 xor      edx, edx
       E891F4FFFF           call     CORINFO_HELP_ARRADDR_ST
       488D4F08             lea      rcx, bword ptr [rdi+8]
       488BD6               mov      rdx, rsi
       E875F4E2FF           call     CORINFO_HELP_ASSIGN_REF
       90                   nop

G_M000_IG03:              ;; offset=003CH
       4883C428             add      rsp, 40
       5E                   pop      rsi
       5F                   pop      rdi
       C3                   ret

; Total bytes of code 67

Perhaps, it will be useful for sharplab too

@JulieLeeMSFT
Copy link
Member

@EgorBo do you plan to merge this to .NET 7?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

@EgorBo do you plan to merge this to .NET 7?

It probably does not meet the bar but I'd love to merge it in .NET 7.0, but no strong opinion

@stephentoub
Copy link
Member

stephentoub commented Aug 4, 2022

It probably does not meet the bar but I'd love to merge it in .NET 7.0, but no strong opinion

FWIW, I would love that, too :) (as long as there's no meaningful perf regressions associated with it and there are no concerns about the data this exposes).

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

no concerns about the data this exposes

Yep, we discussed this one too and came to conclusion that there is nothing to be afraid of and our competitors provide this ability too

@jkotas
Copy link
Member

jkotas commented Aug 4, 2022

Does this PR also cover crossgen2?

Yes works for R2R. And, probably, for NativeAOT

NativeAOT compiler and crossgen use exact same infrastructure. If it works for one, it should work for the other one too.

You have to specify the option on the command line instead of env variable. Is that correct?

DOTNET_NgenDisasm

We should not be injecting new life into NGen name. Can we rename this so that it does not have NGen in the name?

I am wondering why we need both NgenDisasm and JitDisasm. Can we have just one that kicks in everywhere?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

You have to specify the option on the command line instead of env variable. Is that correct?

Correct, e.g. --codegenopt NgenDisasm="Test"

We should not be injecting new life into NGen name. Can we rename this so that it does not have NGen in the name?

I fully agree, should I still keep NgenDisasm for backward compatibility?

@jkotas
Copy link
Member

jkotas commented Aug 4, 2022

I fully agree, should I still keep NgenDisasm for backward compatibility?

There is no backward compatibility to be worried about. We should delete all configs that start with NGen and use the Jit configs everywhere.

If we have any infra that use the NGen configs (I do not see any), it needs to be updated.

I see a few places that clear COMPlus_Ngen* in superpmi. They should be deleted. They are not doing anything useful anyway since NGen configs are not read from the environment.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 4, 2022

There is no backward compatibility to be worried about.

https://godbolt.org/ relies on it to print ASM for C#, but I assume it will only benefit from moving to release .NET as it won't have to compile .NET from sources and use public previews/daily builds of Release .NET instead cc @hez2010

@EgorBo EgorBo force-pushed the jit-disasm-release branch from 2849219 to 98a2a9d Compare August 4, 2022 13:57
@EgorBo EgorBo added this to the 7.0.0 milestone Aug 4, 2022
@hez2010
Copy link
Contributor

hez2010 commented Aug 4, 2022

There is no backward compatibility to be worried about.

https://godbolt.org/ relies on it to print ASM for C#.

There is nothing to worry about. We can definitely setup a new net7.0 config for godbolt while keeping net6.0 as is.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 8, 2022

Outerloop pipelines failures seem unrelated:

@jakobbotsch
Copy link
Member

I have started a non-PR run of runtime here, which will get us some more coverage for release JIT with the libraries tests.

The change is somewhat low risk for release since when m_debugInfoSize = 0, the layout just collapses back to what it was before. So even if we forgot to account for it somewhere, it is unlikely that will cause problems for release non-disasm builds.

My main concern would be that we have an idDebugOnlyInfo() use somewhere that is not conditioned on the debug info being present, but I've audited the uses and wasn't able to find any way that could happen.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 8, 2022

My main concern would be that we have an idDebugOnlyInfo() use somewhere that is not conditioned on the debug info being present, but I've audited the uses and wasn't able to find any way that could happen.

Right, I audited those too (and inserted a failfast if we entered them with .disAsm = false) locally

@EgorBo
Copy link
Member Author

EgorBo commented Aug 8, 2022

@dotnet/jit-contrib @jakobbotsch @BruceForstall PTAL

@AndyAyersMS
Copy link
Member

Seems like we should allow users to specify JitDiffableDasm too?

If you are live debugging it would be nice to see the actual addresses and such.

#ifdef DEBUG
// Should we make it diffable?
disDiffable = disComp->opts.dspDiffable;
#else // !DEBUG
// NOTE: non-debug builds are always diffable!
disDiffable = true;
#endif // !DEBUG

Might also be nice to be able to control JitDasmWithAddress and JitDasmWithAlignmentBoundaries and perhaps even JitDisasmWithGC and JitDisasmWithDebugInfo.

There are a whole bunch more like this: unwind, eh, ... but they might take a lot more work.

@omariom
Copy link
Contributor

omariom commented Aug 8, 2022

@EgorBo
Can we assume that it will always start with "; Assembly listing for method " and end with "; Total bytes of code "?

@EgorBo
Copy link
Member Author

EgorBo commented Aug 8, 2022

Seems like we should allow users to specify JitDiffableDasm too?

If you are live debugging it would be nice to see the actual addresses and such.

#ifdef DEBUG
// Should we make it diffable?
disDiffable = disComp->opts.dspDiffable;
#else // !DEBUG
// NOTE: non-debug builds are always diffable!
disDiffable = true;
#endif // !DEBUG

Might also be nice to be able to control JitDasmWithAddress and JitDasmWithAlignmentBoundaries and perhaps even JitDisasmWithGC and JitDisasmWithDebugInfo.

There are a whole bunch more like this: unwind, eh, ... but they might take a lot more work.

Yes, I had to draw the line somewhere for the initial impl since, obviously, supporting all of them is a lot more work, I am going to take a look at JitDiffableDasm separately if you don't mind. JitDasmWithAlignmentBoundaries is also nice to have - it draws nice lines 😄

@EgorBo
Copy link
Member Author

EgorBo commented Aug 8, 2022

@EgorBo Can we assume that it will always start with "; Assembly listing for method " and end with "; Total bytes of code "?

Good question, I assume some 3rd party tools are going to depend on it (parse) and we should not ever change it
So I personally is fine with the current format, if anyone has better ideas - feel free to change now

@MichalPetryka
Copy link
Contributor

MichalPetryka commented Aug 8, 2022

@EgorBo Can we assume that it will always start with "; Assembly listing for method " and end with "; Total bytes of code "?

Good question, I assume some 3rd party tools are going to depend on it (parse) and we should not ever change it So I personally is fine with the current format, if anyone has better ideas - feel free to change now

There could be a separate env var that'd enable a special stable parsable output, something like git does for tools invoking it.

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It would be nice if the number of places doing + m_debugInfoSize were more minimized, via wrapper functions or the like.

It would also be nice if some of the additional controls were available, as previously suggested, like JitStdOutFile, JitDiffableDasm, etc.

@@ -1650,10 +1649,33 @@ class emitter
#endif // MULTIREG_HAS_SECOND_GC_RET
};

// TODO-Cleanup: Uses of stack-allocated instrDescs should be refactored to be unnecessary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should we eliminate stack-allocated instrDescs? It seems perfectly reasonable to allow them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are creating these temporary instrDesc simply to be able to call existing methods to emit code/do printing. That seems like a code smell that the codegen/printing methods themselves should be refactored so that we can use the specific parts we want directly instead of having to indirect through an instrDesc structure. BTW, there's just three uses of this pattern:

  • One in emitxarch.cpp that wants to call an emit method. It already has this same cleanup comment.
  • One in emitarm.cpp and emitarm64.cpp for printing LARGEJMP instructions.

{
private:
instrDescDebugInfo* idDebugInfo;
alignas(alignof(T)) char idStorage[sizeof(T)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the static_assert_no_msg below, isn't this alignas not useful? Or equivalent to alignas(sizeof(instrDescDebugInfo*))?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, some future instrDesc could have larger-than-pointer alignment requirement. That would certainly require some work to support and I just want it to be noisy that this is a place that would need to be fixed.

@kunalspathak
Copy link
Member

Started to review, but it seems we are not printing PerfScore yet?

@kunalspathak
Copy link
Member

It would be nice if the number of places doing + m_debugInfoSize were more minimized, via wrapper functions or the like.

I agree with @BruceForstall . There are too many places where we are doing + m_debugInfoSize and it is easy to forget doing that in future. A wrapper function will be helpful.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Consolidate most uses of m_debugInfoSize into these functions.
@jakobbotsch
Copy link
Member

I pushed a commit that adds emitFirstInstrDesc and emitAdvanceInstrDesc and uses these in place of the manual castto/buffer accesses, which consolidates most uses of m_debugInfoSize.

Copy link
Member

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BruceForstall
Copy link
Member

I pushed a commit that adds emitFirstInstrDesc and emitAdvanceInstrDesc and uses these in place of the manual castto/buffer accesses, which consolidates most uses of m_debugInfoSize.

The functions are a nice improvement.

@jakobbotsch
Copy link
Member

Does the JIT dll import table change? (I.e., are there any new dependencies in the Release build?)

We get two new IAT entries on Windows: __stdio_common_vsprintf_s and strnlen.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 10, 2022

Merging now. We're going to keep eyes on TP-related benchmarks (e.g. "Crossgen2 Throughput Trends" page) in coming weeks.

Kudos to @jakobbotsch for mitigating all the initial TP/Memory regressions 🎉

@EgorBo EgorBo merged commit 87d5ece into dotnet:main Aug 10, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.