* src/vm/jit/s390/Makefile.am (libarch_la_SOURCES): Added md-trap.h.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 28 Apr 2008 10:47:19 +0000 (12:47 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 28 Apr 2008 10:47:19 +0000 (12:47 +0200)
* src/vm/jit/s390/codegen.c: Use new trap stuff.
* src/vm/jit/s390/emit.c: Likewise.
* src/vm/jit/s390/md-trap.h: New file.
* src/vm/jit/s390/md.c: Use new trap stuff.

--HG--
branch : twisti

src/vm/jit/s390/Makefile.am
src/vm/jit/s390/codegen.c
src/vm/jit/s390/emit.c
src/vm/jit/s390/md-trap.h [new file with mode: 0644]
src/vm/jit/s390/md.c

index a51a16e6387aea642fcbfea254062fc7d76d3873..a9c16bd31a3ac1ae7e4da4f34928cd5eb28a5330 100644 (file)
@@ -51,6 +51,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-trap.h \
        md.c \
        md.h
 
index f53b1427ea1174e835a48df5ff934b7a55a3abbc..ccfa92cf86713a170a05b0159de8b0a4b56d385b 100644 (file)
 #include <stdint.h>
 #include <stdio.h>
 
+#include "vm/jit/s390/arch.h"
+#include "vm/jit/s390/codegen.h"
+#include "vm/jit/s390/emit.h"
+#include "vm/jit/s390/md-abi.h"
+
 #include "native/jni.h"
 #include "native/localref.h"
 #include "native/native.h"
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
 #include "vmcore/statistics.h"
+
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
+#include "vm/types.h"
+#include "vm/stringlocal.h"
+#include "vm/vm.h"
+
 #include "vm/jit/abi.h"
 #if defined(ENABLE_LSRA)
 # include "vm/jit/allocator/lsra.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
-#include "vm/jit/s390/arch.h"
-#include "vm/jit/s390/codegen.h"
-#include "vm/jit/s390/emit.h"
-#include "vm/jit/s390/md-abi.h"
 #include "vm/jit/stacktrace.h"
-#include "vm/types.h"
-#include "vm/stringlocal.h"
-#include "vm/vm.h"
+#include "vm/jit/trap.h"
+
 
 /* DO__LOG generates a call to do__log. No registers are destroyed,
  * so you may use it anywhere. regs is an array containing all general
@@ -372,7 +377,7 @@ bool codegen_emit(jitdata *jd)
                else {
                        M_TEST(REG_A0);
                        M_BNE(SZ_BRC + SZ_ILL);
-                       M_ILL(EXCEPTION_HARDWARE_NULLPOINTER);
+                       M_ILL(TRAP_NullPointerException);
                }
 
                disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
index 1011a62caf4d88ed6e18d8c1eea84044805e7f17..9ac259c71ff7dc7482dd32e287c9999803ea023e 100644 (file)
 #include <assert.h>
 #include <stdint.h>
 
+#include "vm/jit/s390/codegen.h"
+#include "vm/jit/s390/emit.h"
+#include "vm/jit/s390/md-abi.h"
+
 #include "mm/memory.h"
 
 #include "threads/lock-common.h"
@@ -34,6 +38,8 @@
 #include "vm/builtin.h"
 #include "vm/exceptions.h"
 #include "vm/global.h"
+#include "vm/types.h"
+
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.h"
-#include "vm/jit/s390/codegen.h"
-#include "vm/jit/s390/emit.h"
-#include "vm/jit/s390/md-abi.h"
-#include "vm/types.h"
+#include "vm/jit/trap.h"
+
 #include "vmcore/options.h"
 
+
 /* emit_load *******************************************************************
 
    Emits a possible load of an operand.
@@ -227,7 +232,7 @@ uint32_t emit_trap(codegendata *cd)
 
        mcode = *((u2 *) cd->mcodeptr);
 
-       M_ILL(EXCEPTION_HARDWARE_PATCHER);
+       M_ILL(TRAP_PATCHER);
 
        return mcode;
 }
@@ -683,11 +688,12 @@ void emit_branch(codegendata *cd, s4 disp, s4 condition, s4 reg, u4 opt) {
        }
 }
 
-void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg) {
+void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
+{
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TEST(reg);
                M_BNE(SZ_BRC + SZ_ILL);
-               M_ILL(EXCEPTION_HARDWARE_ARITHMETIC);
+               M_ILL(TRAP_ArithmeticException);
        }
 }
 
@@ -705,7 +711,7 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
                 */
                N_CL(s2, OFFSET(java_array_t, size), RN, s1);
         M_BLT(SZ_BRC + SZ_ILL);
-               M_ILL2(s2, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
+               M_ILL2(s2, TRAP_ArrayIndexOutOfBoundsException);
        }
 }
 
