Author: zoltan
Date: 2008-01-24 11:22:42 -0500 (Thu, 24 Jan 2008)
New Revision: 93812

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/abcremoval.c
   trunk/mono/mono/mini/mini.c
   trunk/mono/mono/mini/mini.h
   trunk/mono/mono/mini/ssa.c
   trunk/mono/mono/mini/ssapre.c
Log:
2008-01-24  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini.h *.c: Change cfg->vars to contain the MonoMethodVar entries 
directly
        instead of though a pointer to save an indirection when accessing 
elements of
        the array.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/ChangeLog      2008-01-24 16:22:42 UTC (rev 93812)
@@ -1,5 +1,9 @@
 2008-01-24  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * mini.h *.c: Change cfg->vars to contain the MonoMethodVar entries 
directly
+       instead of though a pointer to save an indirection when accessing 
elements of
+       the array.
+
        * mini.h (MONO_IS_COND_BRANCH_OP): Move these macros here from mini.c. 
Fix
        some typos.
        (NOT_IMPLEMENTED): New helper macro.

Modified: trunk/mono/mono/mini/abcremoval.c
===================================================================
--- trunk/mono/mono/mini/abcremoval.c   2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/abcremoval.c   2008-01-24 16:22:42 UTC (rev 93812)
@@ -1331,8 +1331,8 @@
                area.relations [i].relation = MONO_EQ_RELATION;
                area.relations [i].relation_is_static_definition = TRUE;
                area.relations [i].next = NULL;
