Cherry pick ae495e8bd485f48ecdb7e53d7e98771220f31997 to fix #29665

This commit is contained in:
Jo Shields 2015-06-13 10:07:25 +01:00
parent 7e226537b5
commit 0d61c85358
3 changed files with 73 additions and 22 deletions

View File

@ -0,0 +1,71 @@
From ae495e8bd485f48ecdb7e53d7e98771220f31997 Mon Sep 17 00:00:00 2001
From: Zoltan Varga <vargaz@gmail.com>
Date: Wed, 6 May 2015 04:56:52 -0400
Subject: [PATCH] [runtime] Fix support for callvirt delegates with a vtype
first argument. Fixes #29665.
---
mcs/class/corlib/Test/System/DelegateTest.cs | 21 +++++++++++++++++++++
mono/metadata/marshal.c | 17 ++++++++++++-----
2 files changed, 33 insertions(+), 5 deletions(-)
Index: xamarin-pkg-mono/mcs/class/corlib/Test/System/DelegateTest.cs
===================================================================
--- xamarin-pkg-mono.orig/mcs/class/corlib/Test/System/DelegateTest.cs 2015-06-13 10:05:39.446662338 +0100
+++ xamarin-pkg-mono/mcs/class/corlib/Test/System/DelegateTest.cs 2015-06-13 10:05:39.438662337 +0100
@@ -1069,6 +1069,27 @@
action_int (42);
}
+ struct FooStruct {
+ public int i, j, k, l;
+
+ public int GetProp (int a, int b, int c, int d) {
+ return i;
+ }
+ }
+
+ delegate int ByRefDelegate (ref FooStruct s, int a, int b, int c, int d);
+
+#if MONOTOUCH
+ [Category ("NotWorking")]
+#endif
+ [Test]
+ public void CallVirtVType ()
+ {
+ var action = (ByRefDelegate)Delegate.CreateDelegate (typeof (ByRefDelegate), null, typeof (FooStruct).GetMethod ("GetProp"));
+ var s = new FooStruct () { i = 42 };
+ Assert.AreEqual (42, action (ref s, 1, 2, 3, 4));
+ }
+
class Foo {
public void Bar ()
Index: xamarin-pkg-mono/mono/metadata/marshal.c
===================================================================
--- xamarin-pkg-mono.orig/mono/metadata/marshal.c 2015-06-13 10:05:39.446662338 +0100
+++ xamarin-pkg-mono/mono/metadata/marshal.c 2015-06-13 10:05:39.442662338 +0100
@@ -3248,11 +3248,18 @@
if (callvirt) {
if (!closed_over_null) {
- mono_mb_emit_ldarg (mb, 1);
- mono_mb_emit_op (mb, CEE_CASTCLASS, target_class);
- for (i = 1; i < sig->param_count; ++i)
- mono_mb_emit_ldarg (mb, i + 1);
- mono_mb_emit_op (mb, CEE_CALLVIRT, target_method);
+ if (target_class->valuetype) {
+ mono_mb_emit_ldarg (mb, 1);
+ for (i = 1; i < sig->param_count; ++i)
+ mono_mb_emit_ldarg (mb, i + 1);
+ mono_mb_emit_op (mb, CEE_CALL, target_method);
+ } else {
+ mono_mb_emit_ldarg (mb, 1);
+ mono_mb_emit_op (mb, CEE_CASTCLASS, target_class);
+ for (i = 1; i < sig->param_count; ++i)
+ mono_mb_emit_ldarg (mb, i + 1);
+ mono_mb_emit_op (mb, CEE_CALLVIRT, target_method);
+ }
} else {
mono_mb_emit_byte (mb, CEE_LDNULL);
for (i = 0; i < sig->param_count; ++i)

View File

@ -1,20 +0,0 @@
Index: xamarin-pkg-mono/mcs/tools/xbuild/targets/Microsoft.Portable.VisualBasic_4.0.targets
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xamarin-pkg-mono/mcs/tools/xbuild/targets/Microsoft.Portable.VisualBasic_4.0.targets 2015-05-15 15:55:12.074775985 +0100
@@ -0,0 +1,5 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\Microsoft.Portable.Core.props" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
+ <Import Project="..\Microsoft.Portable.Core.targets" />
+</Project>
Index: xamarin-pkg-mono/mcs/tools/xbuild/targets/Microsoft.Portable.VisualBasic_4.5.targets
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ xamarin-pkg-mono/mcs/tools/xbuild/targets/Microsoft.Portable.VisualBasic_4.5.targets 2015-05-15 15:55:19.194775876 +0100
@@ -0,0 +1,5 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="..\Microsoft.Portable.Core.props" />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
+ <Import Project="..\Microsoft.Portable.Core.targets" />
+</Project>

View File

@ -36,7 +36,7 @@ License: LGPL-2.1 and MIT and MS-PL
Group: Development/Languages/Mono
Url: http://www.mono-project.com
Source0: http://download.mono-project.com/sources/mono/mono-%{version}.tar.bz2
#Patch0: add_missing_vb_portable_targets.patch
Patch0: 0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bison
@ -120,7 +120,7 @@ technologies that have been submitted to the ECMA for standardization.
%prep
%setup -q -n mono-%{__majorver}
#%patch0 -p1
%patch0 -p1
%build
./autogen.sh