[kaffe] CVS kaffe (hkraemer): fixes for arm-linux jit engine

Kaffe CVS cvs-commits at kaffe.org
Tue Sep 30 12:53:04 PDT 2003


PatchSet 4083 
Date: 2003/09/30 19:50:52
Author: hkraemer
Branch: HEAD
Tag: (none) 
Log:
fixes for arm-linux jit engine

It compiles without warnings using gcc 3.2.2, but crashes
at runtime, hope to fix it, though.

Members: 
	ChangeLog:1.1678->1.1679 
	config/arm/common.h:1.6->1.7 
	config/arm/jit.h:1.9->1.10 
	config/arm/linux/jit-md.h:1.5->1.6 
	config/arm/linux/md.h:1.4->1.5 
	libraries/clib/math/BigInteger.c:1.19->1.20 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1678 kaffe/ChangeLog:1.1679
--- kaffe/ChangeLog:1.1678	Mon Sep 29 23:50:25 2003
+++ kaffe/ChangeLog	Tue Sep 30 19:50:52 2003
@@ -1,3 +1,25 @@
+2003-09-30  Helmer Kraemer  <hkraemer at freenet.de>
+
+	* libraries/clib/math/BigInteger.c
+	[!HAVE_GMP_H] (Java_java_math_BigInteger_assignString0): changed
+	return type to jint to match prototype of assignString0 when gmp
+	is used
+
+	* config/arm/common.h (sysdepCallMethod): changed into an inline
+	method, don't treat 'L' return type specially
+
+	* config/arm/jit.h (exceptionFrame): changed type of fields to
+	uintp to fix compilation warnings
+	(NEXTFRAME, PCFRAME, FPFRAME): remove now unnecessary casts
+
+	* config/arm/linux/jit-md.h (FIRSTFRAME): redefined using gcc's
+	__builtin_frame_address extension
+	(ARM_LINUX_HACK): removed since it's no longer necessary
+
+	* config/arm/linux/md.h (SP_OFFSET, FP_OFFSET): corrected to
+	match what current glibc does
+	(ARM_LINUX_HACK): removed since it's no longer necessary
+	
 2003-09-30  Dalibor Topic <robilad at kaffe.org>
 
 	* libraries/javalib/java/util/zip/ZipEntry.java:
Index: kaffe/config/arm/common.h
diff -u kaffe/config/arm/common.h:1.6 kaffe/config/arm/common.h:1.7
--- kaffe/config/arm/common.h:1.6	Sat Oct 19 11:04:41 2002
+++ kaffe/config/arm/common.h	Tue Sep 30 19:50:54 2003
@@ -27,83 +27,87 @@
  * have to take this into account here.  It is a convention of the
  * software floating point libraries and the build tools.
  */
