Skip to content

Commit

Permalink
[jit] Avoid passing a vtable argument to DIM methods when making call…
Browse files Browse the repository at this point in the history
…s out of gsharedvt methods. (mono/mono#18334)

* [jit] Avoid passing a vtable argument to DIM methods when making calls out of gsharedvt methods.

Fixes mono/mono#18276.

* Fix compilation with mcs.


Commit migrated from mono/mono@487dacc
  • Loading branch information
vargaz authored Jan 7, 2020
1 parent 0e9c83c commit 4045b47
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono/mini/Makefile.am.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/
INTERP_RUNTIME = $(MINI_RUNTIME) --interpreter
RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)

MCS = CSC_SDK_PATH_DISABLED= $(TOOLS_RUNTIME) $(CSC) -langversion:7.2 -nostdlib -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
MCS = CSC_SDK_PATH_DISABLED= $(TOOLS_RUNTIME) $(CSC) -langversion:8.0 -nostdlib -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
ILASM = $(TOOLS_RUNTIME) $(mcs_topdir)/class/lib/build/ilasm.exe

if !ENABLE_MSVC_ONLY
Expand Down
31 changes: 31 additions & 0 deletions src/mono/mono/mini/gshared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,14 @@ public static int test_0_open_delegate () {
var res = (Nullable<int>)iface.AMethod<Nullable<int>> ();
return res == 42 ? 0 : 1;
}

#if !__MonoCS__
public static int test_0_gsharedvt_out_dim () {
var c = new Outer<object>();
c.prop = new H ();
return (c.Foo () == "abcd") ? 0 : 1;
}
#endif
}

// #13191
Expand Down Expand Up @@ -2287,6 +2295,29 @@ public SparseArrayBuilder(bool initialize) : this () {
public ArrayBuilder<Marker> Markers => _markers;
}

// #18276
#if !__MonoCS__
public class Outer<Q> {
public interface ID {
string Foo () {
return null;
}
}

public ID prop;

public string Foo () {
return prop?.Foo();
}
}

public class H : Outer<object>.ID {
string Outer<object>.ID.Foo () {
return "abcd";
}
}
#endif

#if !__MOBILE__
public class GSharedTests : Tests {
}
Expand Down
5 changes: 2 additions & 3 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -7632,16 +7632,15 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
imt_arg = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
g_assert (imt_arg);
/* This is not needed, as the trampoline code will pass one, and it might be passed in the same reg as the imt arg */
vtable_arg = NULL;
} else if (mono_class_is_interface (cmethod->klass) && !imt_arg) {
/* This can happen when we call a fully instantiated iface method */
g_assert (will_have_imt_arg);
imt_arg = emit_get_rgctx_method (cfg, context_used,
cmethod, MONO_RGCTX_INFO_METHOD);
g_assert (imt_arg);
vtable_arg = NULL;
}
/* This is not needed, as the trampoline code will pass one, and it might be passed in the same reg as the imt arg */
vtable_arg = NULL;
}

if ((m_class_get_parent (cmethod->klass) == mono_defaults.multicastdelegate_class) && (!strcmp (cmethod->name, "Invoke")))
Expand Down

0 comments on commit 4045b47

Please sign in to comment.