forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: Fix GenTreeCall::Equals for virtual vs static calls (dotnet#77981)
Fix dotnet#77710
- Loading branch information
1 parent
32c7147
commit 62837e5
Showing
3 changed files
with
94 additions
and
0 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
79 changes: 79 additions & 0 deletions
79
src/tests/JIT/Regression/JitBlue/Runtime_77710/Runtime_77710.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
public class Runtime_77710 | ||
{ | ||
public static int Main() | ||
{ | ||
return Test(new Derived()); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static int Test(Base b) | ||
{ | ||
b.M(callBase: false, recursing: false); | ||
b.M(callBase: true, recursing: false); | ||
|
||
int result = 100; | ||
|
||
if (Base.BaseCalls != 1) | ||
{ | ||
Console.WriteLine("FAIL: Expected BaseCalls to be 1, is actually {0}", Base.BaseCalls); | ||
result = -1; | ||
} | ||
|
||
if (Derived.DerivedCalls != 1) | ||
{ | ||
Console.WriteLine("FAIL: Expected DerivedCalls to be 1, is actually {0}", Derived.DerivedCalls); | ||
result = -1; | ||
} | ||
|
||
if (result == 100) | ||
{ | ||
Console.WriteLine("PASS"); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
private class Base | ||
{ | ||
public static int BaseCalls; | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public virtual int M(bool callBase, bool recursing) | ||
{ | ||
BaseCalls++; | ||
return 0; | ||
} | ||
} | ||
|
||
private class Derived : Base | ||
{ | ||
public static int DerivedCalls; | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public override int M(bool callBase, bool recursing) | ||
{ | ||
if (recursing) | ||
{ | ||
DerivedCalls++; | ||
return 0; | ||
} | ||
|
||
if (callBase) | ||
{ | ||
base.M(false, true); | ||
} | ||
else | ||
{ | ||
M(false, true); | ||
} | ||
|
||
return 0; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_77710/Runtime_77710.csproj
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |