* src/vm/jit/parse.cpp,
[cacao.git] / src / vm / jit / m68k / codegen.c
index 0e622a328e856b3100ce1e24219cce1c31e243cf..a6ad45abeef0244cfe0ed521ba3f4dd8acdce5fb 100644 (file)
 #include <stdint.h>
 
 #include "md-abi.h"
-#include "md-os.h"
 
 #include "vm/types.h"
 #include "vm/jit/m68k/codegen.h"
 #include "vm/jit/m68k/emit.h"
 
 #include "mm/memory.h"
-#include "native/jni.h"
-#include "native/localref.h"
-#include "native/native.h"
 
-#include "threads/lock-common.h"
+#include "native/localref.hpp"
+#include "native/native.hpp"
 
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
+#include "threads/lock.hpp"
+
+#include "vm/jit/builtin.hpp"
+#include "vm/exceptions.hpp"
 #include "vm/global.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/loader.hpp"
+#include "vm/options.h"
+#include "vm/utf8.h"
+#include "vm/vm.hpp"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/patcher-common.h"
+#include "vm/jit/codegen-common.hpp"
+#include "vm/jit/patcher-common.hpp"
 #include "vm/jit/dseg.h"
-#include "vm/jit/linenumbertable.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
+#include "vm/jit/linenumbertable.hpp"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
 #include "vm/jit/abi.h"
-#include "vm/jit/parse.h"
+#include "vm/jit/parse.hpp"
 #include "vm/jit/reg.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/stacktrace.h"
-
-#include "vmcore/loader.h"
-#include "vmcore/options.h"
-#include "vmcore/utf8.h"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/stacktrace.hpp"
+#include "vm/jit/trap.h"
 
 
 bool codegen_emit(jitdata *jd) 
@@ -258,7 +256,7 @@ bool codegen_emit(jitdata *jd)
                        M_ALD(REG_ATMP1, REG_SP, cd->stackframesize + 4);
                        M_ATST(REG_ATMP1);
                        M_BNE(2);
-                       M_TRAP(M68K_EXCEPTION_HARDWARE_NULLPOINTER);
+                       M_TRAP(TRAP_NullPointerException);
                }
 
                M_AST(REG_ATMP1, REG_SP, rd->memuse * 8);
@@ -1994,9 +1992,6 @@ nowperformreturn:
                                superindex = super->index;
                        }
                        
-                       if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                               CODEGEN_CRITICAL_SECTION_NEW;
-
                        s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                        d = codegen_reg_of_dst(jd, iptr, REG_ITMP2);
 
@@ -2060,14 +2055,10 @@ nowperformreturn:
 
                                M_ALD(REG_ATMP1, s1, OFFSET(java_object_t, vftbl));
 
-                               CODEGEN_CRITICAL_SECTION_START;
-
                                M_ILD(REG_ITMP1, REG_ATMP1, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval));
                                M_ILD(REG_ITMP2, REG_ATMP2, OFFSET(vftbl_t, diffval));
 
-                               CODEGEN_CRITICAL_SECTION_END;
-
                                M_ISUB(REG_ITMP3, REG_ITMP1);
                                M_ICMP(REG_ITMP2, REG_ITMP1);
                                M_BHI(4);
@@ -2119,9 +2110,6 @@ nowperformreturn:
                                        superindex = super->index;
                                }
 
-                               if ((super == NULL) || !(super->flags & ACC_INTERFACE))
-                                       CODEGEN_CRITICAL_SECTION_NEW;
-
                                s1 = emit_load_s1(jd, iptr, REG_ATMP1);
                                assert(VAROP(iptr->s1)->type == TYPE_ADR);
 
@@ -2181,14 +2169,10 @@ nowperformreturn:
 
                                        M_ALD(REG_ATMP2, s1, OFFSET(java_object_t, vftbl));
 
-                                       CODEGEN_CRITICAL_SECTION_START;
-
                                        M_ILD(REG_ITMP3, REG_ATMP2, OFFSET(vftbl_t, baseval));  /* REG_ITMP3 == sub->vftbl->baseval */
                                        M_ILD(REG_ITMP1, REG_ATMP3, OFFSET(vftbl_t, baseval));
                                        M_ILD(REG_ITMP2, REG_ATMP3, OFFSET(vftbl_t, diffval));
 
-                                       CODEGEN_CRITICAL_SECTION_END;
-
                                        M_ISUB(REG_ITMP1, REG_ITMP3);
                                        M_ICMP(REG_ITMP2, REG_ITMP3);   /* XXX was CMPU */
 
@@ -2410,27 +2394,9 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        (void) dseg_add_unique_s4(cd, 0);                              /* IntSave         */
        (void) dseg_add_unique_s4(cd, 0);                              /* FltSave         */
 
-       /* print call trace */
-#if 0
-#if !defined(NDEBUG)
-       if (JITDATA_HAS_FLAG_VERBOSECALL(jd)) {
-               emit_verbosecall_enter(jd);
-       }
-#endif
-#endif
-
        /* generate code */
        M_AADD_IMM(-(cd->stackframesize*8), REG_SP);
 
-       /* get function address (this must happen before the stackframeinfo) */
-       if (f == NULL)  {
-               patcher_add_patch_ref(jd, PATCHER_resolve_native_function, m, 0);
-       }
-
-       M_AMOV_IMM(f, REG_ATMP2); /* do not move this line, the patcher is needed */
-
-       M_AST(REG_ATMP2, REG_SP, 4 * 4);
-
        /* put arguments for codegen_start_native_call onto stack */
        /* void codegen_start_native_call(u1 *datasp, u1 *pv, u1 *sp, u1 *ra) */
        
@@ -2448,9 +2414,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
        if (m->flags & ACC_STATIC)
                M_INT2ADRMOVE(REG_RESULT, REG_ATMP3);
 
-       /* load function pointer */
-       M_ALD(REG_ATMP2, REG_SP, 4 * 4);
-
        /* copy arguments into stackframe */
        for (i = md->paramcount -1, j = i + skipparams; i >= 0; --i, --j)       {
                t = md->paramtypes[i].type;
@@ -2476,11 +2439,12 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
                        M_AST(REG_ATMP3, REG_SP, 1 * 4);
 
                /* env ist first argument */
-               M_AMOV_IMM(_Jv_env, REG_ATMP1);
+               M_AMOV_IMM(VM_get_jnienv(), REG_ATMP1);
                M_AST(REG_ATMP1, REG_SP, 0 * 4);
        }
 
        /* call the native function */
+       M_AMOV_IMM(f, REG_ATMP2);
        M_JSR(REG_ATMP2);
 
        /* save return value */
@@ -2501,14 +2465,7 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
                default: assert(0);
        }
-#if 0  
-       /* print call trace */
-#if ! defined(NDEBUG)
-       if (JITDATA_HAS_FLAG_VERBOSECALL(jd)) {
-               emit_verbosecall_exit(jd);
-       }
-#endif
-#endif
+
        /* remove native stackframe info */
        /* therefore we call: java_objectheader *codegen_finish_native_call(u1 *datasp) */
 
@@ -2566,9 +2523,6 @@ void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int s
 
        /* should never be reached from within jit code*/
        M_JSR_IMM(0);
-
-       /* generate patcher stub call code */
-       emit_patcher_traps(jd);
 }