-
-#define	sysdepCallMethod(CALL) do {					\
-  int extraargs[((CALL)->nrargs>4)?((CALL)->nrargs-4):0];		\
-  switch((CALL)->nrargs) {						\
-    register int r0 asm("r0");						\
-    register int r1 asm("r1");						\
-    register int r2 asm("r2");						\
-    register int r3 asm("r3");						\
-    register double f0 asm("f0");                                       \
-  default:								\
-    {									\
-      int *args = extraargs;						\
-      int argidx = 4; 							\
-      if ((CALL)->callsize[3] == 2) {					\
-	*args++ = ((CALL)->args[argidx].j) >> 32;			\
-	}								\
-      for(; argidx < (CALL)->nrargs; ++argidx) {			\
-	if ((CALL)->callsize[argidx]) { 				\
-	  *args++ = (CALL)->args[argidx].i;				\
-	  if ((CALL)->callsize[argidx] == 2) 				\
-	    *args++ = ((CALL)->args[argidx].j) >> 32;			\
-	} 								\
-      }									\
-    }									\
-  case 4:								\
-    if ((CALL)->callsize[3]) {						\
-      r3 = (CALL)->args[3].i;						\
-      if ((CALL)->callsize[3] == 2)					\
-        *extraargs = ((CALL)->args[3].j) >> 32; 			\
-    }									\
-  case 3:								\
-    if ((CALL)->callsize[2]) {						\
-      r2 = (CALL)->args[2].i;						\
-      if ((CALL)->callsize[2] == 2)					\
-        r3 = ((CALL)->args[2].j) >> 32; 				\
-    }									\
-  case 2:								\
-    if ((CALL)->callsize[1]) {						\
-      r1 = (CALL)->args[1].i;						\
-      if ((CALL)->callsize[1] == 2)					\
-        r2 = ((CALL)->args[1].j) >> 32; 				\
-    }									\
-  case 1:								\
-    if ((CALL)->callsize[0]) {						\
-      r0 = (CALL)->args[0].i;						\
-      if ((CALL)->callsize[0] == 2)					\
-        r1 = ((CALL)->args[0].j) >> 32; 				\
-    }									\
-  case 0:								\
-    asm ("mov lr, pc\n							\
-	  mov pc, %3\n"							\
-        : "=r" (r0), "=r" (r1), "=f" (f0)				\
-	: "r" ((CALL)->function),					\
-	  "0" (r0), "1" (r1), "r" (r2), "r" (r3) 			\
-	: "ip", "rfp", "sl", "fp", "lr" 				\
-	);								\
-    switch((CALL)->rettype)    						\
-    {									\
-    case 'D':								\
-        asm("stfd %1,%0" : "=m" ((CALL)->ret->d) : "f" (f0));		\
-	break;								\
-    case 'F':								\
-	asm("stfs %1,%0" : "=m" ((CALL)->ret->f) : "f" (f0));		\
-	break;								\
-    case 'L':								\
-	(CALL)->ret->l = r0;						\
-	break;								\
-    case 'J':								\
-	(&(CALL)->ret->i)[1] = r1;					\
-	/* follow through */						\
-    default:								\
-	(CALL)->ret->i = r0;						\
-    }									\
-    break;								\
-  }									\
-} while (0)
-
+#if NEED_sysdepCallMethod
+static inline void sysdepCallMethod(callMethodInfo *call) {
+  int extraargs[(call->nrargs>4)?(call->nrargs-4):0];
+  switch(call->nrargs) {
+    register int r0 asm("r0");
+    register int r1 asm("r1");
+    register int r2 asm("r2");
+    register int r3 asm("r3");
+    register double f0 asm("f0");
+  default:
+    {
+      int *args = extraargs;
+      int argidx = 4;
+      if (call->callsize[3] == 2) {
+	*args++ = (call->args[argidx].j) >> 32;
+	}
+      for(; argidx < call->nrargs; ++argidx) {
+	if (call->callsize[argidx]) {
+	  *args++ = call->args[argidx].i;
+	  if (call->callsize[argidx] == 2)
+	    *args++ = (call->args[argidx].j) >> 32;
+	}
+      }
+    }
+  case 4:
+    if (call->callsize[3]) {
+      r3 = call->args[3].i;
+      if (call->callsize[3] == 2)
+        *extraargs = (call->args[3].j) >> 32;
+    }
+  case 3:
+    if (call->callsize[2]) {
+      r2 = call->args[2].i;
+      if (call->callsize[2] == 2)
+        r3 = (call->args[2].j) >> 32;
+    }
+  case 2:
+    if (call->callsize[1]) {
+      r1 = call->args[1].i;
+      if (call->callsize[1] == 2)
+        r2 = (call->args[1].j) >> 32;
+    }
+  case 1:
+    if (call->callsize[0]) {
+      r0 = call->args[0].i;
+      if (call->callsize[0] == 2)
+        r1 = (call->args[0].j) >> 32;
+    }
+  case 0:
+    asm ("mov lr, pc\n"
+"	  mov pc, %3\n"
+        : "=r" (r0), "=r" (r1), "=f" (f0)
+	: "r" (call->function),
+	  "0" (r0), "1" (r1), "r" (r2), "r" (r3)
+	: "ip", "rfp", "sl", "fp", "lr"
+	);
+    switch(call->rettype)
+    {
+    case 'D':
+        asm("stfd %1,%0" : "=m" (call->ret->d) : "f" (f0));
+	break;
+    case 'F':
+	asm("stfs %1,%0" : "=m" (call->ret->f) : "f" (f0));
+	break;
+    /*
+     * XXX doesn't seem to be necessary to special case 'L',
+     * since its just another 32bit int, right !??!??
+    case 'L':
+	call->ret->l = r0;
+	break;
+	*/
+    case 'J':
+	(&call->ret->i)[1] = r1;
+	/* follow through */
+    default:
+	call->ret->i = r0;
+    }
+    break;
+  }									
+}
+#endif
 
 /*
  * Do an atomic exchange.  The contents of address 'A' is exchanged
Index: kaffe/config/arm/jit.h
diff -u kaffe/config/arm/jit.h:1.9 kaffe/config/arm/jit.h:1.10
--- kaffe/config/arm/jit.h:1.9	Wed Aug 27 20:07:24 2003
+++ kaffe/config/arm/jit.h	Tue Sep 30 19:50:54 2003
@@ -32,20 +32,20 @@
 
 /* Structure of exception frame on stack */
 typedef struct _exceptionFrame {
-        char*   retfp;		/* should be "addr_t" */
-        char*   retsp;
-        char*   retpc;
+        uintp   retfp;
+        uintp   retsp;
+        uintp   retpc;
 } exceptionFrame;
 
 /* Get the next frame in the chain */
 #define NEXTFRAME(f)                                                    \
-        ((uintp)((exceptionFrame*)(f))->retfp - sizeof(exceptionFrame))
+        (((exceptionFrame*)(f))->retfp - sizeof(exceptionFrame))
 
 /* Extract the PC from the given frame */
 #define PCFRAME(f)                                                      \
