summaryrefslogtreecommitdiff
path: root/tests/src/JIT
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2019-06-05 17:25:24 -0700
committerGitHub <noreply@github.com>2019-06-05 17:25:24 -0700
commit3dd303f0004ed4771bc29167df30efda07e4cf7e (patch)
tree164a0fdc4a5f66dd3cecac12b1ebf20743ff0535 /tests/src/JIT
parent5d4ff2f11a87d7d434d05e72744946f48e017b11 (diff)
downloadcoreclr-3dd303f0004ed4771bc29167df30efda07e4cf7e.tar.gz
coreclr-3dd303f0004ed4771bc29167df30efda07e4cf7e.tar.bz2
coreclr-3dd303f0004ed4771bc29167df30efda07e4cf7e.zip
Fix GCStress coverage for multi reg returns. (#24826)
* Extract ReplaceInstrAfterCall. * Avoid GCStress when return multireg with pointers. Determinate when we need to protect the second register and do not cause GCStress in such cases. * Add a repro test. * Reenable MethodImplOptionsTests. * Extract IsGcCoveregeInterruptInstruction. That changes how we do checks for arm32 in `IsGcCoverageInterrupt`. * Tolerate direct call to JIT_RareDisableHelper. x86 ILStubClass:IL_STUB_PInvoke(byref,ref,int,byref):int generates it like: Generating: N119 ( 4, 7) [000118] ------------ * RETURNTRAP int REG NA IN0021: cmp dword ptr [0F9BF9F8H], 0 New Basic Block BB10 [0009] created. IN0022: je L_M6496_BB10 Call: GCvars=00000001 {V01}, gcrefRegs=00000000 {}, byrefRegs=00000000 {} IN0023: call CORINFO_HELP_STOP_FOR_GC * Support GC stress protect return 1/2/both Unix x64. * Fix arm64. Do not insert GC Stress instrucitons when we can't determinate the exact return kind. * Fix review1. * Fix review2. * Change the test as Andy suggested. * Fix some typos. * Replace all SLOT with PBYTE. * Disable assert that can fail because of multithreading.
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>