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

--HG--
branch : twisti

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

index f90fe2a98008cd2536db6f2aec1f134969b1c9ec..5955ff12e0797bfd625b540da05f9c45f97af159 100644 (file)
@@ -51,6 +51,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-trap.h \
        md.c \
        md.h
 
index 9135c99619f715ae1806354644e6c25cd91073d7..4caac6dd7a2e01321fd6428b92dd50be3eba98a5 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/arm/emit.c - Arm code emitter functions
 
-   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
@@ -50,6 +48,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.h"
+#include "vm/jit/trap.h"
 
 #include "toolbox/logging.h" /* XXX for debugging only */
 
@@ -475,7 +474,7 @@ void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                CHECK_INT_REG(reg);
                M_TEQ_IMM(reg, 0);
-               M_TRAPEQ(0, EXCEPTION_HARDWARE_ARITHMETIC);
+               M_TRAPEQ(0, TRAP_ArithmeticException);
        }
 }
 
@@ -490,14 +489,14 @@ void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TST(reg, reg);
-               M_TRAPEQ(0, EXCEPTION_HARDWARE_NULLPOINTER);
+               M_TRAPEQ(0, TRAP_NullPointerException);
        }
 }
 
 void emit_nullpointer_check_force(codegendata *cd, instruction *iptr, s4 reg)
 {
        M_TST(reg, reg);
-       M_TRAPEQ(0, EXCEPTION_HARDWARE_NULLPOINTER);
+       M_TRAPEQ(0, TRAP_NullPointerException);
 }
 
 
@@ -512,7 +511,7 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_ILD_INTERN(REG_ITMP3, s1, OFFSET(java_array_t, size));
                M_CMP(s2, REG_ITMP3);
-               M_TRAPHS(s2, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
+               M_TRAPHS(s2, TRAP_ArrayIndexOutOfBoundsException);
        }
 }
 
@@ -527,7 +526,7 @@ void emit_arraystore_check(codegendata *cd, instruction *iptr)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TST(REG_RESULT, REG_RESULT);
-               M_TRAPEQ(0, EXCEPTION_HARDWARE_ARRAYSTORE);
+               M_TRAPEQ(0, TRAP_ArrayStoreException);
        }
 }
 
@@ -543,15 +542,15 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                switch (condition) {
                case BRANCH_EQ:
-                       M_TRAPEQ(s1, EXCEPTION_HARDWARE_CLASSCAST);
+                       M_TRAPEQ(s1, TRAP_ClassCastException);
                        break;
 
                case BRANCH_LE:
-                       M_TRAPLE(s1, EXCEPTION_HARDWARE_CLASSCAST);
+                       M_TRAPLE(s1, TRAP_ClassCastException);
                        break;
 
                case BRANCH_UGT:
-                       M_TRAPHI(s1, EXCEPTION_HARDWARE_CLASSCAST);
+                       M_TRAPHI(s1, TRAP_ClassCastException);
                        break;
 
                default:
@@ -570,7 +569,7 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 {
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_TST(REG_RESULT, REG_RESULT);
-               M_TRAPEQ(0, EXCEPTION_HARDWARE_EXCEPTION);
+               M_TRAPEQ(0, TRAP_CHECK_EXCEPTION);
        }
 }
 
@@ -588,9 +587,9 @@ uint32_t emit_trap(codegendata *cd)
        /* Get machine code which is patched back in later. The
           trap is 1 instruction word long. */
 
-       mcode = *((u4 *) cd->mcodeptr);
+       mcode = *((uint32_t *) cd->mcodeptr);
 
-       M_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
+       M_TRAP(0, TRAP_PATCHER);
 
        return mcode;
 }
index 27aef3255a0af3274cfdaa9a6bbda62f10f6b24f..568e6a048ce1e71e10477b483c84ba8034e584db 100644 (file)
@@ -58,6 +58,7 @@ typedef struct ucontext {
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 
 /* md_signal_handler_sigsegv ***************************************************
@@ -98,24 +99,21 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
        mcode = *((s4 *) xpc);
 
-       /* this is a NullPointerException */
+       /* This is a NullPointerException. */
 
        addr = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + ((mcode >> 16) & 0x0f));
-       type = EXCEPTION_HARDWARE_NULLPOINTER;
+       type = addr;
        val  = 0;
 
-       if (addr != 0)
-               vm_abort("md_signal_handler_sigsegv: faulting address is not NULL: addr=%p", addr);
+       /* Handle the trap. */
 
-       /* Handle the type. */
-
-       p = signal_handle(type, val, pv, sp, ra, xpc, _p);
+       p = trap_handle(type, val, pv, sp, ra, xpc, _p);
 
        /* set registers */
 
-       _sc->arm_r10 = (intptr_t) p;
-       _sc->arm_fp  = (intptr_t) xpc;
-       _sc->arm_pc  = (intptr_t) asm_handle_exception;
+       _sc->arm_r10 = (uintptr_t) p;
+       _sc->arm_fp  = (uintptr_t) xpc;
+       _sc->arm_pc  = (uintptr_t) asm_handle_exception;
 }
 
 
@@ -166,17 +164,17 @@ void md_signal_handler_sigill(int sig, siginfo_t *siginfo, void *_p)
        type = (mcode >> 8) & 0x0fff;
        val  = *((s4 *) _sc + OFFSET(scontext_t, arm_r0)/4 + (mcode & 0x0f));
 
-       /* 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 if we have an exception, continue execution
           otherwise (this is needed for patchers to work) */
 
        if (p != NULL) {
-               _sc->arm_r10 = (intptr_t) p;
-               _sc->arm_fp  = (intptr_t) xpc;
-               _sc->arm_pc  = (intptr_t) asm_handle_exception;
+               _sc->arm_r10 = (uintptr_t) p;
+               _sc->arm_fp  = (uintptr_t) xpc;
+               _sc->arm_pc  = (uintptr_t) asm_handle_exception;
        }
 }
 
diff --git a/src/vm/jit/arm/md-trap.h b/src/vm/jit/arm/md-trap.h
new file mode 100644 (file)
index 0000000..7992441
--- /dev/null
@@ -0,0 +1,71 @@
+/* src/vm/jit/arm/md-trap.h - ARM 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 (arm) we use illegal instructions as trap
+ * instructions.  Since the illegal instruction with the value 1 is
+ * used by the kernel to generate a SIGTRAP, we skip this one.
+ */
+
+#define TRAP_INSTRUCTION_IS_LOAD    0
+
+enum {
+       TRAP_NullPointerException           = 0,
+
+       /* Skip 1 because it's the SIGTRAP illegal instruction. */
+
+       TRAP_ArithmeticException            = 2,
+       TRAP_ArrayIndexOutOfBoundsException = 3,
+       TRAP_ArrayStoreException            = 4,
+       TRAP_ClassCastException             = 5,
+       TRAP_CHECK_EXCEPTION                = 6,
+       TRAP_PATCHER                        = 7,
+       TRAP_COMPILER                       = 8
+};
+
+#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:
+ */