2009-07-01 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / dominators.c
index 410c51ae130ec17c6acaee1598a99f1ba6a3026c..6dc67906bfdbfb148e7a009a4aef84cecbf511c1 100644 (file)
@@ -9,9 +9,13 @@
  */
 #include <string.h>
 #include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/mempool.h>
+#include <mono/metadata/mempool-internals.h>
 
 #include "mini.h"
 
+#ifndef DISABLE_JIT
+
 //#define DEBUG_DOMINATORS
 
 /*
  */
 #define HAS_DFN(bb, entry) ((bb)->dfn || ((bb) == entry))
 
-static inline GSList*
-g_slist_prepend_mempool (MonoMemPool *mp, GSList   *list,
-                                                gpointer  data)
-{
-  GSList *new_list;
-
-  new_list = mono_mempool_alloc (mp, sizeof (GSList));
-  new_list->data = data;
-  new_list->next = list;
-
-  return new_list;
-}
-
 /*
  * Compute dominators and immediate dominators using the algorithm in the
  * paper "A Simple, Fast Dominance Algorithm" by Keith D. Cooper, 
@@ -352,7 +343,7 @@ mono_compute_natural_loops (MonoCompile *cfg)
                                        if ((cb->dfn && mono_bitset_test_fast (in_loop_blocks, cb->dfn)) || (!cb->dfn && g_list_find (h->loop_blocks, cb)))
                                                continue;
 
-                                       h->loop_blocks = g_list_prepend (h->loop_blocks, cb);
+                                       h->loop_blocks = g_list_prepend_mempool (cfg->mempool, h->loop_blocks, cb);
                                        cb->nesting++;
                                        if (cb->dfn)
                                                mono_bitset_set_fast (in_loop_blocks, cb->dfn);
@@ -368,7 +359,7 @@ mono_compute_natural_loops (MonoCompile *cfg)
 
                                /* add the header if not already there */
                                if (!((h->dfn && mono_bitset_test_fast (in_loop_blocks, h->dfn)) || (!h->dfn && g_list_find (h->loop_blocks, h)))) {
-                                       h->loop_blocks = g_list_prepend (h->loop_blocks, h);
+                                       h->loop_blocks = g_list_prepend_mempool (cfg->mempool, h->loop_blocks, h);
                                        h->nesting++;
                                }
                        }
@@ -445,10 +436,7 @@ clear_loops (MonoCompile *cfg)
     
        for (i = 0; i < cfg->num_bblocks; ++i) {
                cfg->bblocks[i]->nesting = 0;
-               if (cfg->bblocks[i]->loop_blocks) {
-                       g_list_free (cfg->bblocks[i]->loop_blocks);        
-                       cfg->bblocks[i]->loop_blocks = NULL;
-               }
+               cfg->bblocks[i]->loop_blocks = NULL;
        }
 
        cfg->comp_done &= ~MONO_COMP_LOOPS;   
@@ -462,3 +450,12 @@ mono_free_loop_info (MonoCompile *cfg)
     if (cfg->comp_done & MONO_COMP_LOOPS)
         clear_loops (cfg);
 }
+
+#else /* DISABLE_JIT */
+
+void
+mono_free_loop_info (MonoCompile *cfg)
+{
+}
+
+#endif /* DISABLE_JIT */