Skip to content

Commit

Permalink
2010-04-13 Zoltan Varga <vargaz@gmail.com>
Browse files Browse the repository at this point in the history
	* 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
  • Loading branch information
vargaz committed Apr 13, 2010
1 parent 39e3e08 commit c57cdde
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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
Expand Down
44 changes: 44 additions & 0 deletions mono/mini/iltests.il.in
Expand Up @@ -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
}
}
3 changes: 3 additions & 0 deletions mono/mini/method-to-ir.c
Expand Up @@ -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);
Expand Down

0 comments on commit c57cdde

Please sign in to comment.