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

--HG--
branch : twisti

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

index e28ac2e1a0edb39e0c7e22d1635b3a253e12adca..38535c3a897ada405cecc2aae28f20f2a25f013a 100644 (file)
@@ -57,6 +57,7 @@ libarch_la_SOURCES = \
        \
        md-abi.c \
        md-abi.h \
+       md-trap.h \
        md.c \
        md.h
 
index 970101b85fe528457b874f59904f542dd845fe67..d13339a8a8dc63c5d024de7e0d27b71d2f0ffc24 100644 (file)
@@ -259,7 +259,7 @@ bool codegen_emit(jitdata *jd)
                        M_BNEZ(REG_OUT0, 3);
                        disp = dseg_add_functionptr(cd, LOCK_monitor_enter);
                        M_ALD(REG_ITMP3, REG_PV, disp);                   /* branch delay */
-                       M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+                       M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_NullPointerException);
                }
 
                M_JMP(REG_RA_CALLER, REG_ITMP3, REG_ZERO);
index 28a2240560fb04875536bfc5a93abd7a94c08839..def530822aeb785a3f430854e37586925df4014a 100644 (file)
@@ -461,7 +461,7 @@ void emit_arithmetic_check(codegendata *cd, instruction *iptr, s4 reg)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_BNEZ(reg, 3);
                M_NOP;
-               M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_ARITHMETIC);
+               M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_ArithmeticException);
        }
 }
 
@@ -479,7 +479,7 @@ void emit_arrayindexoutofbounds_check(codegendata *cd, instruction *iptr, s4 s1,
                M_CMP(s2, REG_ITMP3);
                M_XBULT(3);
                M_NOP;
-               M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_HARDWARE_ARRAYINDEXOUTOFBOUNDS);
+               M_ALD_INTERN(s2, REG_ZERO, TRAP_ArrayIndexOutOfBoundsException);
        }
 }
 
@@ -495,7 +495,7 @@ void emit_arraystore_check(codegendata *cd, instruction *iptr)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_BNEZ(REG_RESULT_CALLER, 3);
                M_NOP;
-               M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, EXCEPTION_HARDWARE_ARRAYSTORE);
+               M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, TRAP_ArrayStoreException);
        }
 }
 
@@ -529,7 +529,7 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
                }
 
                M_NOP;
-               M_ALD_INTERN(s1, REG_ZERO, EXCEPTION_HARDWARE_CLASSCAST);
+               M_ALD_INTERN(s1, REG_ZERO, TRAP_ClassCastException);
        }
 }
 
@@ -545,7 +545,7 @@ void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_BNEZ(reg, 3);
                M_NOP;
-               M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_NULLPOINTER);
+               M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_NullPointerException);
        }
 }
 
@@ -561,7 +561,7 @@ void emit_exception_check(codegendata *cd, instruction *iptr)
        if (INSTRUCTION_MUST_CHECK(iptr)) {
                M_BNEZ(REG_RESULT_CALLER, 3);
                M_NOP;
-               M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, EXCEPTION_HARDWARE_EXCEPTION);
+               M_ALD_INTERN(REG_RESULT_CALLER, REG_ZERO, TRAP_CHECK_EXCEPTION);
        }
 }
 
@@ -579,9 +579,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_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
+       M_ALD_INTERN(REG_ZERO, REG_ZERO, TRAP_PATCHER);
 
        return mcode;
 }
index 75488dabf90d917e2e961e2b8f3fcce3bc823bcc..1144594771951d8f44736215ff77135dd490bdd8 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/sparc64/linux/md-os.c - machine dependent SPARC Linux functions
 
-   Copyright (C) 1996-2005, 2006 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, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
 
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
+
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 
 typedef struct sigcontext sigcontext;
@@ -121,7 +121,7 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , void *_p)
 
        /* flush register windows? */
        
-       val   = md_get_reg_from_context(ctx, d);
+       val  = md_get_reg_from_context(ctx, d);
 
        /* check for special-load */
 
@@ -138,16 +138,16 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *info , 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 */
 
-       ctx->sigc_regs.u_regs[REG_ITMP2_XPTR] = (intptr_t) p;
-       ctx->sigc_regs.u_regs[REG_ITMP3_XPC]  = (intptr_t) xpc;
-       ctx->sigc_regs.tpc                    = (intptr_t) asm_handle_exception;
-       ctx->sigc_regs.tnpc                   = (intptr_t) asm_handle_exception + 4;
+       ctx->sigc_regs.u_regs[REG_ITMP2_XPTR] = (uintptr_t) p;
+       ctx->sigc_regs.u_regs[REG_ITMP3_XPC]  = (uintptr_t) xpc;
+       ctx->sigc_regs.tpc                    = (uintptr_t) asm_handle_exception;
+       ctx->sigc_regs.tnpc                   = (uintptr_t) asm_handle_exception + 4;
 }
 
 
diff --git a/src/vm/jit/sparc64/md-trap.h b/src/vm/jit/sparc64/md-trap.h
new file mode 100644 (file)
index 0000000..e069031
--- /dev/null
@@ -0,0 +1,79 @@
+/* src/vm/jit/sparc64/md-trap.h - SPARC64 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 (sparc64) 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 4d1f71d6c226b79c5dbf797785e476f86b4e66b7..81f191896fcc537fab491f57d8dae8609c441f93 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/sparc64/solaris/md-os.c - machine dependent SPARC Solaris 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.
 
 #include "vm/exceptions.h"
 #include "vm/signallocal.h"
 #include "vm/stringlocal.h"
+
 #include "vm/jit/asmpart.h"
 #include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
 
 
 ptrint md_get_reg_from_context(mcontext_t *_mc, u4 rindex)
@@ -134,20 +134,20 @@ void md_signal_handler_sigsegv(int sig, siginfo_t *siginfo, void *_p)
                /* This is a normal NPE: addr must be NULL and the NPE-type
                   define is 0. */
 
-               addr  = md_get_reg_from_context(_mc, s1);
+               addr = md_get_reg_from_context(_mc, s1);
                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 */
+       /* Set registers. */
 
-       _mc->gregs[REG_G2]  = (intptr_t) p;                     /* REG_ITMP2_XPTR */
-       _mc->gregs[REG_G3]  = (intptr_t) xpc;                    /* REG_ITMP3_XPC */
-       _mc->gregs[REG_PC]  = (intptr_t) asm_handle_exception;
-       _mc->gregs[REG_nPC] = (intptr_t) asm_handle_exception + 4;      
+       _mc->gregs[REG_G2]  = (uintptr_t) p;                    /* REG_ITMP2_XPTR */
+       _mc->gregs[REG_G3]  = (uintptr_t) xpc;                   /* REG_ITMP3_XPC */
+       _mc->gregs[REG_PC]  = (uintptr_t) asm_handle_exception;
+       _mc->gregs[REG_nPC] = (uintptr_t) asm_handle_exception + 4;     
 }