* src/vm/exceptions.c (exceptions_handle_exception) [__ARM__]: Added
[cacao.git] / src / vm / jit / arm / codegen.c
index 7146e0581e30ae8ae36123c102affbea599a363a..048389eb925d2ecb27cd177c11bb34497cafa1fd 100644 (file)
@@ -129,7 +129,7 @@ bool codegen_emit(jitdata *jd)
        spilledregs_num = rd->memuse;
 
 #if defined(ENABLE_THREADS)        /* space to save argument of monitor_enter */
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
+       if (checksync && code_is_synchronized(code))
                spilledregs_num++;
 #endif
 
@@ -147,18 +147,14 @@ bool codegen_emit(jitdata *jd)
        (void) dseg_add_unique_address(cd, code);              /* CodeinfoPointer */
        (void) dseg_add_unique_s4(cd, cd->stackframesize);     /* 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.
        */
+       /* XXX Remove this "offset by one". */
 
-       if (checksync && (m->flags & ACC_SYNCHRONIZED))
-               (void) dseg_add_unique_s4(cd, rd->memuse * 8 + 4);/* IsSync         */
-       else
-#endif
-               (void) dseg_add_unique_s4(cd, 0);                  /* IsSync          */
+       code->synchronizedoffset = (rd->memuse + 1) * 8;
 
        /* REMOVEME: We still need it for exception handling in assembler. */
 
@@ -288,7 +284,7 @@ bool codegen_emit(jitdata *jd)
 #if defined(ENABLE_THREADS)
        /* call monitorenter function */
 
-       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+       if (checksync && code_is_synchronized(code)) {
                /* stack offset for monitor argument */
 
                s1 = rd->memuse * 8;
@@ -2126,7 +2122,7 @@ bool codegen_emit(jitdata *jd)
 #if defined(ENABLE_THREADS)
                        /* call monitorexit function */
 
-                       if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
+                       if (checksync && code_is_synchronized(code)) {
                                /* stack offset for monitor argument */
 
                                s1 = rd->memuse * 8;
@@ -2895,7 +2891,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        methoddesc  *md;
        s4           i, j;
        s4           t;
-       s4           disp, funcdisp, s1, s2;
+       int          s1, s2;
+       int          disp;
 
        /* get required compiler data */
 
@@ -2911,7 +2908,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
        cd->stackframesize =
                4 +                                                /* return address  */
-               sizeof(stackframeinfo) +                           /* stackframeinfo  */
+               sizeof(stackframeinfo_t) +                         /* stackframeinfo  */
                sizeof(localref_table) +                           /* localref_table  */
                nmd->memuse * 4;                                   /* stack arguments */
 
@@ -2940,19 +2937,12 @@ 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);
-
 #if defined(ENABLE_GC_CACAO)
        /* Save callee saved integer registers in stackframeinfo (GC may
           need to recover them during a collection). */
 
-       disp = cd->stackframesize - SIZEOF_VOID_P - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, intregs);
+       disp = cd->stackframesize - SIZEOF_VOID_P - sizeof(stackframeinfo_t) +
+               OFFSET(stackframeinfo_t, intregs);
 
        for (i = 0; i < INT_SAV_CNT; i++)
                M_STR_INTERN(abi_registers_integer_saved[i], REG_SP, disp + i * 4);
@@ -3047,9 +3037,10 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                M_DSEG_LOAD(REG_A0, disp);
        }
 
-       /* do the native function call */
+       /* Call the native function. */
 
-       M_DSEG_BRANCH(funcdisp);
+       disp = dseg_add_functionptr(cd, f);
+       M_DSEG_BRANCH(disp);
 
        /* recompute pv */
        /* TODO: this is only needed because of the tracer ... do we
@@ -3101,8 +3092,8 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        /* restore callee saved int registers from stackframeinfo (GC might have  */
        /* modified them during a collection).                                    */
 
-       disp = cd->stackframesize - SIZEOF_VOID_P - sizeof(stackframeinfo) +
-               OFFSET(stackframeinfo, intregs);
+       disp = cd->stackframesize - SIZEOF_VOID_P - sizeof(stackframeinfo_t) +
+               OFFSET(stackframeinfo_t, intregs);
 
        for (i = 0; i < INT_SAV_CNT; i++)
                M_LDR_INTERN(abi_registers_integer_saved[i], REG_SP, disp + i * 4);