Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2010-04-14 01:12:53 +0400
committerZoltan Varga <vargaz@gmail.com>2010-04-14 01:12:53 +0400
commitc57cdde726c358fc30b96fa532dbd55c6919a3df (patch)
tree0e7460a8995d9b3f6deb4992d74cb55c6731c686
parent39e3e0830c3ec7fd51771fd220288817f2cdb8c9 (diff)
2010-04-13 Zoltan Varga <vargaz@gmail.com>
* method-to-ir.c (mono_method_to_ir): Disable generic sharing for constrained calls where the constrained class needs a context. Fixes #595863. * iltests.il.in: Add a test. svn path=/branches/mono-2-6/mono/; revision=155330
-rw-r--r--mono/mini/ChangeLog7
-rw-r--r--mono/mini/iltests.il.in44
-rw-r--r--mono/mini/method-to-ir.c3
3 files changed, 54 insertions, 0 deletions
diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog
index 4d880d8b769..d4fab70b077 100644
--- a/mono/mini/ChangeLog
+++ b/mono/mini/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-13 Zoltan Varga <vargaz@gmail.com>
+
+ * method-to-ir.c (mono_method_to_ir): Disable generic sharing for constrained
+ calls where the constrained class needs a context. Fixes #595863.
+
+ * iltests.il.in: Add a test.
+
2010-04-10 Zoltan Varga <vargaz@gmail.com>
* debugger-agent.c (thread_commands): Add a GET_ID command to get the
diff --git a/mono/mini/iltests.il.in b/mono/mini/iltests.il.in
index 09d85a38df9..8dfe3021f1e 100644
--- a/mono/mini/iltests.il.in
+++ b/mono/mini/iltests.il.in
@@ -2460,4 +2460,48 @@ OK_2:
IL_004b: ret
}
+ .class nested private auto ansi sealed beforefieldinit Pair`2<TKey,TValue>
+ extends [mscorlib]System.ValueType
+ {
+ .field public !0 key
+ .field public !1 'value'
+ }
+
+ .method private static hidebysig
+ default bool ContentEquals<TKey,TValue> (valuetype Tests/Pair`2<!!TKey, !!TValue> v) cil managed
+ {
+ .maxstack 8
+ IL_0000: ldarga.s 0
+ IL_0006: ldnull
+ constrained. valuetype Tests/Pair`2<!!0,!!1>
+ IL_0007: callvirt instance bool class [mscorlib]System.Object::Equals(object)
+ ret
+ }
+
+ .method public static hidebysig default int32 test_0_constrained_gshared_595863 () cil managed
+ {
+ .locals init (
+ valuetype Tests/Pair`2<string, string> V_0,
+ valuetype Tests/Pair`2<string, string> V_1)
+ IL_0000: ldloca.s 0
+ IL_0002: initobj valuetype Tests/Pair`2<string,string>
+ IL_0008: ldloc.0
+ IL_0009: stloc.1
+ IL_000a: ldloca.s 1
+ IL_000c: ldstr "A"
+ IL_0011: stfld !0 valuetype Tests/Pair`2<string,string>::key
+ IL_0016: ldloca.s 1
+ IL_0018: ldstr "B"
+ IL_001d: stfld !1 valuetype Tests/Pair`2<string,string>::'value'
+ IL_0022: ldloc.1
+ IL_0023: stloc.0
+ IL_0024: ldloc.0
+ IL_0025: call bool class Tests::ContentEquals<string, string> (valuetype Tests/Pair`2<!!0,!!1>)
+ brfalse SUCCESS
+ ldc.i4.1
+ ret
+ SUCCESS:
+ ldc.i4.0
+ ret
+ }
}
diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c
index 1d21ee9f248..98ec8931b39 100644
--- a/mono/mini/method-to-ir.c
+++ b/mono/mini/method-to-ir.c
@@ -6411,6 +6411,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
* but that type doesn't override the method we're
* calling, so we need to box `this'.
*/
+ if (cfg->generic_sharing_context && mono_class_check_context_used (constrained_call))
+ GENERIC_SHARING_FAILURE (CEE_CONSTRAINED_);
+
EMIT_NEW_LOAD_MEMBASE_TYPE (cfg, ins, &constrained_call->byval_arg, sp [0]->dreg, 0);
ins->klass = constrained_call;
sp [0] = handle_box (cfg, ins, constrained_call);