m68k/{linux,netbsd} integration

Kiyo Inaba inaba at src.ricoh.co.jp
Thu Mar 25 00:10:39 PST 1999


Hi,

Please apply attached patch to the repository. I am now trying to
integrate m68k/linux and m68k/netbsd port (for jit part mainly) and
at least it works fine for netbsd. I think linux part may need
another several days.

When apply this patch, also please remove config/m68k/netbsd1/jit.h
because it is no longer needed.

Kiyo
P.S. Are there anyone who is maintaining alpha jit port???

diff -cr kaffe-0325/ChangeLog kaffe-snap-0325/ChangeLog
*** kaffe-0325/ChangeLog	Thu Mar 25 09:27:41 1999
--- kaffe-snap-0325/ChangeLog	Thu Mar 25 16:56:07 1999
***************
*** 1,3 ****
--- 1,20 ----
+ Wed Mar 25 16:40:00 1999  Kiyo Inaba <inaba at src.ricoh.co.jp>
+ 
+ 	* config/m68k/linux/md.h: define SP_OFFSET.
+ 	* config/alpha/jit.h, config/m68k/jit.h, config/m68k/openbsd2/jit.h
+ 	remove obsolete macros as THREAD_CTX, RETURN_INT, etc.
+ 	* config/m68k/netbsd1/jit-md.h: Jit support is now
+ 	integrated with linux port.
+ 	* config/m68k/linux/jit-md.h: new file. Jit support for
+ 	linux (which has not yet been finished).
+ 	* config/m68k/netbsd1/config.frag: eliminate the use of -O2
+ 	flag to evading jit bug.
+ 	* config/m68k/linux/config.frag: cross compiling suport.
+ 	* config/m68k/trampolines.c: change assembler syntax compatible
+ 	with linux's as. The 'm68k_do_fixup_trampoline' function is
+ 	now used with shared_vmlibrary, but I've not yet tested if
+ 	it works or not.
+ 
  Wed Mar 24 16:15:03 1999  Alan L. Batongbacal <alanlb at access.rrinc.com>
  
  	* FAQ/FAQ.BeOS: updated list of known problems
diff -cr kaffe-0325/config/alpha/jit.h kaffe-snap-0325/config/alpha/jit.h
*** kaffe-0325/config/alpha/jit.h	Wed Apr  1 04:10:52 1998
--- kaffe-snap-0325/config/alpha/jit.h	Thu Mar 25 12:00:21 1999
***************
*** 30,37 ****
  
  /* Is this frame valid (ie. is it on the current stack) ? */
  #define	FRAMEOKAY(f)							\
! 	((f) && (f)->retfp >= (uintp)THREAD_CTX()->stackBase &&	\
! 	 (f)->retfp < (uintp)THREAD_CTX()->stackEnd)
  
  /* Get the next frame in the chain */
  #define	NEXTFRAME(f)							\
