* src/vm/jit/exceptiontable.c: New file.
[cacao.git] / src / vm / jit / mips / codegen.c
index 159887ef118ccb6216c7d39020be6d8a131a88fe..99e9e67a58b31e6387917adbd01585385882a9c6 100644 (file)
@@ -83,7 +83,6 @@ bool codegen_emit(jitdata *jd)
        varinfo            *var;
        basicblock         *bptr;
        instruction        *iptr;
-       exception_entry    *ex;
        u2                  currentline;
        constant_classref  *cr;
        unresolved_class   *uc;
@@ -130,7 +129,7 @@ bool codegen_emit(jitdata *jd)
 #if defined(ENABLE_THREADS)
        /* space to save argument of monitor_enter */
 
-       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+       if (checksync && code_is_synchronized(code)) {
 # if SIZEOF_VOID_P == 8
                cd->stackframesize++;
 # else
@@ -150,19 +149,8 @@ bool codegen_emit(jitdata *jd)
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
        (void) dseg_add_unique_s4(cd, cd->stackframesize * 8); /* FrameSize       */
 
-#if defined(ENABLE_THREADS)
-       /* 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.
-       */
-
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_add_unique_s4(cd, (rd->memuse + 1) * 8); /* IsSync        */
-       else
-#endif
-               (void) dseg_add_unique_s4(cd, 0);                  /* IsSync          */
-                                              
+       code->synchronizedoffset = rd->memuse * 8;
+
        /* REMOVEME: We still need it for exception handling in assembler. */
 
        if (code_is_leafmethod(code))
@@ -172,18 +160,9 @@ 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 */
-       dseg_addlinenumbertablesize(cd);
-       (void) dseg_add_unique_s4(cd, jd->exceptiontablelength); /* ExTableSize   */
 
-       /* create exception table */
+       dseg_addlinenumbertablesize(cd);
 
-       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);
-       }
-       
        /* create stack frame (if necessary) */
 
        if (cd->stackframesize)
@@ -289,7 +268,7 @@ bool codegen_emit(jitdata *jd)
        /* call monitorenter function */
 
 #if defined(ENABLE_THREADS)
-       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+       if (checksync && code_is_synchronized(code)) {
                /* stack offset for monitor argument */
 
                s1 = rd->memuse;
@@ -2838,7 +2817,7 @@ nowperformreturn:
 #endif
 
 #if defined(ENABLE_THREADS)
-                       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+                       if (checksync && code_is_synchronized(code)) {
                                disp = dseg_add_functionptr(cd, LOCK_monitor_exit);
                                M_ALD(REG_ITMP3, REG_PV, disp);
 
@@ -3659,8 +3638,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        methoddesc  *md;
        s4           i, j;
        s4           t;
-       s4           s1, s2, disp;
-       s4           funcdisp;              /* displacement of the function       */
+       int          s1, s2;
+       int          disp;
 
        /* get required compiler data */
 
@@ -3711,13 +3690,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                emit_verbosecall_enter(jd);
 #endif
 
-       /* 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);
-
        /* save integer and float argument registers */
 
 #if SIZEOF_VOID_P == 8
@@ -3950,9 +3922,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                M_ALD(REG_A0, REG_PV, disp);
        }
 
-       /* do the native function call */
+       /* Call the native function. */
 
-       M_ALD(REG_ITMP3, REG_PV, funcdisp); /* load adress of native method       */
+       disp = dseg_add_functionptr(cd, f);
+       M_ALD(REG_ITMP3, REG_PV, disp);     /* load adress of native method       */
        M_JSR(REG_RA, REG_ITMP3);           /* call native method                 */
        M_NOP;                              /* delay slot                         */