2009-06-13 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 13 Jun 2009 10:52:48 +0000 (10:52 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 13 Jun 2009 10:52:48 +0000 (10:52 -0000)
* mini.h (struct MonoBasicBlock): Add 'has_jump_table' and
'has_call_handler' fields.

* method-to-ir.c (mono_method_to_ir): Set them if needed.

* branch-opts.c (mono_merge_basic_blocks): Avoid iterating through the
first bblock if not needed. Fixes #512790.

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

mono/mini/ChangeLog
mono/mini/branch-opts.c
mono/mini/method-to-ir.c
mono/mini/mini.h

index 86c9a65171ec8735e31ee32715d8888881ce955f..50a93ce75aa7ea7aab426e9559df18b806ba847d 100644 (file)
@@ -1,3 +1,13 @@
+2009-06-13  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini.h (struct MonoBasicBlock): Add 'has_jump_table' and 
+       'has_call_handler' fields.
+
+       * method-to-ir.c (mono_method_to_ir): Set them if needed.
+
+       * branch-opts.c (mono_merge_basic_blocks): Avoid iterating through the
+       first bblock if not needed. Fixes #512790.
+       
 2009-06-11  Zoltan Varga  <vargaz@gmail.com>
 
        * aot-compiler.c (mono_compile_assembly): Fix a warning.
index ff4de4e3d2c1952a1d684ee61ec16eaa113c2e25..cd391f1e978d6bd76ed07573627dcec258e3b9a6 100644 (file)
@@ -958,21 +958,27 @@ mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b
                mono_unlink_bblock (cfg, bbn, bbn->out_bb [0]);
 
        /* Handle the branch at the end of the bb */
-       for (inst = bb->code; inst != NULL; inst = inst->next) {
-               if (inst->opcode == OP_CALL_HANDLER) {
-                       g_assert (inst->inst_target_bb == bbn);
-                       NULLIFY_INS (inst);
+       if (bb->has_call_handler) {
+               for (inst = bb->code; inst != NULL; inst = inst->next) {
+                       if (inst->opcode == OP_CALL_HANDLER) {
+                               g_assert (inst->inst_target_bb == bbn);
+                               NULLIFY_INS (inst);
+                       }
                }
-               if (MONO_IS_JUMP_TABLE (inst)) {
-                       int i;
-                       MonoJumpInfoBBTable *table = MONO_JUMP_TABLE_FROM_INS (inst);
-                       for (i = 0; i < table->table_size; i++ ) {
-                               /* Might be already NULL from a previous merge */
-                               if (table->table [i])
-                                       g_assert (table->table [i] == bbn);
-                               table->table [i] = NULL;
+       }
+       if (bb->has_jump_table) {
+               for (inst = bb->code; inst != NULL; inst = inst->next) {
+                       if (MONO_IS_JUMP_TABLE (inst)) {
+                               int i;
+                               MonoJumpInfoBBTable *table = MONO_JUMP_TABLE_FROM_INS (inst);
+                               for (i = 0; i < table->table_size; i++ ) {
+                                       /* Might be already NULL from a previous merge */
+                                       if (table->table [i])
+                                               g_assert (table->table [i] == bbn);
+                                       table->table [i] = NULL;
+                               }
+                               /* Can't nullify this as later instructions depend on it */
                        }
-                       /* Can't nullify this as later instructions depend on it */
                }
        }
        if (bb->last_ins && MONO_IS_COND_BRANCH_OP (bb->last_ins)) {
@@ -983,6 +989,9 @@ mono_merge_basic_blocks (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *b
                NULLIFY_INS (bb->last_ins);
        }
 
+       bb->has_call_handler |= bbn->has_call_handler;
+       bb->has_jump_table |= bbn->has_jump_table;
+
        if (bb->last_ins) {
                if (bbn->code) {
                        bb->last_ins->next = bbn->code;
index aa4c026dc5e69b2996b90cef412bbf3e19096118..b48686150a2c854976da9282326c0b9099a5aebc 100644 (file)
@@ -6856,6 +6856,8 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        if (COMPILE_LLVM (cfg))
                                use_op_switch = TRUE;
 
+                       cfg->cbb->has_jump_table = 1;
+
                        if (use_op_switch) {
                                MONO_INST_NEW (cfg, ins, OP_SWITCH);
                                ins->sreg1 = src1->dreg;
@@ -8813,6 +8815,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        MONO_INST_NEW (cfg, ins, OP_CALL_HANDLER);
                                        ins->inst_target_bb = tblock;
                                        MONO_ADD_INS (bblock, ins);
+                                       bblock->has_call_handler = 1;
                                }
                                g_list_free (handlers);
                        } 
index a575105a72cb29c167aef6bee60eb422eb5e47a0..3a0e2d4d2badc527fee326ec0b7f9fdc96b8785f 100644 (file)
@@ -429,6 +429,10 @@ struct MonoBasicBlock {
        guint has_array_access : 1;
        /* Whenever this bblock is extended, ie. it has branches inside it */
        guint extended : 1;
+       /* Whenever this bblock contains a OP_JUMP_TABLE instruction */
+       guint has_jump_table : 1;
+       /* Whenever this bblock contains an OP_CALL_HANDLER instruction */
+       guint has_call_handler : 1;
        
        /* use for liveness analysis */
        MonoBitSet *gen_set;