--- 30,37 ----
  
  /* 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)							\
***************
*** 44,50 ****
  /* Get the first exception frame from a subroutine call */
  #define	FIRSTFRAME(f, o)						\
  	do {								\
! 		exceptionFrame *_cur = THREAD_CTX()->exceptPtr;		\
  		if (_cur) {						\
  			(f) = *_cur;					\
  		}							\
--- 44,50 ----
  /* Get the first exception frame from a subroutine call */
  #define	FIRSTFRAME(f, o)						\
  	do {								\
! 		exceptionFrame *_cur = TCTX(currentThread)->exceptPtr;	\
  		if (_cur) {						\
  			(f) = *_cur;					\
  		}							\
***************
*** 197,212 ****
  
  /* Number of registers in the register set */
  #define	NR_REGISTERS	64
- 
- /* Define which registers are used for which return values as seen
-  * by the the callee */
- #define	RETURN_INT		0	/* v0 */
- #define	RETURN_REF		0	/* v0 */
- #define	RETURN_LONG_LOW		0	/* v0 */
- #define	RETURN_LONG_HIGH	0	/* Not used in this configuration */
- #define	RETURN_FLOAT		32	/* f0 */
- #define	RETURN_DOUBLE_LOW	32	/* f0 */
- #define	RETURN_DOUBLE_HIGH	32	/* Not used in this configuration */
  
  /**/
  /* Opcode generation. */
--- 197,202 ----
diff -cr kaffe-0325/config/m68k/jit.h kaffe-snap-0325/config/m68k/jit.h
*** kaffe-0325/config/m68k/jit.h	Thu Mar 25 02:52:54 1999
--- kaffe-snap-0325/config/m68k/jit.h	Thu Mar 25 12:15:41 1999
***************
*** 30,37 ****
  
  /* Is this frame valid (ie. is it on the current stack) ? */
  #define	FRAMEOKAY(f)							\
! 	((f) && (f)->retfp >= (uintp)THREAD_CTX()->stackBase &&		\
! 	 (f)->retfp < (uintp)THREAD_CTX()->stackEnd)
  
  /* Get the next frame in the chain */
  #define	NEXTFRAME(f)							\
--- 30,37 ----
  
  /* 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)							\
***************
*** 51,63 ****
     necessary). */
  #define CALL_KAFFE_EXCEPTION(frame, info, obj)				\
  	__asm__ __volatile__(						\
- 		"move%.l %0,%/fp\n\t"					\
  		"move%.l %1,%/d0\n\t"					\
  		"jmp (%2)"						\
  		: : "g"(frame->retfp), "g"(obj), "a"(info.handler)	\
  		: "d0", "cc", "memory")
  
  
  /**/
  /* Register management information. */
  /**/
--- 51,86 ----
     necessary). */
  #define CALL_KAFFE_EXCEPTION(frame, info, obj)				\
  	__asm__ __volatile__(						\
  		"move%.l %1,%/d0\n\t"					\
+ 		"move%.l %0,%/fp\n\t"					\
  		"jmp (%2)"						\
  		: : "g"(frame->retfp), "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. */
  /**/
***************
*** 97,115 ****
  /* Number of registers in the register set */
  #define	NR_REGISTERS	24
  
- /* Define which registers are used for which return values as seen
-  * by the the callee */
- #define	RETURN_INT		0	/* d0 */
- #define	RETURN_REF		M68K_RETURN_REF
- #define	RETURN_LONG_LOW		1	/* d1 */
- #define	RETURN_LONG_HIGH	0	/* d0 */
- #define	RETURN_FLOAT		32	/* f0 */
- #define	RETURN_DOUBLE_LOW	32	/* f0 */
- #define	RETURN_DOUBLE_HIGH	32	/* Not used in this configuration */
- 
  /**/
  /* Opcode generation. */
  /**/
  
  /* Define if generated code uses two operands rather than one */
  #define	TWO_OPERAND
--- 120,136 ----
  /* Number of registers in the register set */
  #define	NR_REGISTERS	24
  
  /**/
  /* Opcode generation. */
  /**/
+ #define LABEL_FRAMESIZE(L,P) \
+ 	{ \
+ 		int framesize = SLOTSIZE * (maxLocal + maxStack + \
+ 			maxTemp - maxArgs); \
+ 			*(P) = framesize; \
+ 	}
+ 
+ #define EXTRA_LABELS(P,D,L)
  
  /* Define if generated code uses two operands rather than one */
  #define	TWO_OPERAND
***************
*** 136,142 ****
   */
  
  /* Generate slot offset for an argument (relative to fp) */
! #define SLOT2ARGOFFSET(_n)    (8 + SLOTSIZE*((_n) + isStatic))
  
  /* Generate slot offset for a local (non-argument) (relative to fp) */
  #define SLOT2LOCALOFFSET(_n)  (-SLOTSIZE * (maxTemp+maxLocal+maxStack - (_n)))
--- 157,163 ----
   */
  
  /* Generate slot offset for an argument (relative to fp) */
! #define SLOT2ARGOFFSET(_n)    (8 + SLOTSIZE * (_n))
  
  /* Generate slot offset for a local (non-argument) (relative to fp) */
  #define SLOT2LOCALOFFSET(_n)  (-SLOTSIZE * (maxTemp+maxLocal+maxStack - (_n)))
diff -cr kaffe-0325/config/m68k/linux/config.frag kaffe-snap-0325/config/m68k/linux/config.frag
*** kaffe-0325/config/m68k/linux/config.frag	Fri Jan  8 06:02:54 1999
--- kaffe-snap-0325/config/m68k/linux/config.frag	Thu Mar 25 09:48:47 1999
***************
*** 4,6 ****
--- 4,17 ----
  host_cpu=m68k
  host_os=linux
  CFLAGS="-g -O -fno-omit-frame-pointer"
+ if [ "$cross_compiling" = yes ]; then
+ # if we use cross environment, following values may not be detected.
+   ac_cv_alignmentof_voidp=${ac_cv_alignmentof_voidp='2'}
+   ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}
+   ac_cv_sizeof___int64=${ac_cv_sizeof___int64='0'}
+   ac_cv_sizeof_int=${ac_cv_sizeof_int='4'}
+   ac_cv_sizeof_long=${ac_cv_sizeof_long='4'}
+   ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long='8'}
+   ac_cv_sizeof_short=${ac_cv_sizeof_short='2'}
+   ac_cv_sizeof_voidp=${ac_cv_sizeof_voidp='4'}
+ fi
diff -cr kaffe-0325/config/m68k/linux/jit-md.h kaffe-snap-0325/config/m68k/linux/jit-md.h
*** kaffe-0325/config/m68k/linux/jit-md.h	Thu Mar 25 14:48:53 1999
--- kaffe-snap-0325/config/m68k/linux/jit-md.h	Thu Mar 25 16:43:21 1999
***************
*** 0 ****
--- 1,43 ----
+ /*
+  * m68k/linux/jit-md.h
+  * Linux m68k JIT configuration information.
+  *
+  * Copyright (c) 1996, 1997, 1999
+  *      Transvirtual Technologies, Inc.  All rights reserved.
+  *
+  * See the file "license.terms" for information on usage and redistribution
+  * of this file.
+  *
+  * Same as m68k/netbsd1/jit-md.h
+  */
+ 
+ #ifndef __m68k_linux_jit_md_h
+ #define __m68k_linux_jit_md_h
+ 
+ /**/
+ /* Include common information. */
+ /**/
+ #include "m68k/jit.h"
+ 
+ /**/
+ /* Define where addresses are returned.  */
+ /**/
+ 
+ #define M68K_RETURN_REF		REG_d0	/* d0 */
+ 
+ /**/
+ /* Extra exception handling information. */
+ /**/
+ #include <signal.h>
+ 
+ #define	EXCEPTIONPROTO							\
+ 	int sig, int code, struct sigcontext *ctx
+ 
+ /* 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)
+ 
+ #endif
diff -cr kaffe-0325/config/m68k/linux/md.h kaffe-snap-0325/config/m68k/linux/md.h
*** kaffe-0325/config/m68k/linux/md.h	Fri Dec 18 06:23:46 1998
--- kaffe-snap-0325/config/m68k/linux/md.h	Thu Mar 25 09:48:47 1999
***************
*** 15,20 ****
--- 15,26 ----
  #include "m68k/common.h"
  #include "m68k/threads.h"
  
+ /*
+  * Redefine stack pointer offset.
+  */
+ #undef  SP_OFFSET
+ #define SP_OFFSET	14
+ 
  #if defined(TRANSLATOR)
  #include "jit-md.h"
  #endif
