-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JIT: Remove GTF_CALL_M_UNMGD_THISCALL and badcode on thiscall with 0 …
- Loading branch information
1 parent
56b22b5
commit a1f1e7c
Showing
9 changed files
with
89 additions
and
22 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
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
62 changes: 62 additions & 0 deletions
62
src/tests/JIT/Directed/callconv/ThisCall/EmptyThisCallTest.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,62 @@ | ||
// 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.Reflection; | ||
using System.Text; | ||
using Xunit; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
unsafe class ThisCallNative | ||
{ | ||
[DllImport(nameof(ThisCallNative), CallingConvention = CallingConvention.ThisCall, EntryPoint = "GetWidthAsLongFromManaged")] | ||
public static extern int ThisCallWithEmptySignature(); | ||
} | ||
|
||
unsafe class EmptyThisCallTest | ||
{ | ||
public static int Main(string[] args) | ||
{ | ||
try | ||
{ | ||
delegate* unmanaged[Thiscall]<void*, int> fn = &Foo; | ||
CalliEmptyThisCall((delegate* unmanaged[Thiscall]<int>)fn); | ||
Console.WriteLine("FAIL: thiscall fptr with no args should have failed"); | ||
return -1; | ||
} | ||
catch (InvalidProgramException) | ||
{ | ||
Console.WriteLine("thiscall fptr with no args failed as expected"); | ||
} | ||
|
||
try | ||
{ | ||
PinvokeEmptyThisCall(); | ||
Console.WriteLine("FAIL: pinvoke thiscall with no args should have failed"); | ||
return -1; | ||
} | ||
catch (InvalidProgramException) | ||
{ | ||
Console.WriteLine("thiscall pinvoke with no args failed as expected"); | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[UnmanagedCallersOnly(CallConvs = new [] {typeof(CallConvThiscall)})] | ||
private static int Foo(void* a) | ||
{ | ||
return 0; | ||
} | ||
|
||
private static int CalliEmptyThisCall(delegate* unmanaged[Thiscall]<int> fn) | ||
{ | ||
return fn(); | ||
} | ||
|
||
private static void PinvokeEmptyThisCall() | ||
{ | ||
ThisCallNative.ThisCallWithEmptySignature(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/tests/JIT/Directed/callconv/ThisCall/EmptyThisCallTest.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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<CMakeProjectReference Include="../CMakeLists.txt" /> | ||
<ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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