@@ -721,7 +727,7 @@ void emit_arraystore_check(codegendata *cd, instruction *iptr)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TEST(REG_RESULT);
                M_BNE(SZ_BRC + SZ_ILL);
-               M_ILL(EXCEPTION_HARDWARE_ARRAYSTORE);
+               M_ILL(TRAP_ArrayStoreException);
        }
 }
 
@@ -744,23 +750,25 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
                        default:
                                vm_abort("emit_classcast_check: unknown condition %d", condition);
                }
-               M_ILL2(s1, EXCEPTION_HARDWARE_CLASSCAST);
+               M_ILL2(s1, TRAP_ClassCastException);
        }
 }
 
-void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg) {
+void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
+{
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TEST(reg);
                M_BNE(SZ_BRC + SZ_ILL);
-               M_ILL(EXCEPTION_HARDWARE_NULLPOINTER);
+               M_ILL(TRAP_NullPointerException);
        }
 }
 
-void emit_exception_check(codegendata *cd, instruction *iptr) {
+void emit_exception_check(codegendata *cd, instruction *iptr)
+{
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TEST(REG_RESULT);
                M_BNE(SZ_BRC + SZ_ILL);
-               M_ILL(EXCEPTION_HARDWARE_EXCEPTION);
+               M_ILL(TRAP_CHECK_EXCEPTION);
        }
 }
 
@@ -806,7 +814,7 @@ void emit_restore_pv(codegendata *cd) {
 
 void emit_trap_compiler(codegendata *cd)
 {
-       M_ILL2(REG_METHODPTR, EXCEPTION_HARDWARE_COMPILER);
+       M_ILL2(REG_METHODPTR, TRAP_COMPILER);
 }
 
 /*
diff --git a/src/vm/jit/s390/md-trap.h b/src/vm/jit/s390/md-trap.h
new file mode 100644 (file)
index 0000000..ac0fe08
--- /dev/null
@@ -0,0 +1,67 @@
+/* src/vm/jit/s390/md-trap.h - s390 hardware traps
+
+   Copyright (C) 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_TRAP_H
+#define _MD_TRAP_H
+
+#include "config.h"
+
+
+/**
+ * Trap number defines.
+ *
+ * On this architecture (s390) we use illegal instructions as trap
+ * instructions.
+ */
+
+#define TRAP_INSTRUCTION_IS_LOAD    0
+
+enum {
+       TRAP_NullPointerException           = 0,
+       TRAP_ArithmeticException            = 1,
+       TRAP_ArrayIndexOutOfBoundsException = 2,
+       TRAP_ArrayStoreException            = 3,
+       TRAP_ClassCastException             = 4,
+       TRAP_CHECK_EXCEPTION                = 5,
+       TRAP_PATCHER                        = 6,
+       TRAP_COMPILER                       = 7
+};
+
+#endif /* _MD_TRAP_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 89d04f154d9ea51ca15f1c17e69e612b85f01700..cce456454ae35d5a3fdf88c4a419bc05bb3d236f 100644 (file)
@@ -43,6 +43,7 @@
 #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 */
@@ -182,20 +183,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;
        }
 }
 
@@ -230,7 +231,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;
@@ -242,28 +243,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 {
@@ -332,16 +333,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;
                }