Author: zoltan
Date: 2005-09-27 16:36:46 -0400 (Tue, 27 Sep 2005)
New Revision: 50887

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/inssel-amd64.brg
   trunk/mono/mono/mini/mini-amd64.c
Log:
2005-09-27  Zoltan Varga  <[EMAIL PROTECTED]>

        * mini-amd64.c (mono_arch_call_opcode): Use mono_class_value_size ()
        to determine the amount of memory to copy when passing valuetypes.

        * inssel-amd64.brg: Remove PUSH(LDIND4) rules since they convert an
        4 byte load into a 8 byte load. Fix aligning of size in OP_OUTARG_VT.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2005-09-27 19:49:11 UTC (rev 50886)
+++ trunk/mono/mono/mini/ChangeLog      2005-09-27 20:36:46 UTC (rev 50887)
@@ -1,3 +1,11 @@
+2005-09-27  Zoltan Varga  <[EMAIL PROTECTED]>
+
+       * mini-amd64.c (mono_arch_call_opcode): Use mono_class_value_size ()
+       to determine the amount of memory to copy when passing valuetypes.
+
+       * inssel-amd64.brg: Remove PUSH(LDIND4) rules since they convert an
+       4 byte load into a 8 byte load. Fix aligning of size in OP_OUTARG_VT.
+
 2005-09-27  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * mini.h mini.c aot.c: Add infrastructure to collect pagefault 

Modified: trunk/mono/mono/mini/inssel-amd64.brg
===================================================================
--- trunk/mono/mono/mini/inssel-amd64.brg       2005-09-27 19:49:11 UTC (rev 
50886)
+++ trunk/mono/mono/mini/inssel-amd64.brg       2005-09-27 20:36:46 UTC (rev 
50887)
@@ -237,20 +237,6 @@
        mono_bblock_add_inst (s->cbb, tree);
 }
 
-stmt: OP_OUTARG (CEE_LDIND_I4 (base)) {
-       tree->opcode = OP_X86_PUSH_MEMBASE;
-       tree->inst_basereg = state->left->left->tree->inst_basereg;
-       tree->inst_offset = state->left->left->tree->inst_offset;
-       mono_bblock_add_inst (s->cbb, tree);
-}
-
-stmt: OP_OUTARG (CEE_LDIND_U4 (base)) {
-       tree->opcode = OP_X86_PUSH_MEMBASE;
-       tree->inst_basereg = state->left->left->tree->inst_basereg;
-       tree->inst_offset = state->left->left->tree->inst_offset;
-       mono_bblock_add_inst (s->cbb, tree);
-}
-
 stmt: OP_OUTARG (CEE_LDIND_I (base)) {
        tree->opcode = OP_X86_PUSH_MEMBASE;
        tree->inst_basereg = state->left->left->tree->inst_basereg;
@@ -333,15 +319,16 @@
        if (!tree->inst_imm)
                return;
 
-       if (tree->inst_imm <= 8) {
+       if (tree->inst_imm == 8) {
+               /* Can't use this for < 8 since it does an 8 byte memory load */
                tree->opcode = OP_X86_PUSH_MEMBASE;
                tree->inst_basereg = vt->inst_basereg;
                tree->inst_offset = vt->inst_offset;
                mono_bblock_add_inst (s->cbb, tree);
        } else if (tree->inst_imm <= 20) {
                int sz = tree->inst_imm;
-               sz += 8;
-               sz &= ~8;
+               sz += 7;
+               sz &= ~7;
                MONO_EMIT_NEW_BIALU_IMM (s, OP_SUB_IMM, X86_ESP, X86_ESP, sz);
                mini_emit_memcpy (s, X86_ESP, 0, vt->inst_basereg, 
vt->inst_offset, tree->inst_imm, 0);
        } else {

Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c   2005-09-27 19:49:11 UTC (rev 50886)
+++ trunk/mono/mono/mini/mini-amd64.c   2005-09-27 20:36:46 UTC (rev 50887)
@@ -1086,8 +1086,15 @@
                                else
                                if (sig->pinvoke)
                                        size = mono_type_native_stack_size 
(&in->klass->byval_arg, &align);
-                               else
-                                       size = mono_type_stack_size 
(&in->klass->byval_arg, &align);
+                               else {
+                                       /* 
+                                        * Other backends use 
mono_type_stack_size (), but that
+                                        * aligns the size to 8, which is 
larger than the size of
+                                        * the source, leading to reads of 
invalid memory if the
+                                        * source is at the end of address 
space.
+                                        */
+                                       size = mono_class_value_size 
(in->klass, &align);
+                               }
                                if (ainfo->storage == ArgValuetypeInReg) {
                                        if (ainfo->pair_storage [1] == ArgNone) 
{
                                                MonoInst *load;

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

Reply via email to