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
6 changes: 6 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,12 @@ bool GenTreeCall::Equals(GenTreeCall* c1, GenTreeCall* c2)
{
return false;
}

// For virtual stub calls the stub addresses must agree.
if (c1->IsVirtualStub() && (c1->gtStubCallStubAddr != c2->gtStubCallStubAddr))
{
return false;
}
}
else
{
Expand Down
43 changes: 43 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_128631/Runtime_128631.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Two shared-generic interface call sites that canonicalize to __Canon must
// not be merged by head/tail merge: each call has a distinct virtual stub
// dispatch cell, so the calls are not interchangeable.

namespace Runtime_128631;

using System.Runtime.CompilerServices;
using Xunit;

public interface IFoo<T> { object Get(); }

public class Impl : IFoo<string>, IFoo<byte[]>
{
[MethodImpl(MethodImplOptions.NoInlining)] object IFoo<string>.Get() => "STRING_VALUE";
[MethodImpl(MethodImplOptions.NoInlining)] object IFoo<byte[]>.Get() => new byte[] { 1, 2, 3 };

[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
public object Dispatch(string tag)
{
if (tag == "bytes") return ((IFoo<byte[]>)this).Get();
if (tag == "string") return ((IFoo<string>)this).Get();
return null;
}
}

public class Runtime_128631
{
[Fact]
public static int TestEntryPoint()
{
var d = new Impl();
for (int i = 0; i < 200; i++)
{
d.Dispatch("bytes");
d.Dispatch("string");
}
object r = d.Dispatch("string");
return r is string ? 100 : -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading