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

--HG--
branch : twisti

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

index e94ae058709c270487bfa5973b03a063e328fb83..cd4e0f470162efcf4cae8b40bd4f9d8d9f8e978f 100644 (file)
@@ -1,9 +1,7 @@
 ## src/vm/jit/alpha/Makefile.am
 ##
-## 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.
 ##
@@ -21,8 +19,8 @@
 ## along with this program; if not, write to the Free Software
 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 ## 02110-1301, USA.
-##
-##
+
+
 DIST_SUBDIRS = \
        freebsd \
        linux
@@ -57,6 +55,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-trap.h \
        md.c \
        md.h
 
index 28775f76bc3aa68aa315ab5180ea21790e8922bc..e30d7d601b5702a0ebdfc0c2eb1ca79ce97a1331 100644 (file)
@@ -61,6 +61,7 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 #if defined(ENABLE_SSA)
 # include "vm/jit/optimizing/lsra.h"
@@ -252,7 +253,7 @@ bool codegen_emit(jitdata *jd)
                }
                else {
                        M_BNEZ(REG_A0, 1);
-                       M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+                       M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_NullPointerException);
                }
 
                M_AST(REG_A0, REG_SP, s1 * 8);
index 63f1fbab4c6dc194525b4f96f80bedfd04456bc0..f0d1b7c8967e54335b258afce0b2c0e1d0265fc5 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/alpha/emit.c - Alpha 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.
 
@@ -39,8 +37,6 @@
 
 #include "threads/lock-common.h"
 
-#include "vm/exceptions.h"
-
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
 #include "vm/jit/asmpart.h"
@@ -50,6 +46,7 @@
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/trace.h"
+#include "vm/jit/trap.h"
 
 #include "vmcore/options.h"
 
@@ -327,7 +324,7 @@ void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
                M_BNEZ(reg, 1);
                /* Destination register must not be REG_ZERO, because then no
                   SIGSEGV is thrown. */
-               M_ALD_INTERN(reg, REG_ZERO, EXCEPTION_HARDWARE_ARITHMETIC);
+               M_ALD_INTERN(reg, REG_ZERO, TRAP_ArithmeticException);
        }
 }
 
@@ -344,7 +341,7 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
                M_ILD(REG_ITMP3, s1, OFFSET(java_array_t, size));
                M_CMPULT(s2, REG_ITMP3, REG_ITMP3);
                M_BNEZ(REG_ITMP3, 1);
-               M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
+               M_ALD_INTERN(s2, REG_ZERO, TRAP_ArrayIndexOutOfBoundsException);
        }
 }
 
@@ -361,7 +358,7 @@ void emit_arraystore_check(codegendata *cd, instruction *iptr)
                M_BNEZ(REG_RESULT, 1);
                /* Destination register must not be REG_ZERO, because then no
                   SIGSEGV is thrown. */
-               M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_ARRAYSTORE);
+               M_ALD_INTERN(REG_RESULT, REG_ZERO, TRAP_ArrayStoreException);
        }
 }
 
@@ -385,7 +382,7 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
                default:
                        vm_abort("emit_classcast_check: unknown condition %d", condition);
                }
-               M_ALD_INTERN(s1, REG_ZERO, EXCEPTION_HARDWARE_CLASSCAST);
+               M_ALD_INTERN(s1, REG_ZERO, TRAP_ClassCastException);
        }
 }
 
@@ -402,7 +399,7 @@ void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
                M_BNEZ(reg, 1);
                /* Destination register must not be REG_ZERO, because then no
                   SIGSEGV is thrown. */
-               M_ALD_INTERN(reg, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+               M_ALD_INTERN(reg, REG_ZERO, TRAP_NullPointerException);
        }
 }
 
@@ -419,7 +416,7 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
                M_BNEZ(REG_RESULT, 1);
                /* Destination register must not be REG_ZERO, because then no
                   SIGSEGV is thrown. */
-               M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_EXCEPTION);
+               M_ALD_INTERN(REG_RESULT, REG_ZERO, TRAP_CHECK_EXCEPTION);
        }
 }
 
