Author: zoltan
Date: 2008-02-17 10:56:39 -0500 (Sun, 17 Feb 2008)
New Revision: 95977

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini-amd64.c
   trunk/mono/mono/mini/mini-codegen.c
   trunk/mono/mono/mini/mini.c
   trunk/mono/mono/mini/mini.h
Log:
2008-02-17  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini.h (MonoCompile): Add new 'vret_addr' field which represents the 
hidden
        argument holding the vtype return address, to avoid the ambigious use of
        cfg->ret for this purpose.

        * mini.c (NEW_RETLOADA): Use vret_addr if set.

        * mini-amd64.c: Use cfg->vret_addr instead of cfg->ret.
        
        * mini-codegen.c (mono_print_ins): Rename to mono_print_ins_index (), 
Add a
        new mono_print_ins () function which only takes one argument.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2008-02-17 14:59:29 UTC (rev 95976)
+++ trunk/mono/mono/mini/ChangeLog      2008-02-17 15:56:39 UTC (rev 95977)
@@ -1,3 +1,16 @@
+2008-02-17  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * mini.h (MonoCompile): Add new 'vret_addr' field which represents the 
hidden
+       argument holding the vtype return address, to avoid the ambigious use of
+       cfg->ret for this purpose.
+
+       * mini.c (NEW_RETLOADA): Use vret_addr if set.
+
+       * mini-amd64.c: Use cfg->vret_addr instead of cfg->ret.
+       
+       * mini-codegen.c (mono_print_ins): Rename to mono_print_ins_index (), 
Add a
+       new mono_print_ins () function which only takes one argument.
+
 2008-02-15  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * mini-s390.h (MONO_OUTPUT_VTR): Use cfg instead of s, avoid 
assignments to

Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c   2008-02-17 14:59:29 UTC (rev 95976)
+++ trunk/mono/mono/mini/mini-amd64.c   2008-02-17 15:56:39 UTC (rev 95977)
@@ -1040,15 +1040,19 @@
                case ArgInDoubleSSEReg:
                        if ((MONO_TYPE_ISSTRUCT (sig->ret) && 
!mono_class_from_mono_type (sig->ret)->enumtype) || (sig->ret->type == 
MONO_TYPE_TYPEDBYREF)) {
                                /* The register is volatile */
-                               cfg->ret->opcode = OP_REGOFFSET;
-                               cfg->ret->inst_basereg = cfg->frame_reg;
+                               cfg->vret_addr->opcode = OP_REGOFFSET;
+                               cfg->vret_addr->inst_basereg = cfg->frame_reg;
                                if (cfg->arch.omit_fp) {
-                                       cfg->ret->inst_offset = offset;
+                                       cfg->vret_addr->inst_offset = offset;
                                        offset += 8;
                                } else {
                                        offset += 8;
-                                       cfg->ret->inst_offset = -offset;
+                                       cfg->vret_addr->inst_offset = -offset;
                                }
+                               if (G_UNLIKELY (cfg->verbose_level > 1)) {
+                                       printf ("vret_addr =");
+                                       mono_print_ins (cfg->vret_addr);
+                               }
                        }
                        else {
                                cfg->ret->opcode = OP_REGVAR;
@@ -1173,6 +1177,14 @@
 
        if (cinfo->ret.storage == ArgValuetypeInReg)
                cfg->ret_var_is_local = TRUE;
+
+       if ((cinfo->ret.storage != ArgValuetypeInReg) && MONO_TYPE_ISSTRUCT 
(sig->ret)) {
+               cfg->vret_addr = mono_compile_create_var (cfg, 
&mono_defaults.int_class->byval_arg, OP_ARG);
+               if (G_UNLIKELY (cfg->verbose_level > 1)) {
+                       printf ("vret_addr = ");
+                       mono_print_ins (cfg->vret_addr);
+               }
+       }
 }
 
 static void
