diff options
author | monojenkins <jo.shields+jenkins@xamarin.com> | 2018-10-30 20:25:49 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2018-10-30 20:25:49 +0300 |
commit | 2f2615ffc88241177a55fde6ee5f1456de11e027 (patch) | |
tree | 7e48ea2893e7cc4be36263651242cfc376a8b3f5 | |
parent | 47eb7c55eb00cead810ebeec360a48e7e9547d79 (diff) |
[2018-06] [delegates] do not use CEE_CALLVIRT for non-virtual methods (#11450)
Backport of #11433.
/cc @lewurm
Description:
-rw-r--r-- | mcs/class/corlib/Test/System/DelegateTest.cs | 2 | ||||
-rw-r--r-- | mono/metadata/marshal-ilgen.c | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/mcs/class/corlib/Test/System/DelegateTest.cs b/mcs/class/corlib/Test/System/DelegateTest.cs index e0801848d2e..338201073e0 100644 --- a/mcs/class/corlib/Test/System/DelegateTest.cs +++ b/mcs/class/corlib/Test/System/DelegateTest.cs @@ -1144,8 +1144,6 @@ namespace MonoTests.System } [Test] - // Interp uses slowpath delegate invoke virtual wrapper which throws NRE also with JIT - [Category ("NotWorkingRuntimeInterpreter")] public void DynamicInvokeOpenInstanceDelegate () { var d1 = Delegate.CreateDelegate (typeof (Func<DelegateTest, int>), typeof(DelegateTest).GetMethod ("DynamicInvokeOpenInstanceDelegate_CB")); diff --git a/mono/metadata/marshal-ilgen.c b/mono/metadata/marshal-ilgen.c index f41be5a5e3f..e93b9c7b6b1 100644 --- a/mono/metadata/marshal-ilgen.c +++ b/mono/metadata/marshal-ilgen.c @@ -3817,7 +3817,8 @@ emit_delegate_invoke_internal_ilgen (MonoMethodBuilder *mb, MonoMethodSignature if (callvirt) { if (!closed_over_null) { - if (m_class_is_valuetype (target_class)) { + /* if target_method is not really virtual, turn it into a direct call */ + if (!(target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) || m_class_is_valuetype (target_class)) { mono_mb_emit_ldarg (mb, 1); for (i = 1; i < sig->param_count; ++i) mono_mb_emit_ldarg (mb, i + 1); |