Skip to content

Commit

Permalink
[delegates] do not use CEE_CALLVIRT for non-virtual methods (mono#11451)
Browse files Browse the repository at this point in the history
[2018-08] [delegates] do not use CEE_CALLVIRT for non-virtual methods

Backport of mono#11433.

/cc @lewurm 

Description:
  • Loading branch information
monojenkins committed Oct 30, 2018
1 parent d90fbe3 commit 8df60a2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions mcs/class/corlib/Test/System/DelegateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,6 @@ public static int DynamicInvokeClosedStaticDelegate_CB (string instance)
}

[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"));
Expand Down
3 changes: 2 additions & 1 deletion mono/metadata/marshal-ilgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -3897,7 +3897,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);
Expand Down

0 comments on commit 8df60a2

Please sign in to comment.