Improve getExactClasses to support classes as base types#92440
Merged
jkotas merged 1 commit intodotnet:mainfrom Sep 22, 2023
Merged
Improve getExactClasses to support classes as base types#92440jkotas merged 1 commit intodotnet:mainfrom
jkotas merged 1 commit intodotnet:mainfrom
Conversation
Fixes dotnet#88547 ```csharp using System.Runtime.CompilerServices; public class ClassA { public virtual int GetValue() => 42; } public class ClassB : ClassA { // we don't even need to override GetValue here } class MyClass { static void Main() { Test(new ClassB()); } [MethodImpl(MethodImplOptions.NoInlining)] static int Test(ClassA c) => c.GetValue(); } ``` Old codegen: ``` ; Method MyClass:Test(ClassA):int (FullOpts) sub rsp, 40 mov rax, qword ptr [rcx] call [rax+30H]ClassA:GetValue():int:this nop add rsp, 40 ret ; Total bytes of code: 16 ``` New codegen: ``` 00007FF66DD8AFB0 cmp dword ptr [rcx],ecx 00007FF66DD8AFB2 mov eax,2Ah 00007FF66DD8AFB7 ret ```
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas Issue DetailsFixes #88547 using System.Runtime.CompilerServices;
public class ClassA
{
public virtual int GetValue() => 42;
}
public class ClassB : ClassA
{
// we don't even need to override GetValue here
}
class MyClass
{
static void Main()
{
Test(new ClassB());
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int Test(ClassA c) => c.GetValue();
}Old codegen: New codegen: Cc @dotnet/ilc-contrib @EgorBo
|
Member
Author
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Member
|
Love it! It should also pick up other jit opts like |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #88547
Old codegen:
New codegen:
Cc @dotnet/ilc-contrib @EgorBo