Repository navigation
Closed
Description
Why DecimalExtensions:Round is not getting inlined? I followed instructions here https://github.com/dotnet/coreclr/blob/master/Documentation/building/viewing-jit-dumps.md to get the jit dump. I published the program in release. As you can see it still calls DecimalExtensions:Round instead of calling Decimal:Round directly.
using System;
using System.Runtime.CompilerServices;
public static class DecimalExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)] // doesn't help
public static decimal Round(this decimal @this)
{
return decimal.Round(@this);
}
}
public static class Program
{
public static void Main()
{
Console.WriteLine(1.2134m.Round());
Console.WriteLine(decimal.Round(1.2134m));
}
}The dump:
G_M20519_IG01: ; func=00, offs=000000H, size=0013H, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref, nogc <-- Prolog IG
IN002e: 000000 push rbp
IN002f: 000001 sub rsp, 192
IN0030: 000008 vzeroupper
IN0031: 00000B lea rbp, [rsp+C0H]
G_M20519_IG02: ; offs=000013H, size=00D3H, gcrefRegs=00000000 {}, byrefRegs=00000000 {}, byref
IN0001: 000013 lea rcx, bword ptr [V01 rbp-10H]
IN0002: 000017 vxorps xmm0, xmm0
IN0003: 00001C vmovdqu qword ptr [rcx], xmm0
IN0004: 000021 xor ecx, ecx
IN0005: 000023 mov dword ptr [V00+0x20 rsp+20H], ecx
IN0006: 000027 mov dword ptr [V00+0x28 rsp+28H], 4
IN0007: 00002F lea rcx, bword ptr [V01 rbp-10H]
IN0008: 000033 mov edx, 0x2F66
IN0009: 000038 xor r8d, r8d
IN000a: 00003B xor r9d, r9d
IN000b: 00003E call Decimal:.ctor(int,int,int,bool,ubyte):this
IN000c: 000043 lea rcx, bword ptr [V02 rbp-20H]
IN000d: 000047 mov qword ptr [V06 rbp-58H], rcx
IN000e: 00004B vmovdqu xmm0, qword ptr [V01 rbp-10H]
IN000f: 000051 vmovdqu qword ptr [V05 rbp-50H], xmm0
IN0010: 000057 mov rcx, qword ptr [V06 rbp-58H]
IN0011: 00005B lea rdx, bword ptr [V05 rbp-50H]
IN0012: 00005F call DecimalExtensions:Round(struct):struct
IN0013: 000064 vmovdqu xmm0, qword ptr [V02 rbp-20H]
IN0014: 00006A vmovdqu qword ptr [V07 rbp-68H], xmm0
IN0015: 000070 lea rcx, bword ptr [V07 rbp-68H]
IN0016: 000074 call Console:WriteLine(struct)
IN0017: 000079 lea rcx, bword ptr [V03 rbp-30H]
IN0018: 00007D vxorps xmm0, xmm0
IN0019: 000082 vmovdqu qword ptr [rcx], xmm0
IN001a: 000087 xor ecx, ecx
IN001b: 000089 mov dword ptr [V00+0x20 rsp+20H], ecx
IN001c: 00008D mov dword ptr [V00+0x28 rsp+28H], 4
IN001d: 000095 lea rcx, bword ptr [V03 rbp-30H]
IN001e: 000099 mov edx, 0x2F66
IN001f: 00009E xor r8d, r8d
IN0020: 0000A1 xor r9d, r9d
IN0021: 0000A4 call Decimal:.ctor(int,int,int,bool,ubyte):this
IN0022: 0000A9 lea rcx, bword ptr [V04 rbp-40H]
IN0023: 0000AD mov qword ptr [V09 rbp-80H], rcx
IN0024: 0000B1 vmovdqu xmm0, qword ptr [V03 rbp-30H]
IN0025: 0000B7 vmovdqu qword ptr [V08 rbp-78H], xmm0
IN0026: 0000BD mov rcx, qword ptr [V09 rbp-80H]
IN0027: 0000C1 lea rdx, bword ptr [V08 rbp-78H]
IN0028: 0000C5 call Decimal:Round(struct):struct
IN0029: 0000CA vmovdqu xmm0, qword ptr [V04 rbp-40H]
IN002a: 0000D0 vmovdqu qword ptr [V10 rbp-90H], xmm0
IN002b: 0000D9 lea rcx, bword ptr [V10 rbp-90H]
IN002c: 0000E0 call Console:WriteLine(struct)
IN002d: 0000E5 nop
G_M20519_IG03: ; offs=0000E6H, size=0006H, epilog, nogc, emitadd
IN0032: 0000E6 lea rsp, [rbp]
IN0033: 0000EA pop rbp
IN0034: 0000EB ret
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Static methods are not getting inlined[/-][+]Methods are not getting inlined[/+]benaadams commentedon Sep 13, 2018
Try setting the environment variable
Should give more info?
bugproof commentedon Sep 13, 2018
With
COMPlus_JitPrintInlinedMethods=1:benaadams commentedon Sep 13, 2018
Guessing is with Core 2.2+; likely to be teired jitting? Try switching it off
Method needs to be called 10 times I think to recompile with inlining active with tiered Jit I believe
bugproof commentedon Sep 13, 2018
@benadams with tiered jitting switched off it seems to inline correctly, however, it's not listed when using
COMPlus_JitPrintInlinedMethods=1( the output of inlined methods doesn't change)benaadams commentedon Sep 13, 2018
With teiring enabled then it should inline on the 11th iteration of
AndyAyersMS commentedon Sep 13, 2018
Also make sure you are copying a check or debug built JIT into a release build of the runtime/framework.
The debug build of the System.Private.CoreLib will have an attribute that inhibits all jit optimization. The checked build will still contain assertion checks.
RussKeldorph commentedon Sep 17, 2018
@necronux Is this issue answered to your satisfaction? Can you close?