Skip to content
Merged
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
7 changes: 4 additions & 3 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,9 +1098,10 @@ var_types Compiler::impImportCall(OPCODE opcode,
}

// For opportunistic tailcalls we allow implicit widening, i.e. tailcalls from int32 -> int16, since the
// managed calling convention dictates that the callee widens the value. For explicit tailcalls we don't
// want to require this detail of the calling convention to bubble up to the tailcall helpers
bool allowWidening = isImplicitTailCall;
// managed calling convention dictates that the callee widens the value. For explicit tailcalls or async
// functions we don't want to require this detail of the calling convention to bubble up to helper
// infrastructure.
bool allowWidening = isImplicitTailCall && !call->AsCall()->IsAsync();
if (canTailCall &&
!impTailCallRetTypeCompatible(allowWidening, info.compRetType, info.compMethodInfo->args.retTypeClass,
info.compCallConv, callRetTyp, sig->retTypeClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ private static async Task TestSyncContextContinueAsync()
// we check IsCompleted on the awaiter).
//await WrappedYieldToThreadPool(suspend: true).ConfigureAwait(false);
//Assert.Null(SynchronizationContext.Current);

await WrappedYieldToThreadWithCustomSyncContext();
Assert.Null(SynchronizationContext.Current);
//
//await WrappedYieldToThreadWithCustomSyncContext();
//Assert.Null(SynchronizationContext.Current);
}

private static async Task WrappedYieldToThreadPool(bool suspend)
Expand Down
29 changes: 29 additions & 0 deletions src/tests/async/widening-tailcall/widening-tailcall.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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.Tasks;
using Xunit;

public class Async2WideningTailcall
{
[Fact]
public static void TestEntryPoint()
{
uint vr0 = (uint)M29().GetAwaiter().GetResult();
Assert.Equal(uint.MaxValue, vr0);
}

private static async Task<short> M29()
{
return await M40();
}

private static sbyte s_38 = -1;
private static async Task<sbyte> M40()
{
await Task.Yield();
return s_38;
}
}
8 changes: 8 additions & 0 deletions src/tests/async/widening-tailcall/widening-tailcall.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading