[kaffe] MIPS Port, Revisited

Kevin D. Kissell kevink@mips.com
Fri, 27 Sep 2002 21:00:40 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_01A0_01C26668.EFD3EAF0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

[I had forgotten which of my email accounts was registered with the mailing list.
 There's a copy of this message that was sent from my paralogos.com account
  that's awaiting the moderator's attention.  Hopefully, he'll have seen this first
  and will spare the rest of you the tedium of seeing it twice.]

Back in July, I was working a bit on kaffe for MIPS/Linux
and reporting stuff to this mailing list.  I've been off working
on other, more urgent projects since then, but I had a reason
to go back into the kaffe sources today, and I found and fixed
another potential problem (with MIPS/Linux signal handling).

My build seems to work fine in interpreted mode
(.configure --with-engine=intrp) and is down to failing
5 out of 115 regression tests with jit3 enabled.  I don't
know when I'll be able to hunt down and kill those
last bugs, but to prevent people from re-inventing the
wheel (or perhaps more accurately, re-patching the
flat tire), I attach the diff output between the 1.0.7
baseline and my working build.  As you can see,
the changes are pretty small, and mostly have to
do with stack frame setup, signal interfaces, and
some inconsistencies in the setup of the debug code.
Of particular interest to some will be my shot at
fixing the COMPARE_AND_EXCHANGE macro
in config/mips/common.h.  Between that semaphore
fix and the signal fix, the random regression test 
failures I was seeing with the JIT builds seem to
have gone away, and I'm down to reproducable
errors.

My Grand and Glorious Goal remains to have a
patch that can be applied to the 1.0.7 (though maybe
it will be 1.0.8 by then :-) refernce drop that will
build 100% functional kaffe for both vanilla MIPS
Linux and the Playstation 2, but from the emails
that I've been seeing on various lists, it's probably
worth sharing what I've already got.

            Regards,

            Kevin K.
------=_NextPart_000_01A0_01C26668.EFD3EAF0
Content-Type: application/octet-stream;
	name="kaffe-1.0.7_patch_kevink_020927"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="kaffe-1.0.7_patch_kevink_020927"

diff -ur kaffe-1.0.7/config/mips/common.h =
kaffe-1.0.7.kevink_020927/config/mips/common.h=0A=
--- kaffe-1.0.7/config/mips/common.h	Wed Mar  7 11:38:17 2001=0A=
+++ kaffe-1.0.7.kevink_020927/config/mips/common.h	Fri Sep 27 13:34:23 =
2002=0A=
@@ -53,16 +53,17 @@=0A=
 	asm volatile(				\=0A=
 	"	.set	noreorder\n"		\=0A=
 	"	.set	mips2\n"		\=0A=
-	"1:	ll	%0, %3\n"		\=0A=
-	"	xor	%1, %0, %4\n"		\=0A=
-	"	sltiu	%1, %1, 1\n"		\=0A=
-	"	movn	%0, %5, %1\n"		\=0A=
-	"	sc	%0, %2\n"		\=0A=
+	"1:	ll	%0, %2\n"		\=0A=
+	"	bne	%0, %3,2f\n"		\=0A=
+	"	move	%0, $0\n"		\=0A=
+	"	move	%0, %4\n"		\=0A=
+	"	sc	%0, %1\n"		\=0A=
 	"	beqz	%0, 1b\n"		\=0A=
-	"	sync\n"				\=0A=
+	"	nop\n"				\=0A=
+	"2:\n"					\=0A=
 	"	.set	mips0\n"		\=0A=
 	"	.set	reorder\n"		\=0A=
-	: "=3D&r" (tmp), "=3D&r" (ret), "=3Dm" (*(A))	\=0A=
+	: "=3D&r" (ret), "=3Dm" (*(A))		\=0A=
 	: "m" (*(A)), "r" (O), "r" (N)		\=0A=
 	: "memory");				\=0A=
 	ret;					\=0A=
diff -ur kaffe-1.0.7/config/mips/jit3-mips.def =
kaffe-1.0.7.kevink_020927/config/mips/jit3-mips.def=0A=
--- kaffe-1.0.7/config/mips/jit3-mips.def	Sun Jun 17 18:39:11 2001=0A=
+++ kaffe-1.0.7.kevink_020927/config/mips/jit3-mips.def	Mon Jul 15 =
22:53:49 2002=0A=
@@ -25,10 +25,11 @@=0A=
 #endif=0A=
 =0A=
 #ifdef DEBUG=0A=
-extern int pc;=0A=
-int dbmsg =3D 0;=0A=
+extern uint pc;=0A=
+int jit_debug =3D 0;=0A=
+/* int dbmsg =3D 0; */=0A=
 #define	debug_name(x)	debug(x)=0A=
