trampoline code for m68k/netbsd1
Kiyo Inaba
inaba at src.ricoh.co.jp
Fri Jul 31 11:00:29 PDT 1998
I'm now trying to make 'trampolines.c' for m68k. Attached file is
my current version.
But, still I can not make any program to be executed with it. The
problem what I have right now is very mysterious.
When I use this version with GDB 4.16, until the program goes
into one (compiled) method the back trace is displayed properly.
But when it goes into a method (which is java/util/Hashtable
calculateBucket method), the back trace is disappered. The very
begining of this (compiled) method is the usual 'link'
instruction, and for me there are no funny thing happens here.
Since I will take short summer vacation (part 1), I decided
to post this halfway result. If there are some m68k guru
who can help, I am so happy.
I am now using m68k-sun-netbsd1.3.1, but the generic idea can
be applied to some other platforms.
Kiyo
diff -cr config/m68k/netbsd1/jit-md.h /tmp/config/m68k/netbsd1/jit-md.h
*** config/m68k/netbsd1/jit-md.h Wed Apr 1 04:10:53 1998
--- /tmp/config/m68k/netbsd1/jit-md.h Thu Jul 30 23:38:06 1998
***************
*** 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)
--- 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)
diff -cr config/m68k/netbsd1/jit.h /tmp/config/m68k/netbsd1/jit.h
*** config/m68k/netbsd1/jit.h Wed Apr 1 04:10:53 1998
--- /tmp/config/m68k/netbsd1/jit.h Fri Jul 31 00:12:30 1998
***************
*** 62,79 ****
/* 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) \
! ((f) = (exceptionFrame*)(f)->retfp)
/* Extract the PC from the given frame */
#define PCFRAME(f) ((f)->retpc)
--- 62,79 ----
/* 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)
***************
*** 83,89 ****
((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). */
--- 83,89 ----
((f) = *(exceptionFrame*)__builtin_frame_address(0))
/* Extract the object argument from given frame */
! #define FRAMEOBJECT(f) (*(Hjava_lang_Object**)((f)->retbp + 8))
/* Call the relevant exception handler (rewinding the stack as
necessary). */
***************
*** 92,101 ****
"move%.l %0,%/a6\n\t" \
"move%.l %1,%/d0\n\t" \
"jmp %2@" \
! : : "g"(frame->retfp), "g"(obj), "a"(info.handler) \
: "d0", "cc", "memory")
/**/
/* Register management information. */
/**/
--- 92,124 ----
"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")
+ /**/
+ /* Method dispatch. */
+ /**/
+
+ #define HAVE_TRAMPOLINE
+
+ typedef struct _methodTrampoline {
+ unsigned short call;
+ int fixup;
+ struct _methods* meth;
+ } methodTrampoline;
+ extern void m68k_do_fixup_trampoline(void);
+
+ #define FILL_IN_TRAMPOLINE(t,m) \
+ do { \
+ (t)->call = 0x4eb9; /* jsr abs.l */ \
+ (t)->fixup = (int)m68k_do_fixup_trampoline; \
+ (t)->meth = (m); \
+ } while (0)
+
+ #define FIXUP_TRAMPOLINE_DECL Method** _pmeth
+ #define FIXUP_TRAMPOLINE_INIT (meth = *_pmeth)
+
/**/
/* Register management information. */
/**/
***************
*** 149,154 ****
--- 172,179 ----
/* Opcode generation. */
/**/
+ #define EXTRA_LABELS(P,D,L)
+
/* Define if generated code uses two operands rather than one */
#define TWO_OPERAND
***************
*** 187,192 ****
--- 212,219 ----
privledged instruction, so we have to get operating system help
for this. Naturally, there is no standard there. */
+ #define FLUSH_DCACHE(beg, end) __clear_cache((beg), (end))
+ #if 0
#define FLUSH_DCACHE(beg, end) \
__asm__ __volatile__( \
"movem%.l %/d0-%/d7/%/a0-%/a5,%-\n\t" \
***************
*** 198,203 ****
--- 225,231 ----
"movem%.l %+,%/d0-%/d7/%/a0-%/a5" \
: \
: "g" (beg), "g" (end) )
+ #endif
#define LABEL_FRAMESIZE(L,P) \
{ \
diff -cr config/m68k/trampolines.c /tmp/config/m68k/trampolines.c
*** config/m68k/trampolines.c Fri Jul 31 01:44:18 1998
--- /tmp/config/m68k/trampolines.c Thu Jul 30 22:50:23 1998
***************
*** 0 ****
--- 1,50 ----
+ /*
+ * m68k/trampolines.c
+ * m68k trampolines codes for for various occasions.
+ *
+ * Copyright (c) 1996, 1997, 1998
+ * Transvirtual Technologies, Inc. All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ *
+ * Written by Kiyo Inaba (inaba at src.ricoh.co.jp) based on i386/trampolines.c
+ */
+
+ #if defined(TRAMPOLINE_FUNCTION)
+ /*
+ * If we have an explit function defined then use that.
+ */
+ TRAMPOLINE_FUNCTION()
+
+ #else
+ /*
+ * Otherwise we'll try to construct one.
+ */
+ #if !defined(START_ASM_FUNC)
+ #define START_ASM_FUNC() ".text\n\t.even\n\t.globl "
+ #endif
+ #if !defined(END_ASM_FUNC)
+ #define END_ASM_FUNC() ""
+ #endif
+ #if defined(HAVE_UNDERSCORED_C_NAMES)
+ #define C_FUNC_NAME(FUNC) "_" #FUNC
+ #else
+ #define C_FUNC_NAME(FUNC) #FUNC
+ #endif
+
+ #if defined(NO_SHARED_VMLIBRARY)
+
+ asm(
+ START_ASM_FUNC() C_FUNC_NAME(m68k_do_fixup_trampoline) "\n"
+ C_FUNC_NAME(m68k_do_fixup_trampoline) ": \n
+ jbsr " C_FUNC_NAME(soft_fixup_trampoline) " \n
+ addqw #4,sp \n
+ movel d0,a0 \n
+ jmp a0@"
+ END_ASM_FUNC()
+ );
+
+ #else
+ #endif
+
+ #endif
More information about the kaffe
mailing list