@@ -2420,9 +2432,8 @@
        /* This is the opposite of the code in emit_prolog */
 
        if (sig->ret->type != MONO_TYPE_VOID) {
-               if ((cinfo->ret.storage == ArgInIReg) && (cfg->ret->opcode != 
OP_REGVAR)) {
-                       amd64_mov_reg_membase (code, cinfo->ret.reg, 
cfg->ret->inst_basereg, cfg->ret->inst_offset, 8);
-               }
+               if (cfg->vret_addr && (cfg->vret_addr->opcode != OP_REGVAR))
+                       amd64_mov_reg_membase (code, cinfo->ret.reg, 
cfg->vret_addr->inst_basereg, cfg->vret_addr->inst_offset, 8);
        }
 
        for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
@@ -4641,10 +4652,9 @@
        cinfo = cfg->arch.cinfo;
 
        if (sig->ret->type != MONO_TYPE_VOID) {
-               if ((cinfo->ret.storage == ArgInIReg) && (cfg->ret->opcode != 
OP_REGVAR)) {
-                       /* Save volatile arguments to the stack */
-                       amd64_mov_membase_reg (code, cfg->ret->inst_basereg, 
cfg->ret->inst_offset, cinfo->ret.reg, 8);
-               }
+               /* Save volatile arguments to the stack */
+               if (cfg->vret_addr && (cfg->vret_addr->opcode != OP_REGVAR))
+                       amd64_mov_membase_reg (code, 
cfg->vret_addr->inst_basereg, cfg->vret_addr->inst_offset, cinfo->ret.reg, 8);
        }
 
        /* Keep this in sync with emit_load_volatile_arguments */

Modified: trunk/mono/mono/mini/mini-codegen.c
===================================================================
--- trunk/mono/mono/mini/mini-codegen.c 2008-02-17 14:59:29 UTC (rev 95976)
+++ trunk/mono/mono/mini/mini-codegen.c 2008-02-17 15:56:39 UTC (rev 95977)
@@ -376,7 +376,7 @@
 
 #ifndef DISABLE_LOGGING
 void
-mono_print_ins (int i, MonoInst *ins)
+mono_print_ins_index (int i, MonoInst *ins)
 {
        const char *spec = ins_get_spec (ins->opcode);
        printf ("\t%-2d %s", i, mono_inst_name (ins->opcode));
@@ -441,8 +441,19 @@
                printf ("liveness: %s [%d - %d]\n", r, t [i].born_in, 
t[i].killed_in);
        }
 }
+#else
+void
+mono_print_ins_index (int i, MonoInst *ins)
+{
+}
 #endif /* DISABLE_LOGGING */
 
+void
+mono_print_ins (MonoInst *ins)
+{
+       mono_print_ins_index (-1, ins);
+}
+
 static inline void
 insert_before_ins (MonoInst *ins, MonoInst* to_insert)
 {
@@ -784,7 +795,7 @@
                        g_error ("Opcode '%s' missing from machine description 
file.", mono_inst_name (ins->opcode));
                }
                
-               DEBUG (mono_print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
 
                /*
                 * TRACK FP STACK
@@ -962,7 +973,7 @@
                sreg2_mask = sreg2_is_fp (spec) ? MONO_ARCH_CALLEE_FREGS : 
MONO_ARCH_CALLEE_REGS;
 
                DEBUG (printf ("processing:"));
-               DEBUG (mono_print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
 
                ip = ins->cil_code;
 
@@ -1669,7 +1680,7 @@
                        mono_regstate_free_int (rs, ins->sreg2);
                }*/
        
-               DEBUG (mono_print_ins (i, ins));
+               DEBUG (mono_print_ins_index (i, ins));
                ins = prev_ins;
        }
 

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2008-02-17 14:59:29 UTC (rev 95976)
+++ trunk/mono/mono/mini/mini.c 2008-02-17 15:56:39 UTC (rev 95977)
@@ -579,14 +579,23 @@
        } while (0)
 
 #define NEW_RETLOADA(cfg,dest) do {    \