-#define	debug(x)	if (dbmsg) printf##x;fflush(stdout)=0A=
+#define	debug(x)	if (jit_debug) printf##x;fflush(stdout)=0A=
 static char* rnames[] =3D {=0A=
 	"i0",  "i1",  "i2",  "i3",  "i4",  "i5",  "i6",  "i7",=0A=
 	"i8",  "i9",  "i10", "i11", "i12", "i13", "i14", "i15",=0A=
diff -ur kaffe-1.0.7/config/mips/linux/md.c =
kaffe-1.0.7.kevink_020927/config/mips/linux/md.c=0A=
--- kaffe-1.0.7/config/mips/linux/md.c	Mon Sep  6 23:44:39 1999=0A=
+++ kaffe-1.0.7.kevink_020927/config/mips/linux/md.c	Fri Jul  5 14:46:49 =
2002=0A=
@@ -9,4 +9,6 @@=0A=
  * of this file. =0A=
  */=0A=
 =0A=
+#if defined(TRANSLATOR)=0A=
 #include "mips/mips.c"=0A=
+#endif=0A=
diff -ur kaffe-1.0.7/config/mips/linux/md.h =
kaffe-1.0.7.kevink_020927/config/mips/linux/md.h=0A=
--- kaffe-1.0.7/config/mips/linux/md.h	Mon Sep  6 23:44:39 1999=0A=
+++ kaffe-1.0.7.kevink_020927/config/mips/linux/md.h	Fri Sep 27 11:09:34 =
2002=0A=
@@ -19,7 +19,7 @@=0A=
 #undef	FP_OFFSET=0A=
 =0A=
 #define	SP_OFFSET	1=0A=
-#define	FP_OFFSET	10=0A=
+#define FP_OFFSET	10=0A=
 =0A=
 #if defined(TRANSLATOR)=0A=
 #include "jit-md.h"=0A=
@@ -28,16 +28,16 @@=0A=
 /**/=0A=
 /* Signal handling */=0A=
 /**/=0A=
-#include <sigcontext.h>=0A=
+#include <signal.h>=0A=
 =0A=
 /* Define the entry into a signal handler */=0A=
-#define EXCEPTIONPROTO  int sig, int c1, int c2, int c3, int c4, int =
c5, int c6, int c7, struct sigcontext ctx=0A=
+#define EXCEPTIONPROTO  int sig, int cause, struct sigcontext *ctx=0A=
 =0A=
 /* Get the first exception frame from a signal handler */=0A=
 #define MIPS_FP 30=0A=
 #define EXCEPTIONFRAME(f, c) \=0A=
-	(f).return_frame =3D (void*)(c).sc_regs[MIPS_FP]; \=0A=
-	(f).return_pc =3D (void*)(c).sc_pc=0A=
+	(f).return_frame =3D (void*)(c)->sc_regs[MIPS_FP]; \=0A=
+	(f).return_pc =3D (void*)(c)->sc_pc=0A=
 =0A=
 =0A=
 #endif=0A=
diff -ur kaffe-1.0.7/config/mips/threads.h =
kaffe-1.0.7.kevink_020927/config/mips/threads.h=0A=
--- kaffe-1.0.7/config/mips/threads.h	Mon Mar 12 13:50:47 2001=0A=
+++ kaffe-1.0.7.kevink_020927/config/mips/threads.h	Mon Jul 15 19:23:07 =
2002=0A=
@@ -32,9 +32,11 @@=0A=
  * This is the offset into the setjmp buffer where the stack pointer is=0A=
  * stored.  This may be different with different OSes.=0A=
  */=0A=
+#if !defined(SP_OFFSET)=0A=
+=0A=
 #if !defined(_MIPS_SIM) || (_MIPS_SIM =3D=3D _MIPS_SIM_ABI32)=0A=
-#define SP_OFFSET               2=0A=
-#define FP_OFFSET               13=0A=
+#define SP_OFFSET               1=0A=
+#define FP_OFFSET		10=0A=
 #endif=0A=
 =0A=
 #if (_MIPS_SIM =3D=3D _MIPS_SIM_ABI64 || _MIPS_SIM =3D=3D =
_MIPS_SIM_NABI32)=0A=
@@ -42,4 +44,5 @@=0A=
 #define FP_OFFSET               23=0A=
 #endif=0A=
 =0A=
+#endif /* SP_OFFSET */=0A=
 #endif=0A=
diff -ur =
kaffe-1.0.7/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h =
kaffe-1.0.7.kevink_020927/kaffe/kaffevm/systems/unix-jthreads/config-jthr=
eads.h=0A=
--- kaffe-1.0.7/kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h	=
Fri Apr 30 21:05:37 1999=0A=
+++ =
kaffe-1.0.7.kevink_020927/kaffe/kaffevm/systems/unix-jthreads/config-jthr=
eads.h	Mon Jul 15 19:24:23 2002=0A=
@@ -93,11 +93,23 @@=0A=
 #define sigprocmask(op, nsig, osig)     sigsetmask(0)=0A=
 typedef int sigset_t;=0A=
 =0A=
-#elif defined(sgi) && defined(mips)=0A=
+#elif defined(mips)=0A=
+=0A=
+#if    defined(sgi)=0A=
 =0A=
 /* SGI running IRIX 6.2 */=0A=
+#undef  SP_OFFSET=0A=
+#undef  FP_OFFSET=0A=
 #define SP_OFFSET		2=0A=
 #define FP_OFFSET		13=0A=
+=0A=
+#elif !defined(SP_OFFSET) /* mips but not SGI */=0A=
+=0A=
+/* Should have been established in config/mips headers */=0A=
+=0A=
+#error MIPS configuration without valid SP_OFFSET=0A=
+=0A=
+#endif /* sgi */=0A=
 =0A=
 #elif defined(arm32) && defined(__NetBSD__)=0A=
 =0A=

------=_NextPart_000_01A0_01C26668.EFD3EAF0--