* src/vm/jit/linenumbertable.c (linenumbertable_create, linenumbertable_linenumber_fo...
[cacao.git] / src / vm / jit / s390 / codegen.c
index 5b083baa5a8f495ccab71d947607e7f38157ac99..b0a1516f029a7cfbfc4eaa59d84c4ede7e936204 100644 (file)
@@ -57,6 +57,7 @@
 #include "vm/jit/dseg.h"
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
+#include "vm/jit/linenumbertable.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
  * purpose registers.
  */
 
+/*
 static void do__log(u4 *regs) {
-       /* insert stuff here */
 }
+*/
 
 #define DO__LOG \
        N_AHI(REG_SP, -200); \
@@ -89,7 +91,11 @@ static void do__log(u4 *regs) {
        N_LM(R0, R15, 96, REG_SP); \
        N_AHI(REG_SP, 200);
 
-#define SUPPORT_HERCULES 1
+/* If the following macro is defined, workaround code for hercules quirks
+ * is generated
+ */
+
+/* #define SUPPORT_HERCULES 1 */
 
 /* codegen *********************************************************************
 
@@ -130,11 +136,9 @@ bool codegen_emit(jitdata *jd)
        registerdata       *rd;
        s4                  len, s1, s2, s3, d, dd, disp;
        u2                  currentline;
-       ptrint              a;
-       varinfo            *var, *var1, *var2, *dst;
+       varinfo            *var;
        basicblock         *bptr;
        instruction        *iptr;
-       exception_entry    *ex;
        constant_classref  *cr;
        unresolved_class   *uc;
        methodinfo         *lm;             /* local methodinfo for ICMD_INVOKE*  */
@@ -206,14 +210,7 @@ bool codegen_emit(jitdata *jd)
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
        (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize       */
 
-       /* IsSync contains the offset relative to the stack pointer for the
-          argument of monitor_exit used in the exception handler. Since the
-          offset could be zero and give a wrong meaning of the flag it is
-          offset by one.
-       */
-       /* XXX Remove this "offset by one". */
-
-       code->synchronizedoffset = (rd->memuse + 1) * 8;
+       code->synchronizedoffset = rd->memuse * 8;
 
        /* REMOVEME: We still need it for exception handling in assembler. */
 
@@ -225,19 +222,6 @@ bool codegen_emit(jitdata *jd)
        (void) dseg_add_unique_s4(cd, INT_SAV_CNT - rd->savintreguse); /* IntSave */
        (void) dseg_add_unique_s4(cd, FLT_SAV_CNT - rd->savfltreguse); /* FltSave */
 
-       (void) dseg_addlinenumbertablesize(cd);
-
-       (void) dseg_add_unique_s4(cd, jd->exceptiontablelength); /* ExTableSize   */
-
-       /* create exception table */
-
-       for (ex = jd->exceptiontable; ex != NULL; ex = ex->down) {
-               dseg_add_target(cd, ex->start);
-               dseg_add_target(cd, ex->end);
-               dseg_add_target(cd, ex->handler);
-               (void) dseg_add_unique_address(cd, ex->catchtype.any);
-       }
-
        /* Offset PV */
 
        M_AADD_IMM(N_PV_OFFSET, REG_PV);
@@ -517,7 +501,7 @@ bool codegen_emit(jitdata *jd)
 
                for (iptr = bptr->iinstr; len > 0; len--, iptr++) {
                        if (iptr->line != currentline) {
-                               dseg_addlinenumber(cd, iptr->line);
+                               linenumbertable_list_entry_add(cd, iptr->line);
                                currentline = iptr->line;
                        }
 
@@ -537,14 +521,14 @@ bool codegen_emit(jitdata *jd)
                case ICMD_INLINE_BODY:
 
                        REPLACEMENT_POINT_INLINE_BODY(cd, iptr);
-                       dseg_addlinenumber_inline_start(cd, iptr);
-                       dseg_addlinenumber(cd, iptr->line);
+                       linenumbertable_list_entry_add_inline_start(cd, iptr);
+                       linenumbertable_list_entry_add(cd, iptr->line);
                        break;
 
                case ICMD_INLINE_END:
 
-                       dseg_addlinenumber_inline_end(cd, iptr);
-                       dseg_addlinenumber(cd, iptr->line);
+                       linenumbertable_list_entry_add_inline_end(cd, iptr);
+                       linenumbertable_list_entry_add(cd, iptr->line);
                        break;
 
                case ICMD_CHECKNULL:  /* ..., objectref  ==> ..., objectref           */
@@ -1638,7 +1622,9 @@ bool codegen_emit(jitdata *jd)
 
                case ICMD_F2D:       /* ..., value  ==> ..., (double) value           */
                        {
+#ifdef SUPPORT_HERCULES
                                u1 *ref;
+#endif
                                s1 = emit_load_s1(jd, iptr, REG_FTMP1);
                                d = codegen_reg_of_dst(jd, iptr, REG_FTMP2);
 #ifdef SUPPORT_HERCULES
@@ -3463,8 +3449,6 @@ gen_method:
        } /* if (bptr -> flags >= BBREACHED) */
        } /* for basic block */
 
-       dseg_createlinenumbertable(cd);
-
        /* generate stubs */
 
        emit_patcher_traps(jd);
@@ -3474,36 +3458,6 @@ gen_method:
        return true;
 }
 
-
-/* codegen_emit_stub_compiler **************************************************
-
-   Emits a stub routine which calls the compiler.
-       
-*******************************************************************************/
-
-void codegen_emit_stub_compiler(jitdata *jd)
-{
-       methodinfo  *m;
-       codegendata *cd;
-
-       /* get required compiler data */
-
-       m  = jd->m;
-       cd = jd->cd;
-
-       /* code for the stub */
-
-       /* don't touch ITMP2 as it cointains the return address */
-
-       M_AADD_IMM(N_PV_OFFSET, REG_PV); /* suppress negative displacements */
-
-       /* REG_METHODPTR (REG_ITMP1) already used */
-       M_ILD_DSEG(REG_ITMP3, -2 * SIZEOF_VOID_P); /* methodinfo  */
-       M_ILD_DSEG(REG_PV, -3 * SIZEOF_VOID_P); /* compiler pointer */
-       N_BR(REG_PV);
-}
-
-
 /* codegen_emit_stub_native ****************************************************
 
    Emits a stub routine which calls a native method.
@@ -3536,10 +3490,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        codeinfo    *code;
        codegendata *cd;
        methoddesc  *md;
-       s4           i, j;                 /* count variables                    */
-       s4           t;
-       s4           s1, s2, disp;
-       s4           funcdisp;
+       int          i, j;
+       int          t;
+       int          s1, s2;
+       int          disp;
 
        /* get required compiler data */
 
@@ -3569,12 +3523,9 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
        (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize       */
-       (void) dseg_add_unique_s4(cd, 0);                      /* IsSync          */
        (void) dseg_add_unique_s4(cd, 0);                      /* IsLeaf          */
        (void) dseg_add_unique_s4(cd, 0);                      /* IntSave         */
        (void) dseg_add_unique_s4(cd, 0);                      /* FltSave         */
-       (void) dseg_addlinenumbertablesize(cd);
-       (void) dseg_add_unique_s4(cd, 0);                      /* ExTableSize     */
 
        /* generate code */
 
@@ -3585,13 +3536,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
        M_AST(REG_RA, REG_SP, (cd->stackframesize - 1) * 8);
 
-       /* get function address (this must happen before the stackframeinfo) */
-
-       funcdisp = dseg_add_functionptr(cd, f);
-
-       if (f == NULL)
-               patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, funcdisp);
-
 #if defined(ENABLE_GC_CACAO)
        /* Save callee saved integer registers in stackframeinfo (GC may
           need to recover them during a collection). */
@@ -3725,9 +3669,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                M_ALD_DSEG(REG_A0, disp);
        }
 
-       /* generate the actual native call */
+       /* Call native function. */
 
-       M_ALD_DSEG(REG_ITMP2, funcdisp);
+       disp = dseg_add_functionptr(cd, f);
+       M_ALD_DSEG(REG_ITMP2, disp);
        M_CALL(REG_ITMP2);
 
        /* save return value */
@@ -3805,14 +3750,11 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        /* handle exception */
 
        M_MOV(REG_RA, REG_ITMP1_XPC);
+       M_ASUB_IMM(2, REG_ITMP1_XPC);
 
        disp = dseg_add_functionptr(cd, asm_handle_nat_exception);
        M_ALD_DSEG(REG_ITMP2, disp);
        M_JMP(RN, REG_ITMP2);
-
-       /* generate patcher traps */
-
-       emit_patcher_traps(jd);
 }
 
 /*