Skip to content

Commit

Permalink
Merge in 'release/6.0' changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnet-bot committed Mar 11, 2022
2 parents 1d1ea97 + 19b5f15 commit 8d7b562
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ private bool Get_CORINFO_METHOD_INFO(MethodDesc method, MethodIL methodIL, CORIN
methodInfo->ILCode = (byte*)GetPin(ilCode);
methodInfo->ILCodeSize = (uint)ilCode.Length;
methodInfo->maxStack = (uint)methodIL.MaxStack;
methodInfo->EHcount = (uint)methodIL.GetExceptionRegions().Length;
var exceptionRegions = methodIL.GetExceptionRegions();
methodInfo->EHcount = (uint)exceptionRegions.Length;
methodInfo->options = methodIL.IsInitLocals ? CorInfoOptions.CORINFO_OPT_INIT_LOCALS : (CorInfoOptions)0;

if (method.AcquiresInstMethodTableFromThis())
Expand All @@ -623,6 +624,24 @@ private bool Get_CORINFO_METHOD_INFO(MethodDesc method, MethodIL methodIL, CORIN
Get_CORINFO_SIG_INFO(method, sig: &methodInfo->args);
Get_CORINFO_SIG_INFO(methodIL.GetLocals(), &methodInfo->locals);

#if READYTORUN
if ((methodInfo->options & CorInfoOptions.CORINFO_GENERICS_CTXT_MASK) != 0)
{
foreach (var region in exceptionRegions)
{
if (region.Kind == ILExceptionRegionKind.Catch)
{
TypeDesc catchType = (TypeDesc)methodIL.GetObject(region.ClassToken);
if (catchType.IsCanonicalSubtype(CanonicalFormKind.Any))
{
methodInfo->options |= CorInfoOptions.CORINFO_GENERICS_CTXT_KEEP_ALIVE;
break;
}
}
}
}
#endif

return true;
}

Expand Down
35 changes: 35 additions & 0 deletions src/tests/Regressions/coreclr/GitHub_66005/test66005.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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 Program
{
[MethodImpl(MethodImplOptions.NoInlining)]
static void Test<TException>() where TException : Exception
{
try
{
throw new InvalidOperationException();
}
catch (TException)
{
return;
}
}

static int Main()
{
try
{
Test<InvalidOperationException>();
}
catch
{
return -1;
}

return 100;
}
}
9 changes: 9 additions & 0 deletions src/tests/Regressions/coreclr/GitHub_66005/test66005.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="test66005.cs" />
</ItemGroup>
</Project>

0 comments on commit 8d7b562

Please sign in to comment.