* Merged in new trap code (twisti-branch).
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 28 Apr 2008 15:11:29 +0000 (17:11 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 28 Apr 2008 15:11:29 +0000 (17:11 +0200)
1  2 
src/vm/jit/m68k/codegen.c
src/vm/jit/mips/linux/md-os.c
src/vm/vm.c

index 478b6f3cf578a07a739152f77a9a0669ab3b40a1,0862cad4905ad2d5ea407286e7f7f80e0f2af714..41bd7c7f7f83e459c527546e81fe368a01bbdf8b
@@@ -29,7 -29,6 +29,6 @@@
  #include <stdint.h>
  
  #include "md-abi.h"
- #include "md-os.h"
  
  #include "vm/types.h"
  #include "vm/jit/m68k/codegen.h"
@@@ -60,6 -59,7 +59,7 @@@
  #include "vm/jit/reg.h"
  #include "vm/jit/replace.h"
  #include "vm/jit/stacktrace.h"
+ #include "vm/jit/trap.h"
  
  #include "vmcore/loader.h"
  #include "vmcore/options.h"
@@@ -258,7 -258,7 +258,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);
@@@ -2410,9 -2410,27 +2410,9 @@@ void codegen_emit_stub_native(jitdata *
        (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) */
        
        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;
        }
  
        /* call the native function */
 +      M_AMOV_IMM(f, REG_ATMP2);
        M_JSR(REG_ATMP2);
  
        /* save return value */
  
                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) */
  
  
        /* should never be reached from within jit code*/
        M_JSR_IMM(0);
 -
 -      /* generate patcher stub call code */
 -      emit_patcher_traps(jd);
  }
  
  
index e3bada4c36a779c4eb4027bc02ea6119ea3589d9,31dc479e5c9018071a62c6b5e5abfbc6c1d448ae..f8c9407d9e3bd82e24ddc26e16593690b0f03733
@@@ -45,6 -45,7 +45,7 @@@
  
  #include "vm/jit/asmpart.h"
  #include "vm/jit/stacktrace.h"
+ #include "vm/jit/trap.h"
  
  
  /* md_init *********************************************************************
@@@ -119,8 -120,7 +120,8 @@@ void md_signal_handler_sigsegv(int sig
        sp  = (u1 *) (ptrint) _gregs[REG_SP];
        ra  = (u1 *) (ptrint) _gregs[REG_RA];        /* this is correct for leafs */
  
 -#if !defined(__UCLIBC__) && ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 5))
 +#if !defined(__UCLIBC__)
 +# if ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 5))
        /* NOTE: We only need this for pre glibc-2.5. */
  
        xpc = (u1 *) (ptrint) _mc->pc;
                xpc = xpc - 4;
                break;
        }
 +# else
 +      xpc = (u1 *) (ptrint) _mc->pc;
 +# endif
  #else
        xpc = (u1 *) (ptrint) _gregs[CTX_EPC];
  #endif
                type = disp;
                val  = _gregs[d];
  
-               if (type == EXCEPTION_HARDWARE_COMPILER) {
+               if (type == TRAP_COMPILER) {
                        /* The XPC is the RA minus 4, because the RA points to the
                           instruction after the call. */
  
                   define is 0. */
  
                addr = _gregs[s1];
-               type = (s4) addr;
+               type = (int) addr;
                val  = 0;
        }
  
-       /* Handle the type. */
+       /* Handle the trap. */
  
-       p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
  
        /* Set registers. */
  
        switch (type) {
-       case EXCEPTION_HARDWARE_COMPILER:
+       case TRAP_COMPILER:
                if (p != NULL) {
                        _gregs[REG_PV]  = (uintptr_t) p;
  #if defined(__UCLIBC__)
  
                /* fall-through */
  
-       case EXCEPTION_HARDWARE_PATCHER:
+       case TRAP_PATCHER:
                if (p == NULL) {
                        /* We set the PC again because the cause may have changed
                           the XPC. */
diff --combined src/vm/vm.c
index b2a0a7eaa25a743178c9704e4f36af906ba1852c,3a44d2daec65ab4e5df0f31bcdf3547413e1c943..30134fcb11eb31a270201d08b74e8a4c1253b56b
  # include "vm/jit/python.h"
  #endif
  
+ #include "vm/jit/trap.h"
  #include "vmcore/classcache.h"
  #include "vmcore/options.h"
  #include "vmcore/statistics.h"
@@@ -1516,7 -1518,9 +1518,9 @@@ bool vm_create(JavaVMInitArgs *vm_args
        primitive_postinit();
        method_init();
  
-       exceptions_init();
+ #if defined(ENABLE_JIT)
+       trap_init();
+ #endif
  
        if (!builtin_init())
                vm_abort("vm_create: builtin_init failed");
@@@ -2240,8 -2244,7 +2244,8 @@@ static char *vm_get_mainclass_from_jar(
        o = vm_call_method(m, o, s);
  
        if (o == NULL) {
 -              exceptions_print_stacktrace();
 +              fprintf(stderr, "Failed to load Main-Class manifest attribute from\n");
 +              fprintf(stderr, "%s\n", mainstring);
                return NULL;
        }