* src/vm/jit/m68k/codegen.c (codegen_emit): Fix stackframesize
authortbfg <none@none>
Fri, 11 May 2007 17:15:08 +0000 (17:15 +0000)
committertbfg <none@none>
Fri, 11 May 2007 17:15:08 +0000 (17:15 +0000)
allocation in not synchronized methods which call a builtin returning
a double. Merged with ENABLE_THREADS case.
Added code to copy interface registers.

* src/vm/jit/m68k/asmpart.S (asm_handle_exception):
Save temporary registers, dunno if really needed, but its a
slow path anyways.

src/vm/jit/m68k/asmpart.S
src/vm/jit/m68k/codegen.c

index bd4d1a8ea95d93021118f96e069e1d24cc9f22e8..7638cefc3125657ab6d9a026c04eff77163e6dc8 100644 (file)
@@ -328,7 +328,17 @@ asm_handle_nat_exception:
        lea     %sp@(4), %sp
 asm_handle_exception:
 L_asm_handle_exception_stack_loop:
-       
+       /* save temporary registers */
+       movel   %d0, %sp@-
+       movel   %d1, %sp@-
+       movel   %a0, %sp@-
+       movel   %a1, %sp@-
+#if !defined(ENABLE_SOFTFLOAT)
+       addal   #-8*2, %sp
+       fmovemd %fp0, %sp@(0)
+       fmovemd %fp1, %sp@(8)
+#endif
+
        /* we need the dseg, figure it out */
        movel   %a3, %sp@-                              /* push ra argument */
        jsr     md_codegen_get_pv_from_pc       /* pv in %d0 now */
@@ -337,7 +347,11 @@ L_asm_handle_exception_stack_loop:
 
        /* now call the following c function */
        /* u1 *exceptions_handle_exception(java_objectheader *xptr, u1 *xpc, u1 *pv, u1 *sp) */
-       movel   %sp,%sp@-
+#if !defined(ENABLE_SOFTFLOAT)
+       pea             %sp@(4*4 + 8*2)
+#else
+       pea             %sp@(4*4)
+#endif
        movel   %d2,%sp@-
        movel   %a3,%sp@-
        movel   %a2,%sp@-
@@ -347,14 +361,33 @@ L_asm_handle_exception_stack_loop:
        beq     L_asm_handle_exception_not_catched
 
        /* %d0 contains address of exception handler */
-       moveal  %d0, %a0
-       moveal  %a2, %a1                                        /* XXX FIXME, xptr is expected in %a1 by java code, whyever */
-       jmp     %a0@
+       moveal  %d0, %a3
+
+       /* restore temporary registers */
+       moveal  %sp@+, %a1
+       moveal  %sp@+, %a0
+       movel   %sp@+, %d1
+       movel   %sp@+, %d0
+#if !defined(ENABLE_SOFTFLOAT)
+       fmovemd %fp0, %sp@(0)
+       fmovemd %fp1, %sp@(8)
+       addal   #8*2, %sp
+#endif
+
+       jmp     %a3@
 
 L_asm_handle_exception_not_catched:
        /* we did not find an exception handler in this stackframe */
        /* remove this frame and search in the one above */
        /* %a2 containts exception object ptr, %d2 the actual pv */
+
+       /* remove temporary registers stored */
+#if !defined(ENABLE_SOFTFLOAT)
+       addal   #4*4 + 8*2, %sp
+#else
+       addal   #4*4, %sp
+#endif
+
        moveal  %d2, %a3
        movel   %a3@(FrameSize), %d2
 
index 812ed9b31489b1c3cf1d020928408e0d5fc92af4..f0db5ceee24a060521fed831bd354c00cf41f4cb 100644 (file)
@@ -112,25 +112,27 @@ bool codegen_emit(jitdata *jd)
                savedregs_num += (FLT_SAV_CNT - rd->savfltreguse) * 2;
 
                cd->stackframesize = rd->memuse + savedregs_num;
+       
+               /* we always add 3 words, 
+                * 1 word the lock word, which may be unused and resides @ rd->memuse * 4
+                * + 2 words to either save the return value for LOCK_monitor_exit @ rd->memuse * 4 + 4
+                * on the other hand we could use 2 words when a builtin returns a doulbe which are
+                * returned in %d0, %d1 and need to be stored onto the stack and read in used a fmovemd
+                * so we always _need_ at least 2 words, and this keeps the code simple */
+               cd->stackframesize += 3;        
 
-               /* FIXME: we could need 2 words to move a double result, which gets
-                * passed in %d0, %d1 into a floating point register, this is of 
-                * course onyl true when not using ENABLE_SOFTFLOAT, so this could be
-                * optimized away, for now always use 2 more words. When optimizing watch
-                * the threading code, which stores the lock word, the offset would change */
-               cd->stackframesize += 2;
-
+#if 0
 #if defined(ENABLE_THREADS)
                /* we need additional space to save argument of monitor_enter */
                if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                        if (IS_2_WORD_TYPE(m->parseddesc->returntype.type))     {
                                cd->stackframesize += 2;
                        } else  {
-                               cd->stackframesize ++;
+                               cd->stackframesize += 1;
                        }
                }
 #endif
-               
+#endif 
        
                /* create method header */
                (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
@@ -273,7 +275,7 @@ bool codegen_emit(jitdata *jd)
                } /* end for argument out of stack*/
 
 #if defined(ENABLE_THREADS)
-       /* call monitor_enter function */
+       /* call lock_monitor_enter function */
        if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
                if (m->flags & ACC_STATIC)      {
                        M_AMOV_IMM((&m->class->object.header), REG_ATMP1);
@@ -306,8 +308,35 @@ bool codegen_emit(jitdata *jd)
        /* branch resolving */
        codegen_resolve_branchrefs(cd, bptr);
 
+       /* handle replacement points */
+       REPLACEMENT_POINT_BLOCK_START(cd, bptr);
+
+#if defined(ENABLE_PROFILING)
+       assert(0);
+#endif
        /* FIXME there are still some constrcuts to copy in here */
 
+#if defined(ENABLE_LSRA)
+       assert(0);
+#endif
+
+       /* copy interface registers to their destination */
+       len = bptr->indepth;
+       MCODECHECK(64+len);
+
+       while (len > 0) {
+               len--;
+               var = VAR(bptr->invars[len]);
+               if ((len == bptr->indepth-1) && (bptr->type == BBTYPE_EXH)) {
+                       d = codegen_reg_of_var(0, var, REG_ATMP1_XPTR);
+                       M_ADRMOVE(REG_ATMP1_XPTR, d);
+                       emit_store(jd, NULL, var, d);
+               }
+               else {
+                       assert((var->flags & INOUT));
+               }
+       }
+
        /* walk through all instructions */
        len = bptr->icount;
        currentline = 0;