-/*
- * liveness.c: liveness analysis
+/**
+ * \file
+ * liveness analysis
*
* Author:
* Dietmar Maurer (dietmar@ximian.com)
*
* (C) 2002 Ximian, Inc.
* Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
+#include <mono/utils/mono-compiler.h>
#ifndef DISABLE_JIT
static inline MonoBitSet*
mono_bitset_mp_new (MonoMemPool *mp, guint32 size, guint32 max_size)
{
- guint8 *mem = mono_mempool_alloc0 (mp, size);
+ guint8 *mem = (guint8 *)mono_mempool_alloc0 (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
static inline MonoBitSet*
mono_bitset_mp_new_noinit (MonoMemPool *mp, guint32 size, guint32 max_size)
{
- guint8 *mem = mono_mempool_alloc (mp, size);
+ guint8 *mem = (guint8 *)mono_mempool_alloc (mp, size);
return mono_bitset_mem_new (mem, max_size, MONO_BITSET_DONT_FREE);
}
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
- get_vreg_to_inst (cfg, var->dreg + 1)->flags |= MONO_INST_VOLATILE;
- get_vreg_to_inst (cfg, var->dreg + 2)->flags |= MONO_INST_VOLATILE;
+ get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
+ get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
cfg->varinfo [vi->idx]->flags |= MONO_INST_VOLATILE;
if (SIZEOF_REGISTER == 4 && (var->type == STACK_I8 || (var->type == STACK_R8 && COMPILE_SOFT_FLOAT (cfg)))) {
/* Make the component vregs volatile as well (#612206) */
- get_vreg_to_inst (cfg, var->dreg + 1)->flags |= MONO_INST_VOLATILE;
- get_vreg_to_inst (cfg, var->dreg + 2)->flags |= MONO_INST_VOLATILE;
+ get_vreg_to_inst (cfg, MONO_LVREG_LS (var->dreg))->flags |= MONO_INST_VOLATILE;
+ get_vreg_to_inst (cfg, MONO_LVREG_MS (var->dreg))->flags |= MONO_INST_VOLATILE;
}
}
}
* Determine which clauses are outer try clauses, i.e. they are not contained in any
* other non-try clause.
*/
- outer_try = mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses);
+ outer_try = (gboolean *)mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses);
for (i = 0; i < header->num_clauses; ++i)
outer_try [i] = TRUE;
/* Iterate over the clauses backward, so outer clauses come first */
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
- printf ("\t");
- mono_print_ins (ins);
+ mono_print_ins_index (1, ins);
}
#endif
continue;
if (ins->opcode == OP_LDADDR) {
- MonoInst *var = ins->inst_p0;
+ MonoInst *var = (MonoInst *)ins->inst_p0;
int idx = var->inst_c0;
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
next_range->from = from;
} else {
/* Insert it */
- new_range = mono_mempool_alloc (cfg->mempool, sizeof (MonoLiveRange2));
+ new_range = (MonoLiveRange2 *)mono_mempool_alloc (cfg->mempool, sizeof (MonoLiveRange2));
new_range->from = from;
new_range->to = to;
new_range->next = NULL;
g_assert (pos > interval->range->from && pos <= interval->last_range->to);
- *i1 = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
- *i2 = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
+ *i1 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
+ *i2 = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
for (r = interval->range; r; r = r->next) {
if (pos > r->to) {
static void
mono_analyze_liveness2 (MonoCompile *cfg)
{
- int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos, reverse_len;
+ int bnum, idx, i, j, nins, max, max_vars, block_from, block_to, pos;
gint32 *last_use;
static guint32 disabled = -1;
- MonoInst **reverse;
if (disabled == -1)
- disabled = g_getenv ("DISABLED") != NULL;
+ disabled = g_hasenv ("DISABLED");
if (disabled)
return;
max_vars = cfg->num_varinfo;
last_use = g_new0 (gint32, max_vars);
- reverse_len = 1024;
- reverse = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
-
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
- vi->interval = mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
+ vi->interval = (MonoLiveInterval *)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoLiveInterval));
}
/*
if (cfg->ret)
last_use [cfg->ret->inst_c0] = block_to;
- for (nins = 0, pos = block_from, ins = bb->code; ins; ins = ins->next, ++nins, ++pos) {
- if (nins >= reverse_len) {
- int new_reverse_len = reverse_len * 2;
- MonoInst **new_reverse = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
- memcpy (new_reverse, reverse, sizeof (MonoInst*) * reverse_len);
- reverse = new_reverse;
- reverse_len = new_reverse_len;
- }
-
- reverse [nins] = ins;
- }
+ pos = block_from + 1;
+ MONO_BB_FOR_EACH_INS (bb, ins) pos++;
/* Process instructions backwards */
- for (i = nins - 1; i >= 0; --i) {
- MonoInst *ins = (MonoInst*)reverse [i];
-
- update_liveness2 (cfg, ins, FALSE, pos, last_use);
-
- pos --;
+ MONO_BB_FOR_EACH_INS_REVERSE (bb, ins) {
+ update_liveness2 (cfg, ins, FALSE, pos, last_use);
+ pos--;
}
for (idx = 0; idx < max_vars; ++idx) {
/* Add it to the last callsite */
g_assert (*callsites);
- last = (*callsites)->data;
+ last = (GCCallSite *)(*callsites)->data;
last->param_slots = g_slist_prepend_mempool (cfg->mempool, last->param_slots, ins);
} else if (ins->flags & MONO_INST_GC_CALLSITE) {
- GCCallSite *callsite = mono_mempool_alloc0 (cfg->mempool, sizeof (GCCallSite));
+ GCCallSite *callsite = (GCCallSite *)mono_mempool_alloc0 (cfg->mempool, sizeof (GCCallSite));
int i;
LIVENESS_DEBUG (printf ("\t%x: ", ins->backend.pc_offset); mono_print_ins (ins));
LIVENESS_DEBUG (printf ("\t\tlive: "));
callsite->bb = bb;
- callsite->liveness = mono_mempool_alloc0 (cfg->mempool, ALIGN_TO (cfg->num_varinfo, 8) / 8);
+ callsite->liveness = (guint8 *)mono_mempool_alloc0 (cfg->mempool, ALIGN_TO (cfg->num_varinfo, 8) / 8);
callsite->pc_offset = ins->backend.pc_offset;
for (i = 0; i < cfg->num_varinfo; ++i) {
if (last_use [i] != 0) {
}
reverse_len = 1024;
- reverse = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
+ reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
MonoInst *ins;
for (nins = 0, pos = block_from, ins = bb->code; ins; ins = ins->next, ++nins, ++pos) {
if (nins >= reverse_len) {
int new_reverse_len = reverse_len * 2;
- MonoInst **new_reverse = mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
+ MonoInst **new_reverse = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * new_reverse_len);
memcpy (new_reverse, reverse, sizeof (MonoInst*) * reverse_len);
reverse = new_reverse;
reverse_len = new_reverse_len;
g_free (vreg_to_varinfo);
}
-#endif /* DISABLE_JIT */
+#else /* !DISABLE_JIT */
+
+MONO_EMPTY_SOURCE_FILE (liveness);
+
+#endif /* !DISABLE_JIT */