summaryrefslogtreecommitdiff
path: root/tests/src/JIT
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/JIT')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.cs201
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.csproj49
2 files changed, 250 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.cs b/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.cs
new file mode 100644
index 0000000000..5d4983e320
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.cs
@@ -0,0 +1,201 @@
+using System;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+
+// The test revealed some problems of GCStress infrastructure on platforms with multi reg returns (arm64, amd64 Unix).
+// It required GCStress=0xc and GcStressOnDirectCalls=1 to hit issues. The issues were with saving GC pointers in the return registers.
+// The GC infra has to correctly mark registers with pointers as alive and must not report registers without pointers.
+
+#if BIT32
+using nint = System.Int32;
+#else
+using nint = System.Int64;
+#endif
+
+namespace GitHub_23199
+{
+ public class Program
+ {
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestCrossgenedReturnWith2PointersStruct()
+ {
+ ProcessStartInfo pi = new ProcessStartInfo();
+ // pi.Environment calls crossgened HashtableEnumerator::get_Entry returning struct that we need.
+ Console.WriteLine(pi.Environment.Count);
+ return pi;
+ }
+
+ struct TwoPointers
+ {
+ public Object a;
+ public Object b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static TwoPointers GetTwoPointersStruct()
+ {
+ var a = new TwoPointers();
+ a.a = new String("TestTwoPointers");
+ a.b = new string("Passed");
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestTwoPointers()
+ {
+ var a = GetTwoPointersStruct(); // Report both.
+ Console.WriteLine(a.a + " " + a.b);
+ return a;
+ }
+
+ struct OnePointer
+ {
+ public Object a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static TwoPointers GetOnePointer()
+ {
+ var a = new TwoPointers();
+ a.a = new String("TestOnePointer Passed");
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestOnePointer()
+ {
+ var a = GetOnePointer(); // Report one.
+ Console.WriteLine(a.a);
+ return a;
+ }
+
+ struct FirstPointer
+ {
+ public Object a;
+ public nint b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static FirstPointer GetFirstPointer()
+ {
+ var a = new FirstPointer();
+ a.a = new String("TestFirstPointer Passed");
+ a.b = 100;
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestFirstPointer()
+ {
+ var a = GetFirstPointer(); // Report the first field, do not report the second.
+ Console.WriteLine(a.a);
+ return a;
+ }
+
+ struct SecondPointer
+ {
+ public nint a;
+ public Object b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static SecondPointer GetSecondPointer()
+ {
+ var a = new SecondPointer();
+ a.a = 100;
+ a.b = new String("TestSecondPointer Passed");
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestSecondPointer()
+ {
+ var a = GetSecondPointer(); // Report the second field, do not report the first.
+ Console.WriteLine(a.b);
+ return a;
+ }
+
+ struct NoPointer1
+ {
+ public nint a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static NoPointer1 GetNoPointer1()
+ {
+ var a = new NoPointer1();
+ a.a = 100;
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestNoPointer1()
+ {
+ var a = GetNoPointer1(); // Do not report anything.
+ Console.WriteLine("TestNoPointer1 Passed");
+ return a;
+ }
+
+ struct NoPointer2
+ {
+ public nint a;
+ public nint b;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static NoPointer2 GetNoPointer2()
+ {
+ var a = new NoPointer2();
+ a.a = 100;
+ a.b = 100;
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestNoPointer2()
+ {
+ NoPointer2 a = GetNoPointer2(); // Do not report anything.
+ Console.WriteLine("TestNoPointer2 Passed");
+ return a;
+ }
+
+ struct ThirdPointer
+ {
+ public nint a;
+ public nint b;
+ public Object c;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static ThirdPointer GetThirdPointer()
+ {
+ var a = new ThirdPointer();
+ a.a = 100;
+ a.b = 100;
+ a.c = new String("TestThirdPointer Passed");
+ return a;
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ static Object TestThirdPointer()
+ {
+ ThirdPointer a = GetThirdPointer(); // Do not return in registers.
+ Console.WriteLine(a.c);
+ return a;
+ }
+
+
+ static int Main(string[] args)
+ {
+ TestCrossgenedReturnWith2PointersStruct();
+ TestTwoPointers();
+ TestOnePointer();
+ TestFirstPointer();
+ TestSecondPointer();
+ TestNoPointer1();
+ TestNoPointer2();
+ TestThirdPointer();
+ return 100;
+ }
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.csproj
new file mode 100644
index 0000000000..273893797e
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_23199/GitHub_23199.csproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(PointerSize)' == '32' ">
+ <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ </PropertyGroup>
+ <!-- Default configurations to help VS understand the configurations -->
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+ <ItemGroup>
+ <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+ <Visible>False</Visible>
+ </CodeAnalysisDependentAssemblyPaths>
+ </ItemGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+ </ItemGroup>
+ <PropertyGroup>
+ <CLRTestBatchPreCommands><![CDATA[
+$(CLRTestBatchPreCommands)
+set COMPlus_GcStressOnDirectCalls=1
+set COMPlus_GcStress=0xc
+]]></CLRTestBatchPreCommands>
+ <BashCLRTestPreCommands><![CDATA[
+$(BashCLRTestPreCommands)
+export COMPlus_GcStressOnDirectCalls=1
+export COMPlus_GcStress=0xc
+]]></BashCLRTestPreCommands>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="$(MSBuildProjectName).cs" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>