-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always use portable tailcalling mechanism for delegate tailcalls (#70269
) * Always use portable tailcalling mechanism for delegate tailcalls It is rare but possible to have delegates that point to VSD stubs. Since VSD stubs on x86 may disassemble the call-site we cannot allow tail calling these with the old mechanism. Fix #70259 * Add regression test * Calm down the test Tailcall through built-in delegates is best-effort. Instantiating stubs may break the chain and on ARM32 so may wrapper delegate stubs. The latter happens for this particular test. Change the test so that it is just verifying we do not hit the assert. * Disable regression test on Mono * Clean up some ildasm output
- v10.0.0-preview.1.25080.5
- v9.0.2
- v9.0.1
- v9.0.0
- v9.0.0-rc.2.24473.5
- v9.0.0-rc.1.24431.7
- v9.0.0-preview.7.24405.7
- v9.0.0-preview.6.24327.7
- v9.0.0-preview.5.24306.7
- v9.0.0-preview.4.24266.19
- v9.0.0-preview.3.24172.9
- v9.0.0-preview.2.24128.5
- v9.0.0-preview.1.24080.9
- v8.0.13
- v8.0.12
- v8.0.11
- v8.0.10
- v8.0.8
- v8.0.7
- v8.0.6
- v8.0.5
- v8.0.4
- v8.0.3
- v8.0.2
- v8.0.1
- v8.0.0
- v8.0.0-rc.2.23479.6
- v8.0.0-rc.1.23419.4
- v8.0.0-preview.7.23375.6
- v8.0.0-preview.6.23329.7
- v8.0.0-preview.5.23280.8
- v8.0.0-preview.4.23259.5
- v8.0.0-preview.3.23174.8
- v8.0.0-preview.2.23128.3
- v8.0.0-preview.1.23110.8
- v7.0.20
- v7.0.19
- v7.0.18
- v7.0.17
- v7.0.16
- v7.0.15
- v7.0.14
- v7.0.13
- v7.0.12
- v7.0.11
- v7.0.10
- v7.0.9
- v7.0.8
- v7.0.7
- v7.0.5
- v7.0.4
- v7.0.3
- v7.0.2
- v7.0.1
- v7.0.0
- v7.0.0-rc.2.22472.3
- v7.0.0-rc.1.22426.10
- v7.0.0-preview.7.22375.6
- v7.0.0-preview.6.22324.4
- release/7.0
1 parent
da573d1
commit caff7b0
Showing
6 changed files
with
191 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
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
48 changes: 48 additions & 0 deletions
48
src/tests/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259.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,48 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// Note: This test file is the source of the Runtime_70259.il file. It requires | ||
// InlineIL.Fody to compile. It is not used as anything but a reference of that | ||
// IL file. | ||
|
||
using InlineIL; | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
|
||
class Runtime_70259 | ||
{ | ||
private static int Main() | ||
{ | ||
// This creates an open delegate that goes through shuffle thunk and | ||
// then VSD stub. On arm32 it also goes through wrapper delegate. | ||
Func<IFace, int> del = typeof(IFace).GetMethod("Method").CreateDelegate<Func<IFace, int>>(); | ||
|
||
// We need a normal call here to get a call site of the form `call | ||
// [rel32]` which triggers the bug. | ||
return CallMe(del); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static int CallMe(Func<IFace, int> del) | ||
{ | ||
IL.Push(del); | ||
IL.Push(new C()); | ||
IL.Emit.Tail(); | ||
IL.Emit.Call(new MethodRef(typeof(Func<IFace, int>), "Invoke")); | ||
return IL.Return<int>(); | ||
} | ||
|
||
interface IFace | ||
{ | ||
int Method(); | ||
} | ||
|
||
class C : IFace | ||
{ | ||
public virtual int Method() | ||
{ | ||
return 100; | ||
} | ||
} | ||
} | ||
|
110 changes: 110 additions & 0 deletions
110
src/tests/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259.il
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,110 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
// See Runtime_70259.cs. | ||
|
||
// Microsoft (R) .NET IL Disassembler. Version 7.0.0-dev | ||
|
||
|
||
|
||
// Metadata version: v4.0.30319 | ||
.assembly extern System.Runtime | ||
{ | ||
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) // .?_....: | ||
.ver 7:0:0:0 | ||
} | ||
.assembly Runtime_70259 | ||
{ | ||
} | ||
.module Runtime_70259.dll | ||
// MVID: {78ECA09B-26A9-44BB-9FD2-D94B639A44D5} | ||
.custom instance void [System.Runtime]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) | ||
.imagebase 0x00400000 | ||
.file alignment 0x00000200 | ||
.stackreserve 0x00100000 | ||
.subsystem 0x0003 // WINDOWS_CUI | ||
.corflags 0x00000001 // ILONLY | ||
// Image base: 0x000001F5DF740000 | ||
|
||
|
||
// =============== CLASS MEMBERS DECLARATION =================== | ||
|
||
.class private auto ansi beforefieldinit Runtime_70259 | ||
extends [System.Runtime]System.Object | ||
{ | ||
.class interface abstract auto ansi nested private IFace | ||
{ | ||
.method public hidebysig newslot abstract virtual | ||
instance int32 Method() cil managed | ||
{ | ||
} // end of method IFace::Method | ||
|
||
} // end of class IFace | ||
|
||
.class auto ansi nested private beforefieldinit C | ||
extends [System.Runtime]System.Object | ||
implements Runtime_70259/IFace | ||
{ | ||
.method public hidebysig newslot virtual | ||
instance int32 Method() cil managed | ||
{ | ||
// Code size 3 (0x3) | ||
.maxstack 8 | ||
IL_0000: ldc.i4.s 100 | ||
IL_0002: ret | ||
} // end of method C::Method | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 7 (0x7) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [System.Runtime]System.Object::.ctor() | ||
IL_0006: ret | ||
} // end of method C::.ctor | ||
|
||
} // end of class C | ||
|
||
.method private hidebysig static int32 | ||
Main() cil managed | ||
{ | ||
.entrypoint | ||
// Code size 31 (0x1f) | ||
.maxstack 8 | ||
IL_0000: ldtoken Runtime_70259/IFace | ||
IL_0005: call class [System.Runtime]System.Type [System.Runtime]System.Type::GetTypeFromHandle(valuetype [System.Runtime]System.RuntimeTypeHandle) | ||
IL_000a: ldstr "Method" | ||
IL_000f: call instance class [System.Runtime]System.Reflection.MethodInfo [System.Runtime]System.Type::GetMethod(string) | ||
IL_0014: callvirt instance !!0 [System.Runtime]System.Reflection.MethodInfo::CreateDelegate<class [System.Runtime]System.Func`2<class Runtime_70259/IFace,int32>>() | ||
IL_0019: call int32 Runtime_70259::CallMe(class [System.Runtime]System.Func`2<class Runtime_70259/IFace,int32>) | ||
IL_001e: ret | ||
} // end of method Runtime_70259::Main | ||
|
||
.method private hidebysig static int32 | ||
CallMe(class [System.Runtime]System.Func`2<class Runtime_70259/IFace,int32> del) cil managed noinlining | ||
{ | ||
// Code size 14 (0xe) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: newobj instance void Runtime_70259/C::.ctor() | ||
IL_0006: tail. | ||
IL_0008: call instance !1 class [System.Runtime]System.Func`2<class Runtime_70259/IFace,int32>::Invoke(!0) | ||
IL_000d: ret | ||
} // end of method Runtime_70259::CallMe | ||
|
||
.method public hidebysig specialname rtspecialname | ||
instance void .ctor() cil managed | ||
{ | ||
// Code size 7 (0x7) | ||
.maxstack 8 | ||
IL_0000: ldarg.0 | ||
IL_0001: call instance void [System.Runtime]System.Object::.ctor() | ||
IL_0006: ret | ||
} // end of method Runtime_70259::.ctor | ||
|
||
} // end of class Runtime_70259 | ||
|
||
// ============================================================= | ||
|
||
// *********** DISASSEMBLY COMPLETE *********************** |
12 changes: 12 additions & 0 deletions
12
src/tests/JIT/Regression/JitBlue/Runtime_70259/Runtime_70259.ilproj
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,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.IL"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<DebugType>Full</DebugType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).il" /> | ||
</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