Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/coreclr/jit/objectalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,8 @@ void ObjectAllocator::AnalyzeParentStack(ArrayStack<GenTree*>* parentStack, unsi
}
else if (call->IsDelegateInvoke())
{
if (tree == call->gtArgs.GetThisArg()->GetNode())
// Explicit tail calls may use helpers that need the delegate after this frame returns.
if (!call->IsTailPrefixedCall() && (tree == call->gtArgs.GetThisArg()->GetNode()))
{
JITDUMP("Delegate invoke this...\n");
canLclVarEscapeViaParentStack = false;
Expand Down
24 changes: 24 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_136373/Runtime_136373.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Runtime_136373

open System
open System.Runtime.CompilerServices

type D = delegate of obj * obj * obj * obj * obj * obj * obj * obj -> obj

type Maker() =
[<MethodImpl(MethodImplOptions.AggressiveInlining)>]
static member Make(captured: obj) =
D(fun _ _ _ _ _ _ _ last -> if Object.ReferenceEquals(captured, last) then captured else null)

module Test =
[<MethodImpl(MethodImplOptions.NoInlining)>]
let private Invoke(value: obj) =
(Maker.Make value).Invoke(null, null, null, null, null, null, null, value)

[<EntryPoint>]
let main _ =
let value = obj()
if Object.ReferenceEquals(value, Invoke value) then 100 else 101
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RequiresProcessIsolation>true</RequiresProcessIsolation>
<Optimize>True</Optimize>
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>
<OtherFlags>--tailcalls+</OtherFlags>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).fs" />
</ItemGroup>
</Project>
Loading