Backport of r121496.
* liveness.c (mono_analyze_liveness): Avoid eliminating the 'this' var in
gshared code. Fixes #458947.
* generics.cs: Add a test.
svn path=/branches/mono-2-2/mono/; revision=121497
+2008-12-14 Zoltan Varga <vargaz@gmail.com>
+
+ Backport of r121496.
+
+ * liveness.c (mono_analyze_liveness): Avoid eliminating the 'this' var in
+ gshared code. Fixes #458947.
+
+ * generics.cs: Add a test.
+
2008-12-12 Zoltan Varga <vargaz@gmail.com>
Backport of r121457.
return the_type == typeof (string) ? 0 : 1;
}
+ public static int test_0_throw_dead_this () {
+ new Foo<string> ("").throw_dead_this ();
+ return 0;
+ }
+
public static Type the_type;
public void ldvirtftn<T> () {
}
}
+ public void throw_dead_this () {
+ try {
+ new SomeClass().ThrowAnException();
+ }
+ catch {
+ }
+ }
+
public T1 get_default () {
return default (T1);
}
}
+ public class SomeClass {
+ public void ThrowAnException() {
+ throw new Exception ("Something went wrong");
+ }
+ }
+
public interface IMyHandler {
object Bar<T>();
}
for (i = 0; i < max_vars; i ++) {
MonoMethodVar *vi = MONO_VARINFO (cfg, i);
if (cfg->varinfo [vi->idx]->opcode == OP_ARG) {
- if (vi->range.last_use.abs_pos == 0 && !(cfg->varinfo [vi->idx]->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT)))
- cfg->varinfo [vi->idx]->flags |= MONO_INST_IS_DEAD;
+ if (vi->range.last_use.abs_pos == 0 && !(cfg->varinfo [vi->idx]->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT))) {
+ /*
+ * Can't eliminate the this variable in gshared code, since
+ * it is needed during exception handling to identify the
+ * method.
+ * It is better to check for this here instead of marking the variable
+ * VOLATILE, since that would prevent it from being allocated to
+ * registers.
+ */
+ if (!(cfg->generic_sharing_context && mono_method_signature (cfg->method)->hasthis && cfg->varinfo [vi->idx] == cfg->args [0]))
+ cfg->varinfo [vi->idx]->flags |= MONO_INST_IS_DEAD;
+ }
vi->range.first_use.abs_pos = 0;
}
}