-               (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof 
(MonoInst));       \
-               (dest)->ssa_op = MONO_SSA_ADDRESS_TAKEN;        \
-               (dest)->inst_i0 = (cfg)->ret;   \
-               (dest)->inst_i0->flags |= MONO_INST_INDIRECT;   \
-               (dest)->opcode = cfg->ret_var_is_local ? OP_LDADDR : 
CEE_LDIND_I;       \
-               (dest)->type = STACK_MP;        \
-               (dest)->klass = (dest)->inst_i0->klass; \
-                (cfg)->disable_ssa = TRUE; \
+        if (cfg->vret_addr) { \
+                   (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof 
(MonoInst));   \
+                   (dest)->ssa_op = MONO_SSA_LOAD;     \
+                   (dest)->inst_i0 = cfg->vret_addr; \
+                   (dest)->opcode = mini_type_to_ldind ((cfg), 
(dest)->inst_i0->inst_vtype); \
+            (dest)->type = STACK_MP; \
+                   (dest)->klass = (dest)->inst_i0->klass;     \
+        } else { \
+                       (dest) = mono_mempool_alloc0 ((cfg)->mempool, sizeof 
(MonoInst));       \
+                   (dest)->ssa_op = MONO_SSA_ADDRESS_TAKEN;    \
+                   (dest)->inst_i0 = (cfg)->ret;       \
+                   (dest)->inst_i0->flags |= MONO_INST_INDIRECT;       \
+                   (dest)->opcode = cfg->ret_var_is_local ? OP_LDADDR : 
CEE_LDIND_I;   \
+                   (dest)->type = STACK_MP;    \
+                   (dest)->klass = (dest)->inst_i0->klass;     \
+            (cfg)->disable_ssa = TRUE; \
+        } \
        } while (0)
 
 #define NEW_ARGLOADA(cfg,dest,num) do {        \
@@ -5659,7 +5668,7 @@
                                        if (ins->opcode == CEE_STOBJ) {
                                                NEW_RETLOADA (cfg, ins);
                                                /* FIXME: it is possible some 
optimization will pass the a heap pointer for the struct address, so we'll need 
the write barrier */
-                                               handle_stobj (cfg, bblock, ins, 
*sp, ip, ins->klass, FALSE, FALSE, FALSE);
+                                               handle_stobj (cfg, bblock, ins, 
*sp, ip, cfg->ret->klass, FALSE, FALSE, FALSE);
                                        } else {
                                                ins->opcode = OP_SETRET;
                                                ins->cil_code = ip;

Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2008-02-17 14:59:29 UTC (rev 95976)
+++ trunk/mono/mono/mini/mini.h 2008-02-17 15:56:39 UTC (rev 95977)
@@ -757,6 +757,13 @@
        MonoInst        *domainvar; /* a cache for the current domain */
        MonoInst        *got_var; /* Global Offset Table variable */
        MonoInst        **args;
+
+       /* 
+        * This variable represents the hidden argument holding the vtype
+        * return address. If the method returns something other than a vtype, 
or
+        * the vtype is returned in registers this is NULL.
+        */
+       MonoInst        *vret_addr;
        
        struct MonoAliasingInformation *aliasing_info;
 
@@ -1102,7 +1109,8 @@
 MonoCompile *mini_method_compile            (MonoMethod *method, guint32 opts, 
MonoDomain *domain, gboolean run_cctors, gboolean compile_aot, int parts) 
MONO_INTERNAL;
 void      mono_destroy_compile              (MonoCompile *cfg) MONO_INTERNAL;
 MonoJitICallInfo *mono_find_jit_opcode_emulation (int opcode) MONO_INTERNAL;
-void     mono_print_ins (int i, MonoInst *ins) MONO_INTERNAL;
+void     mono_print_ins_index (int i, MonoInst *ins) MONO_INTERNAL;
+void     mono_print_ins (MonoInst *ins) MONO_INTERNAL;
 
 void      mono_aot_init                     (void) MONO_INTERNAL;
 gpointer  mono_aot_get_method               (MonoDomain *domain,

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

Reply via email to