-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve getExactClasses to support classes as base types (#92440)
Fixes #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 ```
- Loading branch information
1 parent
f61d3c7
commit e0a4bdd
Showing
2 changed files
with
45 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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