Only make all basic block starts interruption points in methods with clauses.
authorZoltan Varga <vargaz@gmail.com>
Fri, 4 Nov 2011 20:15:44 +0000 (21:15 +0100)
committerZoltan Varga <vargaz@gmail.com>
Wed, 14 Dec 2011 08:13:39 +0000 (09:13 +0100)
mono/mini/method-to-ir.c

index d2545b3da188f15f0783faa24172b74a334ed53b..9df8869cd150281613143b7f751e24dd4d4bf569 100644 (file)
@@ -6264,12 +6264,12 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        /*
                         * Make methods interruptable at the beginning, and at the targets of
                         * backward branches.
-                        * Also, do this at the start of every bblock too,
+                        * Also, do this at the start of every bblock in methods with clauses too,
                         * to be able to handle instructions with inprecise control flow like
                         * throw/endfinally.
-                        * FIXME: Avoid this somehow.
+                        * Backward branches are handled at the end of method-to-ir ().
                         */
-                       gboolean intr_loc = ip == header->code || cfg->cbb->in_count > 1 || !cfg->cbb->last_ins;
+                       gboolean intr_loc = ip == header->code || (!cfg->cbb->last_ins && cfg->header->num_clauses);
 
                        /* Avoid sequence points on empty IL like .volatile */
                        // FIXME: Enable this
@@ -10665,6 +10665,17 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                }
        }
 
+       if (seq_points) {
+               MonoBasicBlock *bb;
+
+               /*
+                * Make seq points at backward branch targets interruptable.
+                */
+               for (bb = cfg->bb_entry; bb; bb = bb->next_bb)
+                       if (bb->code && bb->in_count > 1 && bb->code->opcode == OP_SEQ_POINT)
+                               bb->code->flags |= MONO_INST_SINGLE_STEP_LOC;
+       }
+
        /* Add a sequence point for method entry/exit events */
        if (seq_points) {
                NEW_SEQ_POINT (cfg, ins, METHOD_ENTRY_IL_OFFSET, FALSE);