Permalink
Browse files

2008-12-24 Mark Probst <mark.probst@gmail.com>

	* mini.h: New macro for checking whether a method is final,
	i.e. whether the method or its class is marked final.

	* method-to-ir.c: Use the new macro for all final-checks
	consistently.  Fixes the crash in the System.ServiceModel tests.

2008-12-24  Mark Probst  <mark.probst@gmail.com>

	* generic-sealed-virtual.2.cs: Test case for final generic
	methods.

	* Makefile.am: Test added.

svn path=/trunk/mono/; revision=122086
  • Loading branch information...
1 parent c6d2874 commit 9a6833292818b8a55c3d50aca7c7eef7c5b786dc @schani schani committed Dec 24, 2008
View
@@ -1,3 +1,11 @@
+2008-12-24 Mark Probst <mark.probst@gmail.com>
+
+ * mini.h: New macro for checking whether a method is final,
+ i.e. whether the method or its class is marked final.
+
+ * method-to-ir.c: Use the new macro for all final-checks
+ consistently. Fixes the crash in the System.ServiceModel tests.
+
2008-12-23 Mark Probst <mark.probst@gmail.com>
* mini-exceptions.c (get_exception_catch_class): Corrected another
View
@@ -2230,7 +2230,7 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
if ((!cfg->compile_aot || enable_for_aot) &&
(!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
- ((method->flags & METHOD_ATTRIBUTE_FINAL) &&
+ (MONO_METHOD_IS_FINAL (method) &&
method->wrapper_type != MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK))) {
/*
* the method is not virtual, we just need to ensure this is not null
@@ -2265,9 +2265,7 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
}
#endif
- if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) &&
- ((method->flags & METHOD_ATTRIBUTE_FINAL) ||
- (method->klass && method->klass->flags & TYPE_ATTRIBUTE_SEALED))) {
+ if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) && MONO_METHOD_IS_FINAL (method)) {
/*
* the method is virtual, but we can statically dispatch since either
* it's class or the method itself are sealed.
@@ -6026,7 +6024,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
}
if (!(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
- (cmethod->flags & METHOD_ATTRIBUTE_FINAL)) {
+ MONO_METHOD_IS_FINAL (cmethod)) {
if (virtual)
check_this = TRUE;
virtual = 0;
@@ -6052,7 +6050,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* Calling virtual generic methods */
if (cmethod && virtual &&
(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL) &&
- !((cmethod->flags & METHOD_ATTRIBUTE_FINAL) &&
+ !(MONO_METHOD_IS_FINAL (cmethod) &&
cmethod->wrapper_type != MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK) &&
mono_method_signature (cmethod)->generic_param_count) {
MonoInst *this_temp, *this_arg_temp, *store;
@@ -6174,7 +6172,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
/* Inlining */
if ((cfg->opt & MONO_OPT_INLINE) && cmethod &&
- (!virtual || !(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL) || (cmethod->flags & METHOD_ATTRIBUTE_FINAL)) &&
+ (!virtual || !(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL) || MONO_METHOD_IS_FINAL (cmethod)) &&
mono_method_check_inlining (cfg, cmethod) &&
!g_list_find (dont_inline, cmethod)) {
int costs;
@@ -6246,7 +6244,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (context_used && !imt_arg && !array_rank &&
(!mono_method_is_generic_sharable_impl (cmethod, TRUE) ||
!mono_class_generic_sharing_enabled (cmethod->klass)) &&
- (!virtual || cmethod->flags & METHOD_ATTRIBUTE_FINAL ||
+ (!virtual || MONO_METHOD_IS_FINAL (cmethod) ||
!(cmethod->flags & METHOD_ATTRIBUTE_VIRTUAL))) {
INLINE_FAILURE;
@@ -6272,6 +6270,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
else if (*ip == CEE_CALLI)
g_assert (!vtable_arg);
else
+ /* FIXME: what the hell is this??? */
g_assert (cmethod->flags & METHOD_ATTRIBUTE_FINAL ||
!(cmethod->flags & METHOD_ATTRIBUTE_FINAL));
View
@@ -213,6 +213,7 @@ enum {
/* FIXME: Add more instructions */
#define MONO_INS_HAS_NO_SIDE_EFFECT(ins) (MONO_IS_MOVE (ins) || (ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || MONO_IS_ZERO (ins) || (ins->opcode == OP_ADD_IMM) || (ins->opcode == OP_R8CONST) || (ins->opcode == OP_LADD_IMM) || (ins->opcode == OP_ISUB_IMM) || (ins->opcode == OP_IADD_IMM) || (ins->opcode == OP_INEG) || (ins->opcode == OP_LNEG) || (ins->opcode == OP_ISUB) || (ins->opcode == OP_CMOV_IGE) || (ins->opcode == OP_ISHL_IMM) || (ins->opcode == OP_ISHR_IMM) || (ins->opcode == OP_ISHR_UN_IMM) || (ins->opcode == OP_IAND_IMM) || (ins->opcode == OP_ICONV_TO_U1) || (ins->opcode == OP_ICONV_TO_I1) || (ins->opcode == OP_SEXT_I4) || (ins->opcode == OP_LCONV_TO_U1) || (ins->opcode == OP_ICONV_TO_U2) || (ins->opcode == OP_ICONV_TO_I2) || (ins->opcode == OP_LCONV_TO_I2))
+#define MONO_METHOD_IS_FINAL(m) (((m)->flags & METHOD_ATTRIBUTE_FINAL) || ((m)->klass && ((m)->klass->flags & TYPE_ATTRIBUTE_SEALED)))
#ifdef MONO_ARCH_SIMD_INTRINSICS
View
@@ -1,3 +1,10 @@
+2008-12-24 Mark Probst <mark.probst@gmail.com>
+
+ * generic-sealed-virtual.2.cs: Test case for final generic
+ methods.
+
+ * Makefile.am: Test added.
+
2008-12-24 Rodrigo Kumpera <rkumpera@novell.com>
* bug-461941.cs: New regression test.
View
@@ -293,6 +293,7 @@ BASE_TEST_CS_SRC= \
bug-459285.2.cs \
generic-virtual-invoke.2.cs \
bug-461198.2.cs \
+ generic-sealed-virtual.2.cs \
recursive-generics.2.cs \
bug-80392.2.cs \
dynamic-method-access.2.cs \
@@ -727,7 +728,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
generic-synchronized.2.exe generic-delegate-ctor.2.exe \
generic-constrained.2.exe bug-431413.2.exe \
generic-virtual-invoke.2.exe generic-typedef.2.exe \
- generic-marshalbyref.2.exe bug-459285.2.exe bug-461198.2.exe
+ generic-marshalbyref.2.exe bug-459285.2.exe bug-461198.2.exe \
+ generic-sealed-virtual.2.exe
@for fn in $+ ; do \
echo "Testing $$fn ..."; \
MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared $$fn > $$fn.stdout || exit 1; \
@@ -0,0 +1,29 @@
+using System;
+
+public abstract class Elem {
+ public abstract Type getType<T> ();
+}
+
+public sealed class TextElem : Elem {
+ public override Type getType<T> () { return typeof (T); }
+}
+
+public class OtherTextElem : Elem {
+ public sealed override Type getType<T> () { return typeof (T); }
+}
+
+public class main {
+ public static int Main () {
+ TextElem elem = new TextElem ();
+
+ if (elem.getType<string> () != typeof (string))
+ return 1;
+
+ OtherTextElem oelem = new OtherTextElem ();
+
+ if (oelem.getType<string> () != typeof (string))
+ return 1;
+
+ return 0;
+ }
+}

0 comments on commit 9a68332

Please sign in to comment.