[kaffe] Cleaner, Better MIPS/Linux Patch against 1.0.7, and issues with CVS tree

Kevin D. Kissell kevink@mips.com
Tue, 1 Oct 2002 16:39:21 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_00F9_01C26969.182E1130
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

I attach an updated patch to kaffe 1.0.7 that works
well on MIPS/Linux in *interpreted* mode, i.e.
when configured --with-engine=intrp.  For those of
you who have problems with attachments, I have also
put it up on my ftp server at
ftp://ftp.paralogos.com/pub/kaffe/mips/kaffe-1.0.7.patch_kevink_021001

It differs from the patch I posted the other day in two regards.

First, I dropped the change to
kaffe/kaffevm/systems/unix-jthreads/config-jthreads.h.
I had modified that file as part of bullet-proofing the
definition of SP_OFFSET and FP_OFFSET in
the MIPS builds, but in fact there was nothing
really broken there and no urgent reason to merge
a change to an "architecture independent" file.
In my opinion, there's a bunch of architecture
and platform-specific #ifdefs in that file that
should be replaced with definitions from include
files in the config directories, but that's just my
old project management reflexes kicking in.

Secondly, there was a bug in native methods that
was not addressed by the previous patch (or
some reason, the TestNative regression test only 
gets run in 1.0.7 if one does a configuration and 
build with --enable-debug). Native method support 
had been broken in two places with respect to floating 
point parameter passing. One of those is in 
config/mips/o32-sysdepCallMethod.h, which had some 
truly ugly code for argument setup which I have 
restructures/fixed and above all simplified the control flow
(it's still attrocious C). The other is, alas, in "architecture 
independent code", where a macro that is commented 
to be needed only for MIPS o32 calling sequences 
wasn't really doing the desired job in kaffe/kaffevm/support.c

With these changes, an interpretive MIPS/Linux
build passes all 1.0.7 regression tests both with and 
without debugging enabled.

I therefore checked-out a set of the current CVS
sources for kaffe, with the intention of being able
to provide a patch relative to the archive (to make
life easier for the maintainers) and to see if other
fixes to the sources made since 1.0.7 solved any
of the remaining problems I was seeing with the
JIT3 build.  Alas, while the resulting kaffe builds
and executes a lot of code, there are more, not fewer 
failures for the JIT regression tests, and even the 
interpretive build fails quite a few (12 out of 117) 
tests that it passed  in the 1.0.7-derived build, 
specifically:

ThreadInterrupt fails on a detected timeout.
UncaughtException hangs indefintely.
SoTimeout fails on a detected timeout.
KaffeVerifyBug hangs indefinitely.
CharArrayReaderTest hangs indefinitely
    after announcing "test14".
LineNumberReaderTest hangs indefinitely after
    taking 2 legalArgumentExceptionos for buffer sizes
    in tests 2 and 3, then succeeding tests 4 and 5. 
BufferedReaderTest hangs indefinitely after taking
    two IllegalArgumentExceptions for bad read-ahead
    and buffer sizes.
CLTestConc hangs indefinitely
CLTestLie hangs indefinitely
CatchDeath hangs indefinitely after passing test 1 of 3
SoInterrupt fails on a detected timeout.

Where "hangs indefinitely" means that the
tests consumed at least 3 minutes of CPU time,
sometimes much more, on a 160MHz MIPS 5Kc.
With a few  notable exceptions, most tests normally 
complete after about 30 seconds.

I hope that these problems aren't unique to MIPS,
and that these observations will prove to be helpful
in isolating them.  I have to set kaffe aside for a bit.

The patched 1.0.7 build runs the CVS regression 
tests just fine, with the proviso that the InnerTest
and Reflect from CVS fails because they are expecting 
different output than the 1.0.7 version, presumably due
to a change to the VM/class loader post-1.0.7, and
that NoClassDefTest, which does not exist in 1.0.7,
fails due to a class not being found that apparently
was only introduced to the class libraries post-1.0.7.

Given the good behavior of the patched 1.0.7 tree, 
I would encourage checking the enclosed patches 
into the CVS archive.  There will be more, one of these 
days, to fix the remaining JIT bugs and merge the 
Playstation 2 stuff, which is mostly, but not 100%, 
compatible with mainstream MIPS/Linux support.

            Regards,

            Kevin K.

------=_NextPart_000_00F9_01C26969.182E1130
Content-Type: application/octet-stream;
	name="kaffe-1.0.7.patch_kevink_021001"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="kaffe-1.0.7.patch_kevink_021001"

diff -ur kaffe-1.0.7/config/mips/common.h =
kaffe-1.0.7.kevink_021001/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_021001/config/mips/common.h	Sat Sep 28 00:53:07 =
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_021001/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_021001/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_021001/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_021001/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_021001/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_021001/config/mips/linux/md.h	Tue Oct  1 08:31:08 =
2002=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/o32-sysdepCallMethod.h =
kaffe-1.0.7.kevink_021001/config/mips/o32-sysdepCallMethod.h=0A=
--- kaffe-1.0.7/config/mips/o32-sysdepCallMethod.h	Thu Apr 15 20:19:31 =
1999=0A=
+++ kaffe-1.0.7.kevink_021001/config/mips/o32-sysdepCallMethod.h	Tue Oct =
 1 08:17:59 2002=0A=
@@ -123,61 +123,66 @@=0A=
 #endif=0A=
 =0A=
   case 4:=0A=
-      if (calltype[0] !=3D D) {=0A=
+      if ((calltype[0] !=3D D) && (calltype[0] !=3D F)) {=0A=
 	  a3 =3D callargs[3].i;=0A=
-	  goto allint_3;=0A=
+	  a2 =3D callargs[2].i;=0A=
+	  a1 =3D callargs[1].i;=0A=
+	  a0 =3D callargs[0].i;=0A=
+	  goto alldone;=0A=
       }=0A=
       =0A=
       if (calltype[2] =3D=3D D) {=0A=
 	  d2 =3D callargs[2].d;=0A=
-	  goto alldouble_2;=0A=
+	  if(calltype[0] =3D=3D D) d0 =3D callargs[0].d;=0A=
+	  else f0 =3D callargs[0].f;=0A=
+	  goto alldone;=0A=
       }=0A=
 =0A=
       a3 =3D callargs[3].i;=0A=
-      goto int_double;=0A=
 =0A=
   case 3:=0A=
-      if (calltype[0] !=3D D) {=0A=
-      allint_3:=0A=
+      if ((calltype[0] !=3D D) && (calltype[0] !=3D F)) {=0A=
 	  a2 =3D callargs[2].i;=0A=
-	  goto testfloat_2;=0A=
+	  a1 =3D callargs[1].i;=0A=
+	  a0 =3D callargs[0].i;=0A=
+	  goto alldone;=0A=
       }=0A=
       =0A=
-      if (calltype[2] =3D=3D F)=0A=
+      if ((calltype[2] =3D=3D F) && (calltype[0] =3D=3D D))=0A=
 	  f2 =3D callargs[2].f;=0A=
       else {=0A=
-      int_double:=0A=
 	  a2 =3D callargs[2].i;=0A=
       }=0A=
-      goto alldouble_2;=0A=
 =0A=
   case 2:=0A=
       if (calltype[0] =3D=3D D) {=0A=
-      alldouble_2:=0A=
 	  d0=3Dcallargs[0].d;=0A=
+	  goto alldone;=0A=
       } else {=0A=
-      testfloat_2:=0A=
 	  if (calltype[0] !=3D F) {=0A=
 	      a1 =3D callargs[1].i;=0A=
-	      goto allint_1;=0A=
+	      a0 =3D callargs[0].i;=0A=
+	      goto alldone;=0A=
 	  }=0A=
 =0A=
-	  if (calltype[1] =3D=3D F)=0A=
+	  if (calltype[1] =3D=3D F) {=0A=
 	      f2=3Dcallargs[1].f;=0A=
-	  else=0A=
+	      f0=3Dcallargs[0].f;=0A=
+	      goto alldone;=0A=
+	  } else {=0A=
 	      a1=3Dcallargs[1].i;=0A=
-	  goto allfloat_1;=0A=
+	      f0=3Dcallargs[0].f;=0A=
+	      goto alldone;=0A=
+	  }=0A=
       }=0A=
 =0A=
   case 1:=0A=
       if (calltype[0] =3D=3D F) {=0A=
-      allfloat_1:=0A=
 	  f0=3Dcallargs[0].f;=0A=
       } else {=0A=
-      allint_1:=0A=
 	  a0=3Dcallargs[0].i;=0A=
       }=0A=
-=0A=
+alldone:=0A=
   case 0:=0A=
 #ifndef LONG_SYSDEP=0A=
   noargs:=0A=
diff -ur kaffe-1.0.7/config/mips/threads.h =
kaffe-1.0.7.kevink_021001/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_021001/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/support.c =
kaffe-1.0.7.kevink_021001/kaffe/kaffevm/support.c=0A=
--- kaffe-1.0.7/kaffe/kaffevm/support.c	Thu May 30 00:58:44 2002=0A=
+++ kaffe-1.0.7.kevink_021001/kaffe/kaffevm/support.c	Tue Oct  1 =
08:18:28 2002=0A=
@@ -332,7 +332,17 @@=0A=
 # if NO_HOLES=0A=
 #  error "ALIGN_AT_64bits is incompatible with NO_HOLES"=0A=
 # endif=0A=
-# define ENSURE_ALIGN64(DO) do { if (call.callsize[i] =3D=3D 2 && (i & =
1)) { call.callsize[i] =3D 0; call.calltype[i] =3D 'I'; DO; ++i; ++s; =
call.callsize[i] =3D 2; } } while (0)=0A=
+# define ENSURE_ALIGN64(DO) do { \=0A=
+		if (call.callsize[i] =3D=3D 2 && (i & 1)) { \=0A=
+			char tmptype =3D call.calltype[i]; \=0A=
+			call.callsize[i] =3D 0; \=0A=
+			call.calltype[i] =3D 'I'; \=0A=
+			DO; \=0A=
+			++i; ++s; \=0A=
+			call.calltype[i] =3D tmptype; \=0A=
+			call.callsize[i] =3D 2; \=0A=
+		} \=0A=
+	} while (0)=0A=
 #else=0A=
 # define ENSURE_ALIGN64(DO) do {} while (0)=0A=
 #endif=0A=

------=_NextPart_000_00F9_01C26969.182E1130--