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
\
md-abi.c \
md-abi.h \
+ md-trap.h \
md.c \
md.h
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);
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);
}
}
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);
}
}
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);
}
}
}
M_NOP;
- M_ALD_INTERN(s1, REG_ZERO, EXCEPTION_HARDWARE_CLASSCAST);
+ M_ALD_INTERN(s1, REG_ZERO, TRAP_ClassCastException);
}
}
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);
}
}
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);
}
}
/* 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;
}
/* 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;
/* flush register windows? */
- val = md_get_reg_from_context(ctx, d);
+ val = md_get_reg_from_context(ctx, d);
/* check for special-load */
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;
}
--- /dev/null
+/* 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:
+ */
/* 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)
/* 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;
}