Changes: Edwin Steiner
- $Id: exceptions.h 5935 2006-11-08 20:27:37Z twisti $
+ $Id: exceptions.h 6123 2006-12-05 21:10:54Z twisti $
*/
#include "vm/method.h"
+/* hardware-exception defines **************************************************
+
+ These defines define the load-offset which indicates the given
+ exception.
+
+ ATTENTION: These offsets need NOT to be aligned to 4 or 8-byte
+ boundaries, since normal loads could have such offsets with a base
+ of NULL which should result in a NullPointerException.
+
+*******************************************************************************/
+
+#define EXCEPTION_LOAD_DISP_NULLPOINTER 0
+#define EXCEPTION_LOAD_DISP_ARITHMETIC 1
+#define EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS 2
+#define EXCEPTION_LOAD_DISP_CLASSCAST 3
+
+#define EXCEPTION_LOAD_DISP_PATCHER 5
+
+
+/* exception pointer **********************************************************/
+
#if defined(ENABLE_THREADS)
#define exceptionptr &(THREADOBJECT->_exceptionptr)
#else
Changes:
- $Id: md-os.c 5074 2006-07-04 16:05:35Z twisti $
+ $Id: md-os.c 6123 2006-12-05 21:10:54Z twisti $
*/
ptrint *gregs;
u4 instr;
s4 reg;
+ s4 disp;
ptrint addr;
u1 *pv;
u1 *sp;
u1 *ra;
u1 *xpc;
+ stackframeinfo sfi;
+ java_objectheader *o;
_uc = (ucontext_t *) _p;
_mc = _uc->uc_mcontext;
gregs = &_ss->r0;
instr = *((u4 *) _ss->srr0);
- reg = (instr >> 16) & 31;
- addr = gregs[reg];
+ reg = (instr >> 16) & 31;
+ disp = (instr & 0xffff);
+ addr = gregs[reg];
+
+ pv = (u1 *) _ss->r13;
+ sp = (u1 *) _ss->r1;
+ ra = (u1 *) _ss->lr; /* this is correct for leafs */
+ xpc = (u1 *) _ss->srr0;
+
+ /* create stackframeinfo */
+
+ stacktrace_create_extern_stackframeinfo(&sfi, pv, sp, ra, xpc);
+
+ if (reg == REG_ZERO) {
+ switch (disp) {
+ case EXCEPTION_LOAD_DISP_ARITHMETIC:
+ vm_abort("ArithmeticException");
+ break;
+ case EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS:
+ log_println("ArrayIndexOutOfBoundsException");
+ o = new_arrayindexoutofboundsexception(0);
+ break;
+ case EXCEPTION_LOAD_DISP_CLASSCAST:
+ vm_abort("ClassCastException");
+ break;
+ default:
+ vm_abort("unknown exception %d", disp);
+ }
+ }
+ else if (addr == 0) {
+ o = exceptions_new_nullpointerexception();
+ }
+ else {
+ codegen_get_pv_from_pc(xpc);
- if (addr == 0) {
- pv = (u1 *) _ss->r13;
- sp = (u1 *) _ss->r1;
- ra = (u1 *) _ss->lr; /* this is correct for leafs */
- xpc = (u1 *) _ss->srr0;
+ /* this should not happen */
- _ss->r11 =
- (ptrint) stacktrace_hardware_nullpointerexception(pv, sp, ra, xpc);
+ assert(0);
+ }
- _ss->r12 = (ptrint) xpc;
- _ss->srr0 = (ptrint) asm_handle_exception;
+ /* remove stackframeinfo */
- } else {
- throw_cacao_exception_exit(string_java_lang_InternalError,
- "Segmentation fault: 0x%08lx at 0x%08lx",
- addr, _ss->srr0);
- }
+ stacktrace_remove_stackframeinfo(&sfi);
+
+ _ss->r11 = (ptrint) o;
+ _ss->r12 = (ptrint) xpc;
+ _ss->srr0 = (ptrint) asm_handle_exception;
}
#include "mm/memory.h"
#include "vm/builtin.h"
+#include "vm/exceptions.h"
#include "vm/options.h"
#include "vm/jit/asmpart.h"
#include "vm/jit/dseg.h"
void emit_arrayindexoutofbounds_check(codegendata *cd, s4 s1, s4 s2)
{
+#if 0
if (checkbounds) {
M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
M_CMPU(s2, REG_ITMP3);
M_BGE(0);
codegen_add_arrayindexoutofboundsexception_ref(cd, s2);
}
+#else
+ M_ILD(REG_ITMP3, s1, OFFSET(java_arrayheader, size));
+ M_CMPU(s2, REG_ITMP3);
+ M_BLT(1);
+ M_ALD_INTERN(s2, REG_ZERO, EXCEPTION_LOAD_DISP_ARRAYINDEXOUTOFBOUNDS);
+#endif
}
Authors: Christian Thalinger
- $Id: signal.c 5979 2006-11-14 21:56:17Z twisti $
+ $Id: signal.c 6123 2006-12-05 21:10:54Z twisti $
*/
# endif
/* catch NullPointerException/StackOverFlowException */
- if (!checknull) {
- act.sa_sigaction = md_signal_handler_sigsegv;
- act.sa_flags = SA_NODEFER | SA_SIGINFO;
+ act.sa_sigaction = md_signal_handler_sigsegv;
+ act.sa_flags = SA_NODEFER | SA_SIGINFO;
#if defined(SIGSEGV)
- sigaction(SIGSEGV, &act, NULL);
+ sigaction(SIGSEGV, &act, NULL);
#endif
#if defined(SIGBUS)
- sigaction(SIGBUS, &act, NULL);
+ sigaction(SIGBUS, &act, NULL);
#endif
- }
/* catch ArithmeticException */