From 3e9938421cfdced67b98ec414cda751a5d32b2e2 Mon Sep 17 00:00:00 2001 From: Jo Shields Date: Sat, 13 Jun 2015 10:06:00 +0100 Subject: [PATCH] Cherry pick ae495e8bd485f48ecdb7e53d7e98771220f31997 to fix #29665 Former-commit-id: d87e8c2e3904faed64a7d8e2a5fe9c5b70be7ddf --- ...ort-for-callvirt-delegates-with-a-vt.patch | 71 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 72 insertions(+) create mode 100644 debian/patches/0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch diff --git a/debian/patches/0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch b/debian/patches/0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch new file mode 100644 index 0000000000..236055bf1f --- /dev/null +++ b/debian/patches/0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch @@ -0,0 +1,71 @@ +From ae495e8bd485f48ecdb7e53d7e98771220f31997 Mon Sep 17 00:00:00 2001 +From: Zoltan Varga +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) diff --git a/debian/patches/series b/debian/patches/series index bc84ce1b06..f0d3ae4c73 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,2 @@ +0001-runtime-Fix-support-for-callvirt-delegates-with-a-vt.patch rename-and-package-symbolicate.patch