forked from dotnet/coreclr
-
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.
Fix GC reporting for slow tail call arguments of type
Span<T>
Fixes https://github.com/dotnet/coreclr/issues/9032: - Refactored by-ref-like method table walking to find offsets of by-ref pointers in siginfo.hpp/cpp - Reused that for appending GC layout when creating the copy-args helper for a slow tail call
- Loading branch information
Showing
5 changed files
with
138 additions
and
39 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
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
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
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,53 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Reflection; | ||
using System.Reflection.Emit; | ||
|
||
internal static class Program | ||
{ | ||
private static int Main() | ||
{ | ||
DynamicMethod dm = new DynamicMethod("TailCaller", typeof(void), new Type[] { typeof(Span<int>) }); | ||
ILGenerator il = dm.GetILGenerator(); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Ldarg_0); | ||
il.Emit(OpCodes.Tailcall); | ||
il.Emit(OpCodes.Call, typeof(Program).GetMethod("TailCallee", BindingFlags.Static | BindingFlags.NonPublic)); | ||
il.Emit(OpCodes.Ret); | ||
|
||
var tailCaller = (ActionOfSpanOfInt)dm.CreateDelegate(typeof(ActionOfSpanOfInt)); | ||
|
||
try | ||
{ | ||
for (int i = 0; i < 1000; ++i) | ||
{ | ||
GC.KeepAlive(new object()); | ||
tailCaller(new Span<int>(new int[] { 42 })); | ||
GC.KeepAlive(new object()); | ||
} | ||
} | ||
catch (ArgumentException) | ||
{ | ||
return 1; // fail | ||
} | ||
|
||
return 100; // pass | ||
} | ||
|
||
private static void TailCallee(Span<int> a, Span<int> b, Span<int> c, Span<int> d, Span<int> e) | ||
{ | ||
GC.Collect(); | ||
for (int i = 0; i < 10000; i++) | ||
GC.KeepAlive(new object()); | ||
if (a[0] != 42 || b[0] != 42 || c[0] != 42 || d[0] != 42 || e[0] != 42) | ||
throw new ArgumentException(); | ||
} | ||
|
||
private delegate void ActionOfSpanOfInt(Span<int> x); | ||
} |
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,29 @@ | ||
<?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>{9C964267-06FB-4A77-BC33-2E3A6F3A1648}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<CLRTestKind>BuildAndRun</CLRTestKind> | ||
<CLRTestPriority>1</CLRTestPriority> | ||
</PropertyGroup> | ||
<!-- Default configurations to help VS understand the configurations --> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup> | ||
<ItemGroup> | ||
<CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> | ||
<Visible>False</Visible> | ||
</CodeAnalysisDependentAssemblyPaths> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<!-- Add Compile Object Here --> | ||
<Compile Include="SlowTailCallArgs.cs" /> | ||
</ItemGroup> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
</Project> |