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.
- Loading branch information
1 parent
11fbd15
commit 7adc06c
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/tests/Regressions/coreclr/GitHub_87597/GitHub_87597.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,47 @@ | ||
// 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; | ||
|
||
// Class init for devirtualized calls triggered by PGO does not behave correctly | ||
// This test requires a class initializer on both the interface and on the type in use | ||
// and requires that type to be generic | ||
|
||
public class GitHub_87597 | ||
{ | ||
public interface IFace | ||
{ | ||
static IFace() {} | ||
void Method(); | ||
} | ||
|
||
public class GenericType<T> : IFace | ||
{ | ||
static GenericType() | ||
{ | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public void Method() | ||
{ | ||
} | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
public static void TestL1(IFace iface) | ||
{ | ||
iface.Method(); | ||
} | ||
|
||
public static int Main() | ||
{ | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
System.Threading.Thread.Sleep(16); | ||
TestL1(new GenericType<string>()); | ||
} | ||
|
||
return 100; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/tests/Regressions/coreclr/GitHub_87597/GitHub_87597.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,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileName).cs" /> | ||
</ItemGroup> | ||
</Project> |