Closed omariom closed 4 years ago
When the jit propagates type information "up" from an inlined callee to a virtual call site in a caller, and this leads to devirtualization (aka "late" devirtualization), then the devirtualized call can't yet be inlined.
This is mentioned as one of the future enhancements for devirtualization in dotnet/runtime#7541, and also noted for a very similar example in dotnet/coreclr#20886.
Would sure like to get this working someday... it is unfortunately not a simple change.
and also noted for a very similar example in dotnet/coreclr#20886.
Ah.. just noticed that.
Thanks to this change JIT can now devirtualize and inline virtual calls when it finds that a static readonly field has already been intialized with a reference to an instance of a sealed derived class. Like here
But if the field is hidden behind a get only property, JIT inlines the getter and devirtualizes the call but fails to inline it.
The repro:
This is
CompareInts
when it uses the field.ComparerT<int>.Default.Compare(x, y)
is replaced with the body ofint.CompareTo
:When
Default
is a property. The call is static, but not inlined.Seems like attempt to inline devirtualized call happens too late.
@AndyAyersMS, is it a known issue?