2002-05-16 Dietmar Maurer <dietmar@ximian.com>
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 16 May 2002 06:49:16 +0000 (06:49 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Thu, 16 May 2002 06:49:16 +0000 (06:49 -0000)
* jit.c (mono_find_final_block): make it work with mcs

svn path=/trunk/mono/; revision=4678

mono/jit/ChangeLog
mono/jit/jit.c
mono/tests/Makefile.am
mono/tests/exception12.cs [new file with mode: 0644]

index ce08a1bba549e0b36d0a1cd4fcff377ede1e3de5..689720ad80bb1c4f806cbb9153a0013d6468805d 100644 (file)
@@ -1,5 +1,7 @@
 2002-05-16  Dietmar Maurer  <dietmar@ximian.com>
 
+       * jit.c (mono_find_final_block): make it work with mcs
+
        * x86.brg: buf fix. if exception variable is allocated to a register. 
 
        * jit.c (mono_find_final_block): bug fix.
index c1cccf50df6a2fd809e48fd0c9260a34fa7c6632..0cf36d3e6be55f8944a7282c95cd9b35c1f47221 100644 (file)
@@ -1095,7 +1095,7 @@ mono_cfg_free (MonoFlowGraph *cfg)
 }
 
 static MonoBBlock *
-mono_find_final_block (MonoFlowGraph *cfg, guint32 ip, int type)
+mono_find_final_block (MonoFlowGraph *cfg, guint32 ip, guint32 target, int type)
 {
        MonoMethod *method = cfg->method;
        MonoBytecodeInfo *bcinfo = cfg->bcinfo;
@@ -1105,15 +1105,13 @@ mono_find_final_block (MonoFlowGraph *cfg, guint32 ip, int type)
 
        for (i = 0; i < header->num_clauses; ++i) {
                clause = &header->clauses [i];
-               if (MONO_OFFSET_IN_HANDLER (clause, ip))
-                       return NULL;
 
-               if (MONO_OFFSET_IN_CLAUSE (clause, ip)) {
+               if (MONO_OFFSET_IN_CLAUSE (clause, ip) && 
+                   (!MONO_OFFSET_IN_CLAUSE (clause, target))) {
                        if (clause->flags & type) {
                                g_assert (bcinfo [clause->handler_offset].is_block_start);
                                return &cfg->bblocks [bcinfo [clause->handler_offset].block_id];
-                       } else
-                               return NULL;
+                       }
                }
        }
        return NULL;
@@ -3067,7 +3065,7 @@ mono_analyze_stack (MonoFlowGraph *cfg)
 
                        /* fixme: fault handler */
 
-                       if ((hb = mono_find_final_block (cfg, cli_addr, MONO_EXCEPTION_CLAUSE_FINALLY))) {
+                       if ((hb = mono_find_final_block (cfg, cli_addr, target, MONO_EXCEPTION_CLAUSE_FINALLY))) {
                                mark_reached (cfg, hb, NULL, 0);
                                t1 = mono_ctree_new_leaf (mp, MB_TERM_HANDLER);
                                t1->data.p = hb;
index 704e210449863ce275148b3d318d2ff92735d2fa..7c4ade4f7e1ef5c4a32d5f03e7fcc8159ba08b55 100644 (file)
@@ -30,6 +30,7 @@ TESTSRC=                      \
        exception8.cs           \
        exception10.cs          \
        exception11.cs          \
+       exception12.cs          \
        struct.cs               \
        valuetype-gettype.cs    \
        static-constructor.cs   \
diff --git a/mono/tests/exception12.cs b/mono/tests/exception12.cs
new file mode 100644 (file)
index 0000000..a32ca99
--- /dev/null
@@ -0,0 +1,28 @@
+using System;
+
+public class Test {
+
+       public static int Main (string[] args) {
+
+               int c = 0;
+               try {
+                       try {
+                               c = 0;
+                        }
+                       catch (Exception e) {
+                               Console.WriteLine("Exception: {0}", e.Message);
+                        }
+                       finally { 
+                               Console.WriteLine("Finally... {0}", c++);
+                        }
+               }
+               finally {
+                       c++;
+               }
+               
+               if (c != 2)
+                       return 1;
+               
+               return 0;
+       }
+}