* src/threads/critical.c: Removed.
[cacao.git] / src / vm / jit / s390 / md.c
index 074f5f25c9455335a3b462a64dfe4d109abb0566..b21bbb87190bebee9e8eeb6eb98d1f99a09e7f3d 100644 (file)
 
 #include "vm/jit/s390/md-abi.h"
 
-#include "threads/threads-common.h"
+#include "threads/thread.h"
 
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
+
 #include "vm/jit/asmpart.h"
 #include "vm/jit/abi.h"
+#include "vm/jit/executionstate.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/methodtree.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 #if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
 #include "vmcore/options.h" /* XXX debug */
@@ -100,7 +103,7 @@ void md_dump_context(u1 *pc, mcontext_t *mc) {
                m = (*(codeinfo **)(pv + CodeinfoPointer))->m;
                log_println(
                        "Java method: class %s, method %s, descriptor %s.",
-                       m->class->name->text, m->name->text, m->descriptor->text
+                       m->clazz->name->text, m->name->text, m->descriptor->text
                );
        }
 
@@ -122,11 +125,8 @@ void md_dump_context(u1 *pc, mcontext_t *mc) {
                log_println("\tf%d\t0x%016llX\t(double)%e\t(float)%f", i, freg.l, freg.fr.d, freg.fr.f);
        }
 
-#if defined(ENABLE_THREADS)
        log_println("Dumping the current stacktrace:");
-       threads_print_stacktrace();
-#endif
-
+       stacktrace_print_current();
 }
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -185,20 +185,20 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
        pv = (u1 *)_mc->gregs[REG_PV] - N_PV_OFFSET;
        sp = (u1 *)_mc->gregs[REG_SP];
        ra = xpc;
-       type = EXCEPTION_HARDWARE_NULLPOINTER;
+       type = TRAP_NullPointerException;
        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);
 
        if (p != NULL) {
-               _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
-               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
-               _mc->psw.addr              = (intptr_t) asm_handle_exception;
+               _mc->gregs[REG_ITMP3_XPTR] = (uintptr_t) p;
+               _mc->gregs[REG_ITMP1_XPC]  = (uintptr_t) xpc;
+               _mc->psw.addr              = (uintptr_t) asm_handle_exception;
        }
        else {
-               _mc->psw.addr              = (intptr_t) xpc;
+               _mc->psw.addr              = (uintptr_t) xpc;
        }
 }
 
@@ -233,7 +233,7 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
                sp = (u1 *)_mc->gregs[REG_SP];
                val = (ptrint)_mc->gregs[reg];
 
-               if (EXCEPTION_HARDWARE_COMPILER == type) {
+               if (TRAP_COMPILER == type) {
                        /* The PV from the compiler stub is equal to the XPC. */
 
                        pv = xpc;
@@ -245,28 +245,28 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
                        xpc = ra - 2;
                }
 
-               /* 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);
 
-               if (EXCEPTION_HARDWARE_COMPILER == type) {
+               if (TRAP_COMPILER == type) {
                        if (NULL == p) {
-                               _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) builtin_retrieve_exception();
-                               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) ra - 2;
-                               _mc->gregs[REG_PV]         = (intptr_t) md_codegen_get_pv_from_pc(ra);
-                               _mc->psw.addr              = (intptr_t) asm_handle_exception;
+                               _mc->gregs[REG_ITMP3_XPTR] = (uintptr_t) builtin_retrieve_exception();
+                               _mc->gregs[REG_ITMP1_XPC]  = (uintptr_t) ra - 2;
+                               _mc->gregs[REG_PV]         = (uintptr_t) md_codegen_get_pv_from_pc(ra);
+                               _mc->psw.addr              = (uintptr_t) asm_handle_exception;
                        } else {
-                               _mc->gregs[REG_PV]         = (intptr_t) p;
-                               _mc->psw.addr              = (intptr_t) p;
+                               _mc->gregs[REG_PV]         = (uintptr_t) p;
+                               _mc->psw.addr              = (uintptr_t) p;
                        }
                } else {
                        if (p != NULL) {
-                               _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
-                               _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
-                               _mc->psw.addr              = (intptr_t) asm_handle_exception;
+                               _mc->gregs[REG_ITMP3_XPTR] = (uintptr_t) p;
+                               _mc->gregs[REG_ITMP1_XPC]  = (uintptr_t) xpc;
+                               _mc->psw.addr              = (uintptr_t) asm_handle_exception;
                        }
                        else {
-                               _mc->psw.addr              = (intptr_t) xpc;
+                               _mc->psw.addr              = (uintptr_t) xpc;
                        }
                }
        } else {
@@ -335,16 +335,16 @@ void md_signal_handler_sigfpe(int sig, siginfo_t *siginfo, void *_p)
                        sp = (u1 *)_mc->gregs[REG_SP];
                        ra = xpc;
 
-                       type = EXCEPTION_HARDWARE_ARITHMETIC;
+                       type = TRAP_ArithmeticException;
                        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);
 
-                       _mc->gregs[REG_ITMP3_XPTR] = (intptr_t) p;
-                       _mc->gregs[REG_ITMP1_XPC]  = (intptr_t) xpc;
-                       _mc->psw.addr              = (intptr_t) asm_handle_exception;
+                       _mc->gregs[REG_ITMP3_XPTR] = (uintptr_t) p;
+                       _mc->gregs[REG_ITMP1_XPC]  = (uintptr_t) xpc;
+                       _mc->psw.addr              = (uintptr_t) asm_handle_exception;
 
                        return;
                }
@@ -388,25 +388,28 @@ void md_signal_handler_sigusr2(int sig, siginfo_t *siginfo, void *_p)
 #endif
 
 
-#if defined(ENABLE_THREADS)
-void md_critical_section_restart(ucontext_t *_uc)
+/**
+ * Read the given context into an executionstate.
+ *
+ * @param es      execution state
+ * @param context machine context
+ */
+void md_executionstate_read(executionstate_t* es, void* context)
 {
-       mcontext_t *_mc;
-       u1         *pc;
-       void       *npc;
-
-       _mc = &_uc->uc_mcontext;
-
-       pc = (u1 *)_mc->psw.addr;
+       vm_abort("md_executionstate_read: IMPLEMENT ME!");
+}
 
-       npc = critical_find_restart_point(pc);
 
-       if (npc != NULL) {
-               log_println("%s: pc=%p, npc=%p", __FUNCTION__, pc, npc);
-               _mc->psw.addr = (ptrint) npc;
-       }
+/**
+ * Write the given executionstate back to the context.
+ *
+ * @param es      execution state
+ * @param context machine context
+ */
+void md_executionstate_write(executionstate_t* es, void* context)
+{
+       vm_abort("md_executionstate_write: IMPLEMENT ME!");
 }
-#endif
 
 
 /* md_jit_method_patch_address *************************************************