[kaffe] Patch for PS2/Linux

Dylan Schell dylans@xs4all.nl
Sun, 16 Jun 2002 00:33:22 +0200


This is a multi-part message in MIME format.
--------------030500040309040807020402
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

These are the changes I made to get the interpreter to run on
PS2/Linux. I've added a switch to configure.in to enable my changes.
(--enable-ps2linux) Bear with me here, since I've never worked with
configure scripts before, so if anything needs changing, let me know.
I created the diff before running autoconf to keep the patch clean.

The only point bothering me about the patch right now is that my C is a 
little rusty and my changes in o32-sysdepCallMethod.h could also be done 
with a typecast.

The only testcases that fail are those that expect correct sign of
zero, NaN and Inf.

The JIT would run if the current kernel wasn't broken in the FP 
department. Work is underway to fix this. As soon as the kernel is
fixed the JIT should also work on the PS2 ( and the patch for
o32-sysdeCallMethod.h can go away as well)


--------------030500040309040807020402
Content-Type: text/plain;
 name="kaffe-ps2.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="kaffe-ps2.patch"

diff -r -c3 kaffe-1.0.7-rc1/config/mips/linux/md.h kaffe-1.0.7-rc1-ps2/config/mips/linux/md.h
*** kaffe-1.0.7-rc1/config/mips/linux/md.h	Mon Sep  6 23:44:39 1999
--- kaffe-1.0.7-rc1-ps2/config/mips/linux/md.h	Sat Jun 15 22:05:06 2002
***************
*** 21,26 ****
--- 21,31 ----
  #define	SP_OFFSET	1
  #define	FP_OFFSET	10
  
+ #ifdef HAVE_PS2_LINUX
+ #undef	FP_OFFSET
+ #define	FP_OFFSET	36
+ #endif
+ 
  #if defined(TRANSLATOR)
  #include "jit-md.h"
  #endif
***************
*** 28,34 ****
--- 33,43 ----
  /**/
  /* Signal handling */
  /**/
+ #ifdef HAVE_PS2_LINUX
+ #include <signal.h>
+ #else
  #include <sigcontext.h>
+ #endif
  
  /* Define the entry into a signal handler */
  #define EXCEPTIONPROTO  int sig, int c1, int c2, int c3, int c4, int c5, int c6, int c7, struct sigcontext ctx
diff -r -c3 kaffe-1.0.7-rc1/config/mips/mips.c kaffe-1.0.7-rc1-ps2/config/mips/mips.c
*** kaffe-1.0.7-rc1/config/mips/mips.c	Fri Oct 15 03:38:46 1999
--- kaffe-1.0.7-rc1-ps2/config/mips/mips.c	Sat Jun 15 22:01:11 2002
***************
*** 20,25 ****
--- 20,28 ----
  #include "support.h"
  #include "../../kaffe/kaffevm/thread.h"
  
+ #ifdef HAVE_PS2_LINUX
+ #  include "jit.h"
+ #endif
  extern int maxArgs;
  extern int isStatic;
  
diff -r -c3 kaffe-1.0.7-rc1/config/mips/o32-sysdepCallMethod.h kaffe-1.0.7-rc1-ps2/config/mips/o32-sysdepCallMethod.h
*** kaffe-1.0.7-rc1/config/mips/o32-sysdepCallMethod.h	Thu Apr 15 20:19:31 1999
--- kaffe-1.0.7-rc1-ps2/config/mips/o32-sysdepCallMethod.h	Sat Jun 15 23:16:30 2002
***************
*** 103,110 ****
--- 103,120 ----
      register ARG_TYPE a2 asm("$6");
      register ARG_TYPE a3 asm("$7");
  
+ #ifdef HAVE_PS2_LINUX
+     union {
+         double d;
+         struct {
+             int hi;
+             int lo;
+         } fake_double;
+     } split;
+ #else
      register double d0 asm("$f12");
      register double d2 asm("$f14");
+ #endif
  
      register float f0 asm("$f12");
      register float f2 asm("$f14");
***************
*** 129,135 ****
--- 139,151 ----
        }
        
        if (calltype[2] == D) {
+ #ifdef HAVE_PS2_LINUX
+           split.d = callargs[2].d;
+           a2 = split.fake_double.hi;
+           a3 = split.fake_double.lo;
+ #else
  	  d2 = callargs[2].d;
+ #endif
  	  goto alldouble_2;
        }
  
***************
*** 154,160 ****
--- 170,183 ----
    case 2:
        if (calltype[0] == D) {
        alldouble_2:
+ #ifdef HAVE_PS2_LINUX
+           /* move double into a0/a1 */
+           split.d = callargs[0].d;
+           a0 = split.fake_double.hi;
+           a1 = split.fake_double.lo;
+ #else
  	  d0=callargs[0].d;
+ #endif
        } else {
        testfloat_2:
  	  if (calltype[0] != F) {
***************
*** 183,189 ****
--- 206,216 ----
    noargs:
  #endif
      /* Ensure that the assignments to f* registers won't be optimized away. */
+ #ifdef HAVE_PS2_LINUX
+     asm ("" :: "f" (f0), "f" (f2));
+ #else
      asm ("" :: "f" (f0), "f" (f2), "f" (d0), "f" (d2));
+ #endif
  
      switch(call->retsize) {
      case 0:
diff -r -c3 kaffe-1.0.7-rc1/config/mips/threads.h kaffe-1.0.7-rc1-ps2/config/mips/threads.h
*** kaffe-1.0.7-rc1/config/mips/threads.h	Mon Mar 12 13:50:47 2001
--- kaffe-1.0.7-rc1-ps2/config/mips/threads.h	Sat Jun 15 23:19:40 2002
***************
*** 27,32 ****
--- 27,37 ----
  #define	THREADSTACKSIZE		(32 * 1024)
  #endif
  
+ #ifdef HAVE_PS2_LINUX
+ #undef THREADSTACKSIZE
+ #define THREADSTACKSIZE		(128 * 1024)
+ #endif
+ 
  /*
   * Stack offset.
   * This is the offset into the setjmp buffer where the stack pointer is
diff -r -c3 kaffe-1.0.7-rc1/configure.in kaffe-1.0.7-rc1-ps2/configure.in
*** kaffe-1.0.7-rc1/configure.in	Sun Jun  2 07:03:49 2002
--- kaffe-1.0.7-rc1-ps2/configure.in	Sat Jun 15 21:51:09 2002
***************
*** 831,836 ****
--- 831,849 ----
  dnl -------------------------------------------------------------------------
  
  dnl =========================================================================
+ dnl Compile specifically for PS2/Linux
+ dnl -------------------------------------------------------------------------
+ 
+ AC_ARG_ENABLE(ps2linux, [  --enable-ps2linux       Compile Specifically For PS2])
+ AC_MSG_CHECKING([whether to enable PS2/Linux Specific patches])
+ AC_MSG_RESULT($enable_ps2linux)
+ if test "x$enable_ps2linux" = "xyes"; then
+     AC_DEFINE([HAVE_PS2_LINUX], 1, [Enable PS2 Linux patches])
+ fi
+ 
+ dnl -------------------------------------------------------------------------
+ 
+ dnl =========================================================================
  dnl Checks for typedefs, structures, and compiler characteristics.
  dnl -------------------------------------------------------------------------
  

--------------030500040309040807020402--