-               if (cfg->vars [i]->def != NULL) {
-                       MonoInst *value = 
get_variable_value_from_store_instruction (cfg->vars [i]->def, i);
+               if (MONO_VARINFO (cfg, i)->def != NULL) {
+                       MonoInst *value = 
get_variable_value_from_store_instruction (MONO_VARINFO (cfg, i)->def, i);
                        if (value != NULL) {
                                gboolean is_array_type;
                                MonoIntegerValueKind effective_value_kind;

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/mini.c 2008-01-24 16:22:42 UTC (rev 93812)
@@ -1709,9 +1709,11 @@
        int num = cfg->num_varinfo;
 
        if ((num + 1) >= cfg->varinfo_count) {
+               int orig_count = cfg->varinfo_count;
                cfg->varinfo_count = (cfg->varinfo_count + 2) * 2;
                cfg->varinfo = (MonoInst **)g_realloc (cfg->varinfo, sizeof 
(MonoInst*) * cfg->varinfo_count);
-               cfg->vars = (MonoMethodVar **)g_realloc (cfg->vars, sizeof 
(MonoMethodVar*) * cfg->varinfo_count);      
+               cfg->vars = (MonoMethodVar *)g_realloc (cfg->vars, sizeof 
(MonoMethodVar) * cfg->varinfo_count);
+               memset (&cfg->vars [orig_count], 0, (cfg->varinfo_count - 
orig_count) * sizeof (MonoMethodVar));
        }
 
        /*g_print ("created temp %d of type 0x%x\n", num, type->type);*/
@@ -1726,8 +1728,7 @@
 
        cfg->varinfo [num] = inst;
 
-       cfg->vars [num] = mono_mempool_alloc0 (cfg->mempool, sizeof 
(MonoMethodVar));
-       MONO_INIT_VARINFO (cfg->vars [num], num);
+       MONO_INIT_VARINFO (&cfg->vars [num], num);
 
        cfg->num_varinfo++;
        if (cfg->verbose_level > 2)

Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/mini.h 2008-01-24 16:22:42 UTC (rev 93812)
@@ -87,7 +87,7 @@
 };
 #undef OPDEF
 
-#define MONO_VARINFO(cfg,varnum) ((cfg)->vars [varnum])
+#define MONO_VARINFO(cfg,varnum) (&(cfg)->vars [varnum])
 
 #define MONO_INST_NEW(cfg,dest,op) do {        \
                (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof 
(MonoInst));       \
@@ -724,7 +724,7 @@
        MonoMethod      *method;
        MonoMemPool     *mempool;
        MonoInst       **varinfo;
-       MonoMethodVar  **vars;
+       MonoMethodVar   *vars;
        MonoInst        *ret;
        MonoBasicBlock  *bb_entry;
        MonoBasicBlock  *bb_exit;

Modified: trunk/mono/mono/mini/ssa.c
===================================================================
--- trunk/mono/mono/mini/ssa.c  2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/ssa.c  2008-01-24 16:22:42 UTC (rev 93812)
@@ -225,7 +225,7 @@
                        inst->inst_i0 = new_var;
 
 #ifdef USE_ORIGINAL_VARS
-                       cfg->vars [new_var->inst_c0]->reg = idx;
+                       MONO_VARINFO (cfg, new_var->inst_c0)->reg = idx;
 #endif
 
                        stack [idx] = new_var;
@@ -419,7 +419,7 @@
            (inst->inst_i0->opcode == OP_LOCAL || inst->inst_i0->opcode == 
OP_ARG)) {
                MonoInst *new_var;
                int idx = inst->inst_i0->inst_c0;
-               MonoMethodVar *mv = cfg->vars [idx];
+               MonoMethodVar *mv = MONO_VARINFO (cfg, idx);
 
                if (mv->reg != -1 && mv->reg != mv->idx) {
                       
@@ -475,7 +475,7 @@
                                for (j = 0; j < bb->in_count; j++) {
                                        MonoBasicBlock *pred = bb->in_bb [j];
                                        int idx = phi->inst_phi_args [j + 1];
-                                       MonoMethodVar *mv = cfg->vars [idx];
+                                       MonoMethodVar *mv = MONO_VARINFO (cfg, 
idx);
 
                                        if (mv->reg != -1 && mv->reg != 
mv->idx) {
                                                //printf ("PHICOPY %d %d -> 
%d\n", idx, mv->reg, inst->inst_i0->inst_c0);
@@ -558,7 +558,7 @@
        }
 
        for (i = 0; i < cfg->num_varinfo; ++i) {
-               cfg->vars [i]->reg = -1;
+               MONO_VARINFO (cfg, i)->reg = -1;
                if (!is_live [i]) {
                        cfg->varinfo [i]->flags |= MONO_INST_IS_DEAD;
                }
@@ -613,7 +613,7 @@
        if ((inst->ssa_op == MONO_SSA_STORE) && 
            (inst->inst_i0->opcode == OP_LOCAL /*|| inst->inst_i0->opcode == 
OP_ARG */)) {
                idx = inst->inst_i0->inst_c0;
-               info = cfg->vars [idx];
+               info = MONO_VARINFO (cfg, idx);
                //printf ("%d defined in BB%d %p\n", idx, bb->block_num, root);
                if (info->def) {
                        g_warning ("more than one definition of variable %d in 
%s", idx,
@@ -630,7 +630,7 @@
                        for (i = inst->inst_i1->inst_phi_args [0]; i > 0; i--) {
                                MonoVarUsageInfo *ui = mono_mempool_alloc 
(cfg->mempool, sizeof (MonoVarUsageInfo));
                                idx = inst->inst_i1->inst_phi_args [i]; 
-                               info = cfg->vars [idx];
+                               info = MONO_VARINFO (cfg, idx);
                                //printf ("FOUND %d\n", idx);
                                ui->bb = bb;
                                ui->inst = root;
@@ -643,7 +643,7 @@
            (inst->inst_i0->opcode == OP_LOCAL || inst->inst_i0->opcode == 
OP_ARG)) {
                MonoVarUsageInfo *ui = mono_mempool_alloc (cfg->mempool, sizeof 
(MonoVarUsageInfo));
                idx = inst->inst_i0->inst_c0;   
-               info = cfg->vars [idx];
+               info = MONO_VARINFO (cfg, idx);
                //printf ("FOUND %d\n", idx);
                ui->bb = bb;
                ui->inst = root;
@@ -679,7 +679,7 @@
                MONO_BB_FOR_EACH_INS (bb, inst) {
                        if (inst->ssa_op == MONO_SSA_STORE && 
inst->inst_i0->opcode == OP_LOCAL &&
                            !IS_CALL (inst->inst_i1->opcode) && 
inst->inst_i1->opcode != OP_PHI && !inst->flags) {
-                               i1 = cfg->vars [inst->inst_i0->inst_c0];
+                               i1 = MONO_VARINFO (cfg, inst->inst_i0->inst_c0);
 
 /* fixme: compiling mcs does not work when I enable this */
 #if 0
@@ -709,7 +709,7 @@
                                                g_list_length (i1->uses) == 1 &&
                                                inst->opcode == next->opcode &&
                                                inst->inst_i0->type == 
next->inst_i0->type) {
-                                       i2 = cfg->vars [next->inst_i0->inst_c0];
+                                       i2 = MONO_VARINFO (cfg, 
next->inst_i0->inst_c0);
                                        //printf ("ELIM. COPY in BB%d %s\n", 
bb->block_num, mono_method_full_name (cfg->method, TRUE));
                                        inst->inst_i0 = next->inst_i0;
                                        i2->def = inst;
@@ -1036,7 +1036,7 @@
                }       
        } else if (inst->ssa_op == MONO_SSA_STORE && 
                   (inst->inst_i0->opcode == OP_LOCAL || inst->inst_i0->opcode 
== OP_ARG)) {
-               MonoMethodVar *info = cfg->vars [inst->inst_i0->inst_c0];
+               MonoMethodVar *info = MONO_VARINFO (cfg, 
inst->inst_i0->inst_c0);
                MonoInst *i1 = inst->inst_i1;
                int res;
                
@@ -1048,7 +1048,7 @@
                                int j;
 
                                for (j = 1; j <= i1->inst_phi_args [0]; j++) {
-                                       MonoMethodVar *mv = cfg->vars 
[i1->inst_phi_args [j]];
+                                       MonoMethodVar *mv = MONO_VARINFO (cfg, 
i1->inst_phi_args [j]);
                                        MonoInst *src = mv->def;
 
                                        if (mv->def_bb && !(mv->def_bb->flags & 
BB_REACHABLE)) {
@@ -1115,7 +1115,7 @@
        memset (carray, 0, sizeof (MonoInst *) * cfg->num_varinfo);
 
        for (i = 0; i < cfg->num_varinfo; i++) {
-               MonoMethodVar *info = cfg->vars [i];
+               MonoMethodVar *info = MONO_VARINFO (cfg, i);
                if (!info->def)
                        info->cpstate = 2;
        }
@@ -1195,7 +1195,7 @@
        /* fixme: we should update usage infos during cprop, instead of 
computing it again */
        cfg->comp_done &=  ~MONO_COMP_SSA_DEF_USE;
        for (i = 0; i < cfg->num_varinfo; i++) {
-               MonoMethodVar *info = cfg->vars [i];
+               MonoMethodVar *info = MONO_VARINFO (cfg, i);
                info->def = NULL;
                info->uses = NULL;
        }
@@ -1207,7 +1207,7 @@
 
        work_list = NULL;
        for (i = 0; i < cfg->num_varinfo; i++) {
-               MonoMethodVar *info = cfg->vars [i];
+               MonoMethodVar *info = MONO_VARINFO (cfg, i);
                work_list = g_list_prepend (work_list, info);
                
                //if ((info->def != NULL) && (info->def->inst_i1->opcode != 
OP_PHI)) printf ("SSA DEADCE TOTAL LOCAL\n");
@@ -1225,12 +1225,12 @@
                        if (i1->opcode == OP_PHI) {
                                int j;
                                for (j = i1->inst_phi_args [0]; j > 0; j--) {
-                                       MonoMethodVar *u = cfg->vars 
[i1->inst_phi_args [j]];
+                                       MonoMethodVar *u = MONO_VARINFO (cfg, 
i1->inst_phi_args [j]);
                                        add_to_dce_worklist (cfg, info, u, 
&work_list);
                                }
                        } else if (i1->ssa_op == MONO_SSA_LOAD &&
                                   (i1->inst_i0->opcode == OP_LOCAL || 
i1->inst_i0->opcode == OP_ARG)) {
-                                       MonoMethodVar *u = cfg->vars 
[i1->inst_i0->inst_c0];
+                                       MonoMethodVar *u = MONO_VARINFO (cfg, 
i1->inst_i0->inst_c0);
                                        add_to_dce_worklist (cfg, info, u, 
&work_list);
                        }
                        //if (i1->opcode != OP_PHI) printf ("SSA DEADCE DEAD 
LOCAL\n");
@@ -1264,7 +1264,7 @@
                                continue;
 
                        for (i = 0; i < cfg->num_varinfo; i++) {
-                               MonoMethodVar *info = cfg->vars [i];
+                               MonoMethodVar *info = MONO_VARINFO (cfg, i);
                        
                                if (info->def && info->def->ssa_op == 
MONO_SSA_STORE &&
                                    info->def->inst_i0->opcode == OP_LOCAL && 
g_list_find (lp, info->def_bb)) {

Modified: trunk/mono/mono/mini/ssapre.c
===================================================================
--- trunk/mono/mono/mini/ssapre.c       2008-01-24 16:10:17 UTC (rev 93811)
+++ trunk/mono/mono/mini/ssapre.c       2008-01-24 16:22:42 UTC (rev 93812)
@@ -411,7 +411,7 @@
                result->left_argument = expression->left_argument;
        } else {
                result->left_argument.type = 
MONO_SSAPRE_EXPRESSION_ARGUMENT_ORIGINAL_VARIABLE;
-               original_variable = cfg->vars 
[expression->left_argument.argument.ssa_variable]->reg;
+               original_variable = MONO_VARINFO (cfg, 
expression->left_argument.argument.ssa_variable)->reg;
                if (original_variable >= 0) {
                        result->left_argument.argument.original_variable = 
original_variable;
                } else {
@@ -422,7 +422,7 @@
                result->right_argument = expression->right_argument;
        } else {
                result->right_argument.type = 
MONO_SSAPRE_EXPRESSION_ARGUMENT_ORIGINAL_VARIABLE;
-               original_variable = cfg->vars 
[expression->right_argument.argument.ssa_variable]->reg;
+               original_variable = MONO_VARINFO (cfg, 
expression->right_argument.argument.ssa_variable)->reg;
                if (original_variable >= 0) {
                        result->right_argument.argument.original_variable = 
original_variable;
                } else {
@@ -464,7 +464,7 @@
  * Given a variable index, checks if it is a phi definition
  * (it assumes the "area" is visible).
  */
-#define IS_PHI_DEFINITION(v) is_phi_definition (area->cfg->vars [v]->def)
+#define IS_PHI_DEFINITION(v) is_phi_definition (MONO_VARINFO (area->cfg, 
v)->def)
 
 /*
  * Given a variable index, checks if it is a phi definition.
@@ -473,7 +473,7 @@
  */
 static int*
 get_phi_definition (MonoCompile *cfg, gssize variable) {
-       MonoInst *definition = cfg->vars [variable]->def;
+       MonoInst *definition = MONO_VARINFO (cfg, variable)->def;
        if (is_phi_definition (definition) && (definition->inst_left->inst_c0 
== variable)) {
                return definition->inst_right->inst_phi_args;
        } else {
@@ -489,7 +489,7 @@
  */
 static MonoSsapreBBInfo*
 get_bb_info_of_definition (MonoSsapreWorkArea *area, gssize variable) {
-       MonoBasicBlock *def_bb = area->cfg->vars [variable]->def_bb;
+       MonoBasicBlock *def_bb = MONO_VARINFO (area->cfg, variable)->def_bb;
        if (def_bb != NULL) {
                return area->bb_infos_in_cfg_dfn_order [def_bb->dfn];
        } else {
@@ -842,11 +842,11 @@
                        if ((current_inst->inst_left->opcode == OP_LOCAL) || 
(current_inst->inst_left->opcode == OP_ARG)) {
                                int variable_index = 
current_inst->inst_left->inst_c0;
                                
-                               if (area->cfg->vars [variable_index]->def_bb == 
NULL) {
+                               if (MONO_VARINFO (area->cfg, 
variable_index)->def_bb == NULL) {
                                        if (area->cfg->verbose_level >= 4) {
                                                printf ("SSAPRE WARNING: 
variable %d has no definition, fixing.\n", variable_index);
                                        }
-                                       area->cfg->vars 
[variable_index]->def_bb = bb_info->bb;
+                                       MONO_VARINFO (area->cfg, 
variable_index)->def_bb = bb_info->bb;
                                }
                        }
                        break;
@@ -984,7 +984,7 @@
        int* phi_definition = get_phi_definition (area->cfg, variable);
        
        if (phi_definition != NULL) {
-               int definition_bb = area->cfg->vars [variable]->def_bb->dfn;
+               int definition_bb = MONO_VARINFO (area->cfg, 
variable)->def_bb->dfn;
                if (! mono_bitset_test (phi_bbs, definition_bb)) {
                        int i;
                        mono_bitset_set (phi_bbs, definition_bb);
@@ -1843,8 +1843,8 @@
                        if (original_variable_index == BOTTOM_REDUNDANCY_CLASS) 
{
                                original_variable_index = new_var->inst_c0;
                        }
-                       area->cfg->vars [new_var->inst_c0]->reg = 
original_variable_index;
-                       area->cfg->vars [new_var->inst_c0]->def_bb = 
current_bb->bb;
+                       MONO_VARINFO (area->cfg, new_var->inst_c0)->reg = 
original_variable_index;
+                       MONO_VARINFO (area->cfg, new_var->inst_c0)->def_bb = 
current_bb->bb;
                } else {
                        current_bb->phi_variable_index = 
BOTTOM_REDUNDANCY_CLASS;
                }
@@ -1859,8 +1859,8 @@
                                if (original_variable_index == 
BOTTOM_REDUNDANCY_CLASS) {
                                        original_variable_index = 
new_var->inst_c0;
                                }
-                               area->cfg->vars [new_var->inst_c0]->reg = 
original_variable_index;
-                               area->cfg->vars [new_var->inst_c0]->def_bb = 
current_bb->bb;
+                               MONO_VARINFO (area->cfg, new_var->inst_c0)->reg 
= original_variable_index;
+                               MONO_VARINFO (area->cfg, 
new_var->inst_c0)->def_bb = current_bb->bb;
                        } else {
                                current_expression->variable_index = 
BOTTOM_REDUNDANCY_CLASS;
                        }
@@ -1872,8 +1872,8 @@
                        if (original_variable_index == BOTTOM_REDUNDANCY_CLASS) 
{
                                original_variable_index = new_var->inst_c0;
                        }
-                       area->cfg->vars [new_var->inst_c0]->reg = 
original_variable_index;
-                       area->cfg->vars [new_var->inst_c0]->def_bb = 
current_bb->bb;
+                       MONO_VARINFO (area->cfg, new_var->inst_c0)->reg = 
original_variable_index;
+                       MONO_VARINFO (area->cfg, new_var->inst_c0)->def_bb = 
current_bb->bb;
                } else {
                        current_bb->phi_argument_variable_index = 
BOTTOM_REDUNDANCY_CLASS;
                }
@@ -1886,7 +1886,7 @@
                        int in_bb;
                        
                        NEW_INST (phi, OP_PHI);
-                       phi->inst_c0 = area->cfg->vars 
[current_bb->phi_variable_index]->reg;
+                       phi->inst_c0 = MONO_VARINFO (area->cfg, 
current_bb->phi_variable_index)->reg;
                        phi->inst_phi_args = mono_mempool_alloc 
(area->cfg->mempool, (sizeof (int) * ((current_bb->in_count) + 1)));
                        phi->inst_phi_args [0] = current_bb->in_count;
                        for (in_bb = 0; in_bb < current_bb->in_count; in_bb++) {
@@ -1911,7 +1911,7 @@
                                MONO_INST_LIST_ADD (&store->node,
                                        &current_bb->bb->ins_list);
                        }
-                       area->cfg->vars [current_bb->phi_variable_index]->def = 
store;
+                       MONO_VARINFO (area->cfg, 
current_bb->phi_variable_index)->def = store;
                        current_bb->phi_insertion_point = store;
                        
                        area->added_phis ++;
@@ -1931,7 +1931,7 @@
                                        MONO_INST_LIST_ADD (&store->node,
                                                &current_bb->bb->ins_list);
                                }
-                               area->cfg->vars 
[current_expression->variable_index]->def = store;
+                               MONO_VARINFO (area->cfg, 
current_expression->variable_index)->def = store;
                                mono_compile_make_var_load (area->cfg, 
current_expression->occurrence, current_expression->variable_index);
                                if (current_expression->father_in_tree != NULL) 
{
                                        handle_father_expression (area, 
current_expression, store);
@@ -1980,7 +1980,7 @@
                        
                        inserted_expression = create_expression (area, 
&expression_description, &prototype_occurrence);
                        store = mono_compile_create_var_store (area->cfg, 
current_bb->phi_argument_variable_index, inserted_expression);
-                       area->cfg->vars 
[current_bb->phi_argument_variable_index]->def = store;
+                       MONO_VARINFO (area->cfg, 
current_bb->phi_argument_variable_index)->def = store;
                        MONO_INST_LIST_INIT (&store->node);
                        mono_add_ins_to_end (current_bb->bb, store);
                        

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to