-/*
- * 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
#ifdef DEBUG_LIVENESS
if (cfg->verbose_level > 1) {
- printf ("\t");
- mono_print_ins (ins);
+ mono_print_ins_index (1, ins);
}
#endif
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 = (MonoInst **)mono_mempool_alloc (cfg->mempool, sizeof (MonoInst*) * reverse_len);
-
for (idx = 0; idx < max_vars; ++idx) {
MonoMethodVar *vi = MONO_VARINFO (cfg, idx);
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 = (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;
- }
-
- 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) {
g_free (vreg_to_varinfo);
}
-#endif /* DISABLE_JIT */
+#else /* !DISABLE_JIT */
+
+MONO_EMPTY_SOURCE_FILE (liveness);
+
+#endif /* !DISABLE_JIT */