* Paolo Molaro (lupus@ximian.com)
*
* (C) 2003 Ximian, Inc.
+ * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
*/
#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
/*
compute_dominators (MonoCompile *cfg)
{
int bindex, i, bitsize;
- char* mem;
MonoBasicBlock *entry;
MonoBasicBlock **doms;
gboolean changed;
bitsize = mono_bitset_alloc_size (cfg->num_bblocks, 0);
- mem = mono_mempool_alloc0 (cfg->mempool, bitsize * cfg->num_bblocks);
-
entry = cfg->bblocks [0];
doms = g_new0 (MonoBasicBlock*, cfg->num_bblocks);
MonoBasicBlock *bb = cfg->bblocks [i];
MonoBasicBlock *cbb;
MonoBitSet *dominators;
+ char *mem;
+
+ mem = mono_mempool_alloc0 (cfg->mempool, bitsize);
bb->dominators = dominators = mono_bitset_mem_new (mem, cfg->num_bblocks, 0);
mem += bitsize;
bb->idom = doms [bb->dfn];
if (bb->idom)
- bb->idom->dominated = g_list_prepend (bb->idom->dominated, bb);
+ bb->idom->dominated = g_slist_prepend_mempool (cfg->mempool, bb->idom->dominated, bb);
}
/* The entry bb */
#ifdef DEBUG_DOMINATORS
printf ("DTREE %s %d\n", mono_method_full_name (cfg->method, TRUE),
- mono_method_get_header (cfg->method)->num_clauses);
+ cfg->header->num_clauses);
for (i = 0; i < cfg->num_bblocks; ++i) {
MonoBasicBlock *bb = cfg->bblocks [i];
printf ("BB%d(dfn=%d) (IDOM=BB%d): ", bb->block_num, bb->dfn, bb->idom ? bb->idom->block_num : -1);
#endif
}
+#if 0
+
static void
check_dominance_frontier (MonoBasicBlock *x, MonoBasicBlock *t)
{
}
}
+#endif
+
/**
* Compute dominance frontiers using the algorithm from the same paper.
*/
int i;
mono_bitset_foreach_bit (set, i, m->num_bblocks) {
- mono_bitset_union (dest, m->bblocks [i]->dfrontier);
+ mono_bitset_union_fast (dest, m->bblocks [i]->dfrontier);
}
}
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);
/* 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++;
}
}
/* The loop body start is the first bblock in the order they will be emitted */
MonoBasicBlock *h = cfg->bblocks [i];
MonoBasicBlock *body_start = h;
+#if defined(__native_client_codegen__)
+ MonoInst *inst;
+#endif
GList *l;
for (l = h->loop_blocks; l; l = l->next) {
}
}
+#if defined(__native_client_codegen__)
+ /* Instrument the loop (GC back branch safe point) */
+ MONO_INST_NEW (cfg, inst, OP_NACL_GC_SAFE_POINT);
+ inst->dreg = mono_alloc_dreg (cfg, STACK_I4);
+ mono_bblock_insert_before_ins (body_start, NULL, inst);
+#endif
body_start->loop_body_start = 1;
}
}
for (i = 0; i < cfg->num_bblocks; ++i) {
if (cfg->bblocks[i]->dominated) {
- g_list_free (cfg->bblocks[i]->dominated);
cfg->bblocks[i]->dominated = NULL;
}
}
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;
if (cfg->comp_done & MONO_COMP_LOOPS)
clear_loops (cfg);
}
+
+#else /* DISABLE_JIT */
+
+void
+mono_free_loop_info (MonoCompile *cfg)
+{
+}
+
+#endif /* DISABLE_JIT */