Skip to content

Commit e451fb2

Browse files
vargazmigueldeicaza
authored andcommitted
[jit] Always pass the imt arg to interface calls in gsharedvt methods. Fixes #22624.
1 parent db71bc1 commit e451fb2

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

mono/mini/gshared.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,47 @@ public static int test_0_virtual_generic () {
944944
return 0;
945945
}
946946

947+
public interface IFace1<T> {
948+
void m1 ();
949+
void m2 ();
950+
void m3 ();
951+
void m4 ();
952+
void m5 ();
953+
}
954+
955+
public class ClassIFace<T> : IFace1<T> {
956+
public void m1 () {
957+
}
958+
public void m2 () {
959+
}
960+
public void m3 () {
961+
}
962+
public void m4 () {
963+
}
964+
public void m5 () {
965+
}
966+
}
967+
968+
interface IFaceIFaceCall {
969+
void call<T, T2> (IFace1<object> iface);
970+
}
971+
972+
class MakeIFaceCall : IFaceIFaceCall {
973+
public void call<T, T2> (IFace1<object> iface) {
974+
iface.m1 ();
975+
}
976+
}
977+
978+
// Check normal interface calls from gsharedvt call to fully instantiated methods
979+
public static int test_0_instatiated_iface_call () {
980+
ClassIFace<object> c1 = new ClassIFace<object> ();
981+
982+
IFaceIFaceCall c = new MakeIFaceCall ();
983+
984+
c.call<object, int> (c1);
985+
return 0;
986+
}
987+
947988
[MethodImplAttribute (MethodImplOptions.NoInlining)]
948989
static string to_string<T, T2>(T t, T2 t2) {
949990
return t.ToString ();

mono/mini/method-to-ir.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8411,6 +8411,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
84118411
cmethod, MONO_RGCTX_INFO_METHOD);
84128412
/* This is not needed, as the trampoline code will pass one, and it might be passed in the same reg as the imt arg */
84138413
vtable_arg = NULL;
8414+
} else if ((cmethod->klass->flags & TYPE_ATTRIBUTE_INTERFACE) && !imt_arg) {
8415+
/* This can happen when we call a fully instantiated iface method */
8416+
imt_arg = emit_get_rgctx_method (cfg, context_used,
8417+
cmethod, MONO_RGCTX_INFO_METHOD);
8418+
vtable_arg = NULL;
84148419
}
84158420
}
84168421

0 commit comments

Comments
 (0)