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
3 changes: 2 additions & 1 deletion src/mono/mono/mini/jit-icalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,8 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl
break;
case MONO_GSHAREDVT_CONSTRAINT_CALL_TYPE_REF:
/* Calling a ref method with a ref receiver */
this_arg = *(gpointer*)mp;
/* Static calls don't have this arg */
this_arg = m_method_is_static (cmethod) ? NULL : *(gpointer*)mp;
m = info->method;
break;
default:
Expand Down
7 changes: 1 addition & 6 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -3884,13 +3884,8 @@ handle_constrained_gsharedvt_call (MonoCompile *cfg, MonoMethod *cmethod, MonoMe
int addr_reg;

if (mini_is_gsharedvt_type (fsig->params [i])) {
MonoInst *is_deref;
int deref_arg_reg;
ins = mini_emit_get_gsharedvt_info_klass (cfg, mono_class_from_mono_type_internal (fsig->params [i]), MONO_RGCTX_INFO_CLASS_BOX_TYPE);
deref_arg_reg = alloc_preg (cfg);
/* deref_arg = BOX_TYPE != MONO_GSHAREDVT_BOX_TYPE_VTYPE */
EMIT_NEW_BIALU_IMM (cfg, is_deref, OP_ISUB_IMM, deref_arg_reg, ins->dreg, 1);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, is_gsharedvt_ins->dreg, i, is_deref->dreg);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI1_MEMBASE_REG, is_gsharedvt_ins->dreg, i, ins->dreg);
} else if (has_gsharedvt) {
MONO_EMIT_NEW_STORE_MEMBASE_IMM (cfg, OP_STOREI1_MEMBASE_IMM, is_gsharedvt_ins->dreg, i, 0);
}
Expand Down
44 changes: 44 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_94467/Runtime_94467.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 Xunit;

public static class Runtime_94467
{
public interface ITypeChecker
{
static abstract bool Test<T>(T value);
}

public interface IHandler
{
bool Test<T>(T value);
}

public struct TypeChecker : ITypeChecker
{
public static bool Test<T>(T value) => true;
}

public class Handler<TChecker> : IHandler where TChecker : ITypeChecker
{
public bool Test<T>(T value) => TChecker.Test(value);
}

public static IHandler GetHandler() => new Handler<TypeChecker>();

[Fact]
public static int Test()
{
try {
var handler = GetHandler();
if (handler.Test<bool>(true) && handler.Test<bool?>(true))
return 100;
else
return 101;
} catch (Exception) {
return -1;
}
}
}
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>