NEXTFRAME macro
Kiyo Inaba
inaba at src.ricoh.co.jp
Tue Mar 23 21:39:10 PST 1999
Hi,
I started to integrate m68k/linux and m68k/netbsd ports.
And I noticed (or recalled...) why I place netbsd's jit.h in separate
place. In 'kaffe/kaffevm/exception.c', structure member 'retbp' is
directly used rather than hidden by some macro. When accessing to
PC in exceptionFrame, a macro 'PCFRAME' is used.
So I propose the following patch to hide these implementation details
from exception.c. I'm not so sure this kind of proposal can be acceptable
or not (it is related not only for m68k port), but I hope it is
accepted. While I try to redefine the meaning of NEXTFRAME (originally
it has side effect to assign new value to the frame, but this macro has
never used), I also noticed that FRAMEOKAY macro is no longer needed.
Kiyo
diff -cr kaffe-snap-0317/config/i386/jit.h kaffe-snap/config/i386/jit.h
*** kaffe-snap-0317/config/i386/jit.h Tue Jan 26 17:14:03 1999
--- kaffe-snap/config/i386/jit.h Wed Mar 24 14:13:35 1999
***************
*** 24,30 ****
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! (f) = ((exceptionFrame*)(f)->retbp)
/* Extract the PC from the given frame */
#define PCFRAME(f) \
--- 24,30 ----
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((exceptionFrame*)(f)->retbp)
/* Extract the PC from the given frame */
#define PCFRAME(f) \
diff -cr kaffe-snap-0317/config/m68k/jit.h kaffe-snap/config/m68k/jit.h
*** kaffe-snap-0317/config/m68k/jit.h Mon Mar 1 03:49:07 1999
--- kaffe-snap/config/m68k/jit.h Wed Mar 24 14:14:02 1999
***************
*** 35,41 ****
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((f) = (exceptionFrame*)(f)->retfp)
/* Extract the PC from the given frame */
#define PCFRAME(f) ((f)->retpc)
--- 35,41 ----
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((exceptionFrame*)(f)->retfp)
/* Extract the PC from the given frame */
#define PCFRAME(f) ((f)->retpc)
diff -cr kaffe-snap-0317/config/m68k/netbsd1/jit-md.h kaffe-snap/config/m68k/netbsd1/jit-md.h
*** kaffe-snap-0317/config/m68k/netbsd1/jit-md.h Thu Aug 20 09:50:13 1998
--- kaffe-snap/config/m68k/netbsd1/jit-md.h Wed Mar 24 13:40:34 1999
***************
*** 38,44 ****
/* Get the first exception frame from a signal handler */
#define EXCEPTIONFRAME(f, c) \
do { \
! (f).retbp = (uintp)__builtin_frame_address(1); \
(f).retpc = (uintp)(c)->sc_pc; \
} while (0)
--- 38,44 ----
/* Get the first exception frame from a signal handler */
#define EXCEPTIONFRAME(f, c) \
do { \
! (f).retfp = (uintp)__builtin_frame_address(1); \
(f).retpc = (uintp)(c)->sc_pc; \
} while (0)
diff -cr kaffe-snap-0317/config/m68k/netbsd1/jit.h kaffe-snap/config/m68k/netbsd1/jit.h
*** kaffe-snap-0317/config/m68k/netbsd1/jit.h Thu Aug 20 09:50:14 1998
--- kaffe-snap/config/m68k/netbsd1/jit.h Wed Mar 24 14:16:33 1999
***************
*** 25,61 ****
/* Structure of exception frame on stack */
typedef struct _exceptionFrame {
! uintp retbp;
uintp retpc;
} exceptionFrame;
/* Is this frame valid (ie. is it on the current stack) ? */
#define FRAMEOKAY(f) \
! ((f) && (f)->retbp >= (uintp)TCTX(currentThread)->stackBase && \
! (f)->retbp < (uintp)TCTX(currentThread)->stackEnd)
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((f) = (exceptionFrame*)(f)->retbp)
/* Extract the PC from the given frame */
#define PCFRAME(f) ((f)->retpc)
- /* Extract the object argument from given frame */
- #define FRAMEOBJECT(f) (*(Hjava_lang_Object**)((f)->retbp + 8))
-
/* Get the first exception frame from a subroutine call */
#define FIRSTFRAME(f, o) \
((f) = *(exceptionFrame*)__builtin_frame_address(0))
/* Call the relevant exception handler (rewinding the stack as
necessary). */
#define CALL_KAFFE_EXCEPTION(frame, info, obj) \
__asm__ __volatile__( \
- "move%.l %0,%/a6\n\t" \
"move%.l %1,%/d0\n\t" \
"jmp %2@" \
! : : "g"(frame->retbp), "g"(obj), "a"(info.handler) \
: "d0", "cc", "memory")
/**/
--- 25,61 ----
/* Structure of exception frame on stack */
typedef struct _exceptionFrame {
! uintp retfp;
uintp retpc;
} exceptionFrame;
/* Is this frame valid (ie. is it on the current stack) ? */
#define FRAMEOKAY(f) \
! ((f) && (f)->retfp >= (uintp)TCTX(currentThread)->stackBase && \
! (f)->retfp < (uintp)TCTX(currentThread)->stackEnd)
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((exceptionFrame*)(f)->retfp)
/* Extract the PC from the given frame */
#define PCFRAME(f) ((f)->retpc)
/* Get the first exception frame from a subroutine call */
#define FIRSTFRAME(f, o) \
((f) = *(exceptionFrame*)__builtin_frame_address(0))
+ /* Extract the object argument from given frame */
+ #define FRAMEOBJECT(f) (*(Hjava_lang_Object**)((f)->retfp + 8))
+
/* Call the relevant exception handler (rewinding the stack as
necessary). */
#define CALL_KAFFE_EXCEPTION(frame, info, obj) \
__asm__ __volatile__( \
"move%.l %1,%/d0\n\t" \
+ "move%.l %0,%/a6\n\t" \
"jmp %2@" \
! : : "g"(frame->retfp), "g"(obj), "a"(info.handler) \
: "d0", "cc", "memory")
/**/
diff -cr kaffe-snap-0317/config/sparc/jit.h kaffe-snap/config/sparc/jit.h
*** kaffe-snap-0317/config/sparc/jit.h Wed Apr 1 04:10:53 1998
--- kaffe-snap/config/sparc/jit.h Wed Mar 24 14:14:12 1999
***************
*** 33,39 ****
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! (f) = ((exceptionFrame*)(f)->retbp)
/* Extract the PC from the given frame */
#define PCFRAME(f) \
--- 33,39 ----
/* Get the next frame in the chain */
#define NEXTFRAME(f) \
! ((exceptionFrame*)(f)->retbp)
/* Extract the PC from the given frame */
#define PCFRAME(f) \
diff -cr kaffe-snap-0317/kaffe/kaffevm/exception.c kaffe-snap/kaffe/kaffevm/exception.c
*** kaffe-snap-0317/kaffe/kaffevm/exception.c Sun Feb 28 18:10:57 1999
--- kaffe-snap/kaffe/kaffevm/exception.c Wed Mar 24 14:16:11 1999
***************
*** 136,144 ****
#if defined(TRANSLATOR)
exceptionFrame* nfm;
! nfm = (exceptionFrame*)(((exceptionFrame*)fm)->retbp);
/* Note: this should obsolete the FRAMEOKAY macro */
! if (nfm && jthread_on_current_stack((void *)nfm->retbp)) {
return (nfm);
}
else {
--- 136,144 ----
#if defined(TRANSLATOR)
exceptionFrame* nfm;
! nfm = (exceptionFrame*)NEXTFRAME(fm);
/* Note: this should obsolete the FRAMEOKAY macro */
! if (nfm && jthread_on_current_stack((void *)NEXTFRAME(nfm)) {
return (nfm);
}
else {
More information about the kaffe
mailing list