Repository navigation
[release/11.0] Home DIM instantiating thunks on System.Object - #136148
Merged
Merged
Conversation
Fixes #136073 These need to be homed on something that is not generic so we cannot place them on the interface itself: it causes issues around whether these require instantiating argument (they don't) that requires lots of special casing to back out. This is probably the cleanest local fix. It doesn't work for the multi-obj file mode (these now all look like they should be compiled into CoreLib.obj). We can live with that, considering everything else.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
jkotas
approved these changes
Oct 20, 2026
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
The trap from #136073 is still in the GA release, so this backport is still needed: the minimal repro from that issue ends with Environment: SDK
So the Program.csusing System;
using System.Runtime.CompilerServices;
Console.WriteLine("runtime " + System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription);
Console.WriteLine(Create<object>().ToString(null, null));
Console.WriteLine(Create<string>().ToString(null, null));
Console.WriteLine("done");
[MethodImpl(MethodImplOptions.NoInlining)]
static IFormattable Create<T>() => new Receiver<T>();
interface ITarget { Type Identity(Type type); }
interface IDefault<T> : IFormattable
{
#if NOINLINE
[MethodImpl(MethodImplOptions.NoInlining)]
#else
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
string IFormattable.ToString(string? format, IFormatProvider? provider)
=> ((ITarget)this).Identity(typeof(T)).Name;
}
class Receiver<T> : IDefault<T>, ITarget
{
public Type Identity(Type type) => type;
}
|
Member
|
/ba-g failures known |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #136128 to release/11.0
/cc @MichalStrehovsky
Customer Impact
#136073 - default interface method instantiating thunks need to be homed on a different type but they're conceptually instance methods on the interface. Inlining into these thunks can produce bad optimizations. In this case, RyuJIT optimized out "impossible" code path that is actually possible.
Regression
We have always reported these on the "wrong" type, this was triggered by more inlining.
Testing
Added targeted regression test. This requires interaction of at least two optimizations (first we need to inline, and then make a decision about
this).Risk
The risk should be low, the fix was straightforward and didn't require any adjustments with our existing DIM testing.
IMPORTANT: If this backport is for a servicing release, please verify that:
release/X.0-staging, notrelease/X.0.release/X.0(no-stagingsuffix).Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.