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.
JIT: allow pinvoke calli helper in TreatAsShouldHaveRetBufArg (dotnet…
…#69927) If we have multiple cold pinvokes in return positions that return structs by value and we are merging returns, we will end up querying these calls post-morph, and may see them using CORINFO_HELP_PINVOKE_CALLI. Fixes dotnet#69612.
- Loading branch information
1 parent
c81178f
commit 9a185a7
Showing
3 changed files
with
98 additions
and
4 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
64 changes: 64 additions & 0 deletions
64
src/tests/JIT/Regression/JitBlue/Runtime_69612/Runtime_69612.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,64 @@ | ||
// 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; | ||
using System.Threading; | ||
|
||
ref struct NewReference | ||
{ | ||
public IntPtr pointer; | ||
} | ||
|
||
static unsafe class Delegates | ||
{ | ||
static Delegates() | ||
{ | ||
PyLong_FromLongLong = (delegate* unmanaged[Cdecl]<long, NewReference>)0xbadcab; | ||
z = 100; | ||
} | ||
|
||
public static delegate* unmanaged[Cdecl]<long, NewReference> PyLong_FromLongLong { get; } | ||
public static long z; | ||
} | ||
|
||
class Runtime_69612 | ||
{ | ||
static NewReference ToPython(object value, Type type) | ||
{ | ||
TypeCode tc = Type.GetTypeCode(type); | ||
|
||
switch (tc) | ||
{ | ||
case TypeCode.Byte: | ||
return PyInt_FromInt32((byte)value); | ||
case TypeCode.Int16: | ||
return PyInt_FromInt32((short)value); | ||
case TypeCode.UInt16: | ||
return PyInt_FromInt32((ushort)value); | ||
case TypeCode.Int32: | ||
return PyInt_FromInt32((int)value); | ||
default: | ||
return new NewReference(); | ||
} | ||
} | ||
|
||
static NewReference PyInt_FromInt32(int value) => PyLong_FromLongLong(value); | ||
|
||
unsafe static NewReference PyLong_FromLongLong(long value) => Delegates.PyLong_FromLongLong(value); | ||
|
||
[MethodImpl(MethodImplOptions.NoOptimization)] | ||
static int Main() | ||
{ | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
_ = ToPython(Delegates.z, typeof(long)); | ||
Thread.Sleep(15); | ||
} | ||
|
||
Thread.Sleep(50); | ||
_ = ToPython(Delegates.z, typeof(long)); | ||
return 100; | ||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/tests/JIT/Regression/JitBlue/Runtime_69612/Runtime_69612.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,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<CLRTestBatchPreCommands><![CDATA[ | ||
$(CLRTestBatchPreCommands) | ||
set COMPlus_TieredCompilation=1 | ||
set COMPlus_TieredPGO=1 | ||
set COMPlus_TC_QuickJitForLoops=1 | ||
set COMPlus_TC_OnStackReplacement=1 | ||
]]></CLRTestBatchPreCommands> | ||
<BashCLRTestPreCommands><![CDATA[ | ||
$(BashCLRTestPreCommands) | ||
export COMPlus_TieredCompilation=1 | ||
export COMPlus_TieredPGO=1 | ||
export COMPlus_TC_QuickJitForLoops=1 | ||
export COMPlus_TC_OnStackReplacement=1 | ||
]]></BashCLRTestPreCommands> | ||
</PropertyGroup> | ||
</Project> |