@@ -432,7 +429,7 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
 
 void emit_trap_compiler(codegendata *cd)
 {
-       M_ALD_INTERN(REG_METHODPTR, REG_ZERO, EXCEPTION_HARDWARE_COMPILER);
+       M_ALD_INTERN(REG_METHODPTR, REG_ZERO, TRAP_COMPILER);
 }
 
 
@@ -449,11 +446,11 @@ 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);
 
        /* Destination register must not be REG_ZERO, because then no
           SIGSEGV is thrown. */
-       M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
+       M_ALD_INTERN(REG_RESULT, REG_ZERO, TRAP_PATCHER);
 
        return mcode;
 }
index 08a85f07e6e33425b3983a0792dc28df980f44e0..afe391d11b2b86b0abc946d0a0ff509ff7ff80e1 100644 (file)
 #include "threads/thread.h"
 
 #include "vm/builtin.h"
-#include "vm/exceptions.h"
 #include "vm/signallocal.h"
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/executionstate.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 #include "vmcore/system.h"
 
@@ -97,7 +97,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                type = disp;
 
-               if (type == EXCEPTION_HARDWARE_COMPILER) {
+               if (type == TRAP_COMPILER) {
                        /* The XPC is the RA minus 1, because the RA points to the
                           instruction after the call. */
 
@@ -112,14 +112,14 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                type = (int) addr;
        }
 
-       /* 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) {
                        _mc->sc_regs[REG_PV] = (uintptr_t) p;
                        _mc->sc_pc           = (uintptr_t) p;
@@ -140,7 +140,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
 
                /* fall-through */
 
-       case EXCEPTION_HARDWARE_PATCHER:
+       case TRAP_PATCHER:
                if (p == NULL)
                        break;
 
diff --git a/src/vm/jit/alpha/md-trap.h b/src/vm/jit/alpha/md-trap.h
new file mode 100644 (file)
index 0000000..c932579
--- /dev/null
@@ -0,0 +1,79 @@
+/* src/vm/jit/alpha/md-trap.h - Alpha 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 (alpha) the trap numbers are used as load
+ * displacements and thus must not be 4- or 8-byte aligned.
+ *
+ * NOTE: In trap_init() we have a check whether the offset of
+ * java_arrayheader.data[0] is greater than the largest displacement
+ * defined below.  Otherwise normal array loads/stores could trigger
+ * an exception.
+ */
+
+#define TRAP_INSTRUCTION_IS_LOAD    1
+
+enum {
+       TRAP_NullPointerException           = 0,
+       TRAP_ArithmeticException            = 1,
+       TRAP_ArrayIndexOutOfBoundsException = 2,
+       TRAP_ArrayStoreException            = 3,
+
+       /* Don't use 4 (could be a normal load offset). */
+
+       TRAP_ClassCastException             = 5,
+       TRAP_CHECK_EXCEPTION                = 6,
+       TRAP_PATCHER                        = 7,
+
+       /* Don't use 8 (could be a normal load offset). */
+
+       TRAP_COMPILER                       = 9,
+       TRAP_END
+};
+
+#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 125ff089211127a14b9eeb2db0d541ecc0e209fd..2958813c47ee7fad1d2dbb46fce1bce23dfbd051 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/alpha/md.c - machine dependent Alpha 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.
 
@@ -27,7 +25,6 @@
 
 #include "config.h"
 
-#include <assert.h>
 #include <stdint.h>
 #include <ucontext.h>
 
@@ -41,10 +38,9 @@ extern void ieee_set_fp_control(unsigned long fp_control);
 #include "vm/jit/alpha/codegen.h"
 #include "vm/jit/alpha/md.h"
 
-#include "vm/exceptions.h"
-
 #include "vm/jit/asmpart.h"
 #include "vm/jit/jit.h"
+#include "vm/jit/trap.h"
 
 
 /* global variables ***********************************************************/
@@ -213,7 +209,7 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
                *(u4*)(savedmcode) = *(u4*)(pc);
 
                /* build the machine code for the patch */
-               mcode = (0xa41f0000 | (EXCEPTION_HARDWARE_PATCHER));
+               mcode = (0xa41f0000 | (TRAP_PATCHER));
 
                /* write the new machine code */
                *(u4*)(pc) = mcode;