diff -cr kaffe-0325/config/m68k/netbsd1/config.frag kaffe-snap-0325/config/m68k/netbsd1/config.frag
*** kaffe-0325/config/m68k/netbsd1/config.frag	Fri Jan  8 06:02:55 1999
--- kaffe-snap-0325/config/m68k/netbsd1/config.frag	Thu Mar 25 09:48:48 1999
***************
*** 3,8 ****
--- 3,9 ----
  #
  host_cpu=m68k
  host_os=netbsd1
+ CFLAGS="-g -Wall -Wstrict-prototypes"
  if [ "$cross_compiling" = yes ]; then
  # if we use cross environment, following values may not be detected.
    ac_cv_alignmentof_voidp=${ac_cv_alignmentof_voidp='2'}
diff -cr kaffe-0325/config/m68k/netbsd1/jit-md.h kaffe-snap-0325/config/m68k/netbsd1/jit-md.h
*** kaffe-0325/config/m68k/netbsd1/jit-md.h	Thu Mar 25 02:52:54 1999
--- kaffe-snap-0325/config/m68k/netbsd1/jit-md.h	Thu Mar 25 13:56:24 1999
***************
*** 19,25 ****
  /**/
  /* Include common information. */
  /**/
! #include "m68k/netbsd1/jit.h"
  
  /**/
  /* Define where addresses are returned.  */
--- 19,25 ----
  /**/
  /* Include common information. */
  /**/
! #include "m68k/jit.h"
  
  /**/
  /* Define where addresses are returned.  */
diff -cr kaffe-0325/config/m68k/openbsd2/jit.h kaffe-snap-0325/config/m68k/openbsd2/jit.h
*** kaffe-0325/config/m68k/openbsd2/jit.h	Wed Apr  1 04:10:53 1998
--- kaffe-snap-0325/config/m68k/openbsd2/jit.h	Thu Mar 25 12:00:38 1999
***************
*** 138,153 ****
  /* Number of registers in the register set */
  #define	NR_REGISTERS	24
  
- /* Define which registers are used for which return values as seen
-  * by the the callee */
- #define	RETURN_INT		0	/* d0 */
- #define	RETURN_REF		M68K_RETURN_REF
- #define	RETURN_LONG_LOW		1	/* d1 */
- #define	RETURN_LONG_HIGH	0	/* d0 */
- #define	RETURN_FLOAT		32	/* f0 */
- #define	RETURN_DOUBLE_LOW	32	/* f0 */
- #define	RETURN_DOUBLE_HIGH	32	/* Not used in this configuration */
- 
  /**/
  /* Opcode generation. */
  /**/
--- 138,143 ----
diff -cr kaffe-0325/config/m68k/trampolines.c kaffe-snap-0325/config/m68k/trampolines.c
*** kaffe-0325/config/m68k/trampolines.c	Thu Aug 20 09:50:13 1998
--- kaffe-snap-0325/config/m68k/trampolines.c	Thu Mar 25 14:09:19 1999
***************
*** 33,51 ****
  #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
--- 33,46 ----
  #define C_FUNC_NAME(FUNC) #FUNC
  #endif
  
  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()
  );
  
  #endif


More information about the kaffe mailing list