Index: kaffe/kaffevm/jni.c =================================================================== RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/jni.c,v retrieving revision 1.109 diff -u -r1.109 jni.c --- kaffe/kaffevm/jni.c 5 Apr 2004 17:43:38 -0000 1.109 +++ kaffe/kaffevm/jni.c 6 Apr 2004 15:07:42 -0000 @@ -103,7 +103,9 @@ */ #if defined(TRANSLATOR) #define KAFFE_JNI_SETEXCEPTFP(ebufp) { \ - vmExcept_setJNIFrame(ebufp, __builtin_frame_address(0));\ + exceptionFrame currentFrame; \ + FIRSTFRAME(currentFrame, 0); \ + vmExcept_setJNIFrame(ebufp,FPFRAME(¤tFrame)); \ } #else /* Index: config/arm/arm.c =================================================================== RCS file: config/arm/arm.c diff -N config/arm/arm.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ config/arm/arm.c 6 Apr 2004 15:07:42 -0000 @@ -0,0 +1,135 @@ + +#include "gtypes.h" +#include "debug.h" +#include "jit-md.h" + +#define IS_STMDB(x) ( ((x) & 0xffff0000) == 0xe92d0000 ) +#define IS_STR(x) (((x) & 0xffff0fff) == 0xe52d0004) + +exceptionFrame *__arm_nextFrame (exceptionFrame *f) +{ + uintp pc; + uintp sp; + uintp fp; + + if (f->retsp == 0) { + asm volatile ("str pc,%0" : "=m"(pc)); + asm volatile ("str sp,%0" : "=m"(sp)); + asm volatile ("str fp,%0" : "=m"(fp)); + + DBG(STACKTRACE, dprintf ("firstFrame: pc 0x%x, sp 0x%x, fp 0x%x\n", pc, sp, fp); ); + } else { + + sp = f->retsp; + fp = f->retfp; + pc = f->retpc; + + DBG(STACKTRACE, dprintf ("nextFrame: pc 0x%x, sp 0x%x, fp 0x%x\n", pc, sp, fp); ); + + if (pc == 0) ABORT (); + } + + /* + search backwards until we find an + stmb sp!, {,lr} + */ + for (;;pc-=4) { + /* DBG(STACKTRACE, dprintf ("found 0x%x at %p\n", *pc, pc); ); */ + uintp insn = * (uintp *) pc; + + if (IS_STMDB(insn)) { + /* stmdb !sp, {...} */ + + if ( (insn&(1<<15)) != 0 ) { + /* if pc is pushed, assume that fp has to be used to restore registers */ + int i; + + DBG(STACKTRACE, dprintf ("using fp 0x%x to load registers\n", fp); ); + + for (i=15; i>=0; i--) { + if (insn & (1<retfp = * (uintp *) fp; + } else if (i == 12) { + sp = * (uintp *) fp; + } else if (i == 14) { + f->retpc = * (uintp *) fp; + } + + fp -= 4; + } + } + + break; + } else { + int i; + + stmdb_insn: + DBG(STACKTRACE, dprintf("using sp 0x%x to load registers\n", sp); ); + + for (i=0; i<16; i++) { + if ( insn & (1<retfp = * (uintp *) sp; + } else if (i == 14) { + f->retpc = * (uintp *) sp; + } + sp += 4; + } + } + + pc -= 4; + insn = *(uintp *)pc; + + if (IS_STMDB(insn)) { + goto stmdb_insn; + } + + break; + } + } + else if (IS_STR(insn)) { + str_insn: + /* str something, [sp, #4]! => restore register and set sp accordingly */ + insn = (insn >> 12) & 0xf; + + if (insn == 11) { + f->retfp = * (uintp *) sp; + } else if (insn == 14) { + f->retpc = * (uintp *) sp; + } + + sp += 4; + + pc -= 4; + insn = * (uintp *)pc; + + if (IS_STR(insn)) { + goto str_insn; + } + + break; + } + else if ((insn & 0xfffff000) == 0xe24dd000) { + /* sub sp, sp, framesize => extract framesize */ + int immediate = insn & 0xff; + int shift = (insn & 0xf00) >> 7; + + sp += (immediate >> shift) | (immediate << (32 - shift)); + } + } + + f->retsp = sp; + + DBG(STACKTRACE, dprintf("found pc 0x%x, sp 0x%x, fp 0x%x\n", f->retpc, f->retsp, f->retfp); ); + + return f; +} Index: config/arm/common.h =================================================================== RCS file: /cvs/kaffe/kaffe/config/arm/common.h,v retrieving revision 1.10 diff -u -r1.10 common.h --- config/arm/common.h 11 Mar 2004 16:22:51 -0000 1.10 +++ config/arm/common.h 6 Apr 2004 15:07:42 -0000 @@ -17,7 +17,7 @@ #ifndef __arm_common_h #define __arm_common_h -#include "atomicity.h" +// #include "atomicity.h" /* The arm never aligns to more than a 4 byte boundary. */ #define ALIGNMENT_OF_SIZE(S) ((S) < 4 ? (S) : 4) @@ -28,7 +28,10 @@ * We return '1' if the exchange is successful, otherwise 0. */ +#define ATOMIC_EXCHANGE(A,N) \ + asm volatile("swp %0, %0, [%2]" : "=r" (N) : "0" (N), "r" (A) : "cc", "memory" ); -#define COMPARE_AND_EXCHANGE(A, O, N) (compare_and_swap((long int*) A, (long int) O, (long int) N)) + +// #define COMPARE_AND_EXCHANGE(A, O, N) (compare_and_swap((long int*) A, (long int) O, (long int) N)) #endif Index: config/arm/jit.h =================================================================== RCS file: /cvs/kaffe/kaffe/config/arm/jit.h,v retrieving revision 1.14 diff -u -r1.14 jit.h --- config/arm/jit.h 9 Mar 2004 17:35:47 -0000 1.14 +++ config/arm/jit.h 6 Apr 2004 15:07:42 -0000 @@ -48,7 +48,7 @@ #define PCFRAME(f) \ ((f)->retpc - 4) #define FPFRAME(f) \ - ((f)->retfp) + ((f)->retsp) /* Get the first exception frame from a subroutine call */ #define FIRSTFRAME(f, o) \ @@ -56,22 +56,11 @@ (f) = *(exceptionFrame*)(v - sizeof(exceptionFrame)); }) /* Extract the object argument from given frame */ -#define FRAMEOBJECT(obj, f, meth) do { \ - const char *str; \ - int maxLocal, maxStack, maxArgs, maxTemp; \ - /* Set up the necessary state for the SLOT2 macros to work \ - * in local variables to not get the translator lock. */ \ - maxLocal = meth->localsz; \ - maxStack = meth->stacksz; \ - str = METHOD_SIGD(meth); \ - maxArgs = sizeofSig(&str, false); \ - maxTemp = MAXTEMPS - 1; \ - /* NB: we assume that the JIT will have \ - * spilled the 'this' object in the \ - * stack location for slot zero. \ +#define FRAMEOBJECT(obj, f, meth) \ + /* \ + * f is the stack pointer of this frame. \ */ \ - obj = ((Hjava_lang_Object**)(f))[SLOT2ARGOFFSET(0)/SLOTSIZE]; \ -} while (0) + obj = * ((Hjava_lang_Object**)(f)); /**/ Index: config/arm/linux/jit-md.h =================================================================== RCS file: /cvs/kaffe/kaffe/config/arm/linux/jit-md.h,v retrieving revision 1.7 diff -u -r1.7 jit-md.h --- config/arm/linux/jit-md.h 25 Oct 2003 12:52:42 -0000 1.7 +++ config/arm/linux/jit-md.h 6 Apr 2004 15:07:42 -0000 @@ -17,8 +17,19 @@ /**/ #include "arm/jit.h" +#if __GNUC__ == 3 + +extern exceptionFrame *__arm_nextFrame (exceptionFrame *); + #undef FIRSTFRAME -#define FIRSTFRAME(f, o) (f) = *(exceptionFrame *)((uintp)__builtin_frame_address(0) - sizeof(exceptionFrame)) +#define FIRSTFRAME(f, o) \ + (f).retsp = 0; \ + __arm_nextFrame (&(f)); + +#undef NEXTFRAME +#define NEXTFRAME(f) __arm_nextFrame ((f)) + +#endif /* __GNUC__ == 3 */ #define EXCEPTIONPROTO SIGNAL_ARGS(sig, ctx) @@ -26,12 +37,14 @@ #if defined(HAVE_REG_SIGCONTEXT) #define EXCEPTIONFRAME(f, c) \ (f).retfp = (c).reg.ARM_fp; \ + (f).retsp = (c).reg.ARM_sp; \ (f).retpc = (c).reg.ARM_pc; #else /* This one is for Debian */ #define EXCEPTIONFRAME(f, c) \ (f).retfp = (c).arm_fp; \ + (f).retsp = (c).arm_sp; \ (f).retpc = (c).arm_pc; #endif Index: config/arm/linux/md.c =================================================================== RCS file: /cvs/kaffe/kaffe/config/arm/linux/md.c,v retrieving revision 1.5 diff -u -r1.5 md.c --- config/arm/linux/md.c 11 Mar 2004 11:38:10 -0000 1.5 +++ config/arm/linux/md.c 6 Apr 2004 15:07:42 -0000 @@ -37,3 +37,7 @@ : "r" ((long)start), "r" ((long)end) : "r0","r1","r2"); } + +#if defined(TRANSLATOR) && (__GNUC__ == 3) +#include "arm/arm.c" +#endif