-        ((uintp)((f)->retpc - 4))
+        ((f)->retpc - 4)
 #define FPFRAME(f)							\
-	((uintp)((f)->retfp))
+	((f)->retfp)
 
 /* Get the first exception frame from a subroutine call */
 #define FIRSTFRAME(f, o)                                                \
Index: kaffe/config/arm/linux/jit-md.h
diff -u kaffe/config/arm/linux/jit-md.h:1.5 kaffe/config/arm/linux/jit-md.h:1.6
--- kaffe/config/arm/linux/jit-md.h:1.5	Thu Sep 18 18:29:02 2003
+++ kaffe/config/arm/linux/jit-md.h	Tue Sep 30 19:50:54 2003
@@ -17,6 +17,9 @@
 /**/
 #include "arm/jit.h"
 
+#undef FIRSTFRAME
+#define FIRSTFRAME(f, o) (f) = *(exceptionFrame *)__builtin_frame_address(0)
+
 /**/
 /* Extra exception handling information. */
 /**/
@@ -43,14 +46,6 @@
 #if defined(SA_SIGINFO)
 #undef SA_SIGINFO
 #endif
-
-/* It looks like the linux kernel sets r0 to the signal number
- * and passes a pointer to the context as the fourth argument
- * use this hack to account for that.  -- gback
- *
- * Undef when this gets fixed -- check arch/arm/kernel/signal.c
- */
-#define ARM_LINUX_HACK
 
 #define EXCEPTIONPROTO SIGNAL_ARGS(sig, ctx)
 
Index: kaffe/config/arm/linux/md.h
diff -u kaffe/config/arm/linux/md.h:1.4 kaffe/config/arm/linux/md.h:1.5
--- kaffe/config/arm/linux/md.h:1.4	Thu Sep 18 18:29:02 2003
+++ kaffe/config/arm/linux/md.h	Tue Sep 30 19:50:54 2003
@@ -16,36 +16,17 @@
 #include "arm/threads.h"
 
 
-/* It looks like the linux kernel sets r0 to the signal number
- * and passes a pointer to the context as the fourth argument
- * use this hack to account for that.  -- gback
- *
- * Undef when this gets fixed -- check arch/arm/kernel/signal.c
- */
-#define ARM_LINUX_HACK
-
 /* Function prototype for signal handlers */
 #if defined(HAVE_STRUCT_SIGCONTEXT_STRUCT) && !defined(__GLIBC__)
 /* Linux < 2.1.1 */
-#if defined(ARM_LINUX_HACK)
-#define SIGNAL_ARGS(sig, ctx) \
-        int sig, int r1, int r2, int r3, struct sigcontext_struct ctx
-#else
 #define	SIGNAL_ARGS(sig, ctx) \
 	int sig, struct sigcontext_struct ctx
-#endif /* ARM_LINUX_HACK */
-
 #elif defined(HAVE_STRUCT_SIGCONTEXT) || defined(__GLIBC__)
 /* Linux >= 2.1.1  or Linux 2.0.x with glibc2 */
-#if defined(ARM_LINUX_HACK)
-#define SIGNAL_ARGS(sig, ctx) \
-        int sig, int r1, int r2, int r3, struct sigcontext ctx
-#else
 #define	SIGNAL_ARGS(sig, ctx) \
 	int sig, struct sigcontext ctx
-#endif /* ARM_LINUX_HACK */
 #else
-#error Do not know how to define EXCEPTIONPROTO
+#error Do not know how to define SIGNAL_ARGS
 #endif
 
 #define GET_SIGNAL_CONTEXT_POINTER(ctx) (&ctx)
@@ -78,8 +59,11 @@
 #undef SP_OFFSET
 #undef FP_OFFSET
 
-/* arm/linux/elf (NetWinder) */
-#define SP_OFFSET               20
-#define FP_OFFSET               19
+/*
+ * figured by looking at sysdeps/arm/bits/setjmp.h
+ * and sysdeps/arm/setjmp.S from glibc
+ */ 
+#define SP_OFFSET	8
+#define FP_OFFSET	7
 
 #endif
Index: kaffe/libraries/clib/math/BigInteger.c
diff -u kaffe/libraries/clib/math/BigInteger.c:1.19 kaffe/libraries/clib/math/BigInteger.c:1.20
--- kaffe/libraries/clib/math/BigInteger.c:1.19	Fri Sep  5 17:35:30 2003
+++ kaffe/libraries/clib/math/BigInteger.c	Tue Sep 30 19:50:53 2003
@@ -590,7 +590,7 @@
 	gmp_not_found(env);
 }
 
-void
+jint
 Java_java_math_BigInteger_assignString0(JNIEnv* env, jobject r, jstring val, jint radix)
 {
 	gmp_not_found(env);




More information about the kaffe mailing list