* 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
\
md-abi.c \
md-abi.h \
+ md-trap.h \
md.c \
md.h
/* 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.
#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 */
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);
}
}
{
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);
}
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);
}
}
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_TST(REG_RESULT, REG_RESULT);
- M_TRAPEQ(0, EXCEPTION_HARDWARE_ARRAYSTORE);
+ M_TRAPEQ(0, TRAP_ArrayStoreException);
}
}
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:
{
if (INSTRUCTION_MUST_CHECK(iptr)) {
M_TST(REG_RESULT, REG_RESULT);
- M_TRAPEQ(0, EXCEPTION_HARDWARE_EXCEPTION);
+ M_TRAPEQ(0, 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_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
+ M_TRAP(0, TRAP_PATCHER);
return mcode;
}
#include "vm/jit/asmpart.h"
#include "vm/jit/stacktrace.h"
+#include "vm/jit/trap.h"
/* md_signal_handler_sigsegv ***************************************************
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;
}
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;
}
}
--- /dev/null
+/* 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:
+ */