Thu Oct 4 19:01:59 CEST 2007 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Thu, 4 Oct 2007 16:51:51 +0000 (16:51 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Thu, 4 Oct 2007 16:51:51 +0000 (16:51 -0000)
* mini-ppc.c, tramp-ppc.c: don't use r13 as it's used by the PPC EABI
systems already. This also reduces the specific trampiline sizes and
prepares for the use of r12 as the IMT identifier register.

svn path=/trunk/mono/; revision=86890

mono/mini/ChangeLog
mono/mini/mini-ppc.c
mono/mini/tramp-ppc.c

index 11061ee926e082692d04e86fde7be19fa7a7b076..06023f97abad1d63d60d2520148bb9da5fbbf4e5 100644 (file)
@@ -1,4 +1,10 @@
 
+Thu Oct 4 19:01:59 CEST 2007 Paolo Molaro <lupus@ximian.com>
+
+       * mini-ppc.c, tramp-ppc.c: don't use r13 as it's used by the PPC EABI
+       systems already. This also reduces the specific trampiline sizes and
+       prepares for the use of r12 as the IMT identifier register.
+
 Thu Oct 4 16:38:27 CEST 2007 Paolo Molaro <lupus@ximian.com>
 
        * mini-mips.h: endianess fix (simplified from a patch by
index 0b6012654ebef8efc84eaa31db43761a11d8be14..0540b2c63de3f38b9877091781659bbbc0b1857b 100644 (file)
@@ -319,7 +319,8 @@ mono_arch_get_global_int_regs (MonoCompile *cfg)
        int i, top = 32;
        if (cfg->frame_reg != ppc_sp)
                top = 31;
-       for (i = 13; i < top; ++i)
+       /* ppc_r13 is used by the system on PPC EABI */
+       for (i = 14; i < top; ++i)
                regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
 
        return regs;
index 7f7eddcb036c08fe1bed21cf355f3e46ac6da748..c76e59da7a417f50a153a988c9435352241077ff 100644 (file)
@@ -249,11 +249,10 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                        offset += sizeof (double);
                }
                /* 
-                * now the integer registers. r13 is already saved in the trampoline,
-                * and at this point contains the method to compile, so we skip it.
+                * now the integer registers.
                 */
-               offset = STACK - sizeof (MonoLMF) + G_STRUCT_OFFSET (MonoLMF, iregs) + sizeof (gulong);
-               ppc_stmw (buf, ppc_r14, ppc_r1, offset);
+               offset = STACK - sizeof (MonoLMF) + G_STRUCT_OFFSET (MonoLMF, iregs);
+               ppc_stmw (buf, ppc_r13, ppc_r1, offset);
 
                /* Now save the rest of the registers below the MonoLMF struct, first 14
                 * fp regs and then the 13 gregs.
@@ -263,7 +262,8 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                        ppc_stfd (buf, i, offset, ppc_r1);
                        offset += sizeof (double);
                }
-               offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (13 * sizeof (gulong));
+#define GREGS_OFFSET (STACK - sizeof (MonoLMF) - (14 * sizeof (double)) - (13 * sizeof (gulong)))
+               offset = GREGS_OFFSET;
                for (i = 0; i < 13; i++) {
                        ppc_stw (buf, i, offset, ppc_r1);
                        offset += sizeof (gulong);
@@ -291,8 +291,10 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                ppc_stw (buf, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r11);
                /* *(lmf_addr) = r11 */
                ppc_stw (buf, ppc_r11, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
-               /* save method info (it's in r13) */
-               ppc_stw (buf, ppc_r13, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
+               /* save method info (it's stored on the stack, so get it first and put it
+                * in r3 as it's the first argument to the function) */
+               ppc_lwz (buf, ppc_r3, GREGS_OFFSET, ppc_r1);
+               ppc_stw (buf, ppc_r3, G_STRUCT_OFFSET(MonoLMF, method), ppc_r11);
                ppc_stw (buf, ppc_sp, G_STRUCT_OFFSET(MonoLMF, ebp), ppc_r11);
                /* save the IP (caller ip) */
                if (tramp_type == MONO_TRAMPOLINE_JUMP) {
@@ -305,8 +307,8 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                /*
                 * Now we're ready to call ppc_magic_trampoline ().
                 */
-               /* Arg 1: MonoMethod *method. It was put in r13 */
-               ppc_mr  (buf, ppc_r3, ppc_r13);
+               /* Arg 1: MonoMethod *method. It was put in r3 already above */
+               /*ppc_mr  (buf, ppc_r3, ppc_r3);*/
                
                /* Arg 2: code (next address to the instruction that called us) */
                if (tramp_type == MONO_TRAMPOLINE_JUMP) {
@@ -349,7 +351,7 @@ mono_arch_create_trampoline_code (MonoTrampolineType tramp_type)
                ppc_lwz (buf, ppc_r6, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r11);
                /* *(lmf_addr) = previous_lmf */
                ppc_stw (buf, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r6);
-               /* restore iregs: this time include r13 */
+               /* restore iregs */
                ppc_lmw (buf, ppc_r13, ppc_r11, G_STRUCT_OFFSET(MonoLMF, iregs));
                /* restore fregs */
                for (i = 14; i < 32; i++) {
@@ -395,26 +397,23 @@ create_specific_tramp (MonoMethod *method, guint8* tramp, MonoDomain *domain) {
        MonoJitInfo *ji;
 
        mono_domain_lock (domain);
-       code = buf = mono_code_manager_reserve (domain->code_mp, 32);
+       code = buf = mono_code_manager_reserve (domain->code_mp, 24);
        mono_domain_unlock (domain);
 
-       /* Save r13 in the place it will have in the on-stack MonoLMF */
-       ppc_stw  (buf, ppc_r13, -(MONO_SAVED_FREGS * 8 + MONO_SAVED_GREGS * sizeof (gpointer)),  ppc_r1);
-       
        /* Prepare the jump to the generic trampoline code.*/
-       ppc_lis  (buf, ppc_r13, (guint32) tramp >> 16);
-       ppc_ori  (buf, ppc_r13, ppc_r13, (guint32) tramp & 0xffff);
-       ppc_mtctr (buf, ppc_r13);
+       ppc_lis  (buf, ppc_r0, (guint32) tramp >> 16);
+       ppc_ori  (buf, ppc_r0, ppc_r0, (guint32) tramp & 0xffff);
+       ppc_mtctr (buf, ppc_r0);
        
-       /* And finally put 'method' in r13 and fly! */
-       ppc_lis  (buf, ppc_r13, (guint32) method >> 16);
-       ppc_ori  (buf, ppc_r13, ppc_r13, (guint32) method & 0xffff);
+       /* And finally put 'method' in r0 and fly! */
+       ppc_lis  (buf, ppc_r0, (guint32) method >> 16);
+       ppc_ori  (buf, ppc_r0, ppc_r0, (guint32) method & 0xffff);
        ppc_bcctr (buf, 20, 0);
        
        /* Flush instruction cache, since we've generated code */
        mono_arch_flush_icache (code, buf - code);
 
-       g_assert ((buf - code) <= 32);
+       g_assert ((buf - code) <= 24);
 
        ji = g_new0 (MonoJitInfo, 1);
        ji->method = method;