Author: lupus
Date: 2007-07-05 14:01:50 -0400 (Thu, 05 Jul 2007)
New Revision: 81413

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/mini-ppc.c
Log:


Thu Jul 5 20:12:52 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>

        * mini-ppc.c: fixed memory corruption for localloc(0)
        (bug #81852).



Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-07-05 17:39:44 UTC (rev 81412)
+++ trunk/mono/mono/mini/ChangeLog      2007-07-05 18:01:50 UTC (rev 81413)
@@ -1,3 +1,9 @@
+
+Thu Jul 5 20:12:52 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>
+
+       * mini-ppc.c: fixed memory corruption for localloc(0)
+       (bug #81852).
+
 2007-07-05  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * mini.c: Fix warnings.

Modified: trunk/mono/mono/mini/mini-ppc.c
===================================================================
--- trunk/mono/mono/mini/mini-ppc.c     2007-07-05 17:39:44 UTC (rev 81412)
+++ trunk/mono/mono/mini/mini-ppc.c     2007-07-05 18:01:50 UTC (rev 81413)
@@ -2560,8 +2560,12 @@
                        ppc_rlwinm (code, ppc_r11, ppc_r11, 0, 0, 27);
                        /* use ctr to store the number of words to 0 if needed 
*/
                        if (ins->flags & MONO_INST_INIT) {
-                               /* we zero 4 bytes at a time */
-                               ppc_addi (code, ppc_r0, ins->sreg1, 3);
+                               /* we zero 4 bytes at a time:
+                                * we add 7 instead of 3 so that we set the 
counter to
+                                * at least 1, otherwise the bdnz instruction 
will make
+                                * it negative and iterate billions of times.
+                                */
+                               ppc_addi (code, ppc_r0, ins->sreg1, 7);
                                ppc_srawi (code, ppc_r0, ppc_r0, 2);
                                ppc_mtctr (code, ppc_r0);
                        }
@@ -2571,7 +2575,10 @@
                        
                        if (ins->flags & MONO_INST_INIT) {
                                /* adjust the dest reg by -4 so we can use stwu 
*/
-                               ppc_addi (code, ins->dreg, ppc_sp, (area_offset 
- 4));
+                               /* we actually adjust -8 because we let the loop
+                                * run at least once
+                                */
+                               ppc_addi (code, ins->dreg, ppc_sp, (area_offset 
- 8));
                                ppc_li (code, ppc_r11, 0);
                                zero_loop_start = code;
                                ppc_stwu (code, ppc_r11, 4, ins->dreg);

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

Reply via email to