PATCH libjava: Enable bytecode interpreter for sparc*-*

Jeff Sturm jsturm@one-point.com
Fri Jul 19 14:52:00 GMT 2002


Patch includes two ffi-related fixes, one needed for sparc64, the
other for both.  Both have to do with big endianness.

This depends on my as-yet-unreviewed libffi closure patch:

http://gcc.gnu.org/ml/java-patches/2002-q3/msg00036.html

Test results on sparc-sun-solaris2.8:

		=== libjava Summary ===

# of expected passes		2649
# of unexpected failures	18
# of expected failures		14
# of untested testcases		26

New failure:

FAIL: Array_3 execution - gij test

On sparcv9-sun-solaris2.8:

		=== libjava Summary ===

# of expected passes		2659
# of unexpected failures	14
# of expected failures		14
# of untested testcases		20

New failures:

FAIL: Array_3 execution - gij test
FAIL: err10 output - gij test

I'll look at these failures once I muster the courage to debug the
interpreter again (but they aren't regressions, since they weren't tested
before, right?)


2002-07-19  Jeff Sturm  <jsturm@one-point.com>

	* configure.host (sparc*-*): Enable libgcj_interpreter.

	* interpret.cc (_Jv_InterpMethod::run_normal): Pass cif to run.
	(_Jv_InterpMethod::run_synch_object): Likewise.
	(_Jv_InterpMethod::run_synch_class): Likewise.
	(_Jv_InterpMethod::run): Receive cif from caller.
	(perform_invoke): Create union type for rvalue.
	(insn_ireturn): Use narrowing conversions on pointer type.

	* include/java-interp.h (_Jv_InterpMethod::run):
	Declare cif argument.

Index: configure.host
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.host,v
retrieving revision 1.34
diff -u -p -r1.34 configure.host
--- configure.host	10 Jun 2002 03:50:41 -0000	1.34
+++ configure.host	19 Jul 2002 20:50:22 -0000
@@ -97,7 +97,8 @@ case "${host}" in
 	enable_hash_synchronization_default=yes
 	slow_pthread_self=yes
 	;;
-  sparc-*)
+  sparc*-*)
+	libgcj_interpreter=yes
         ;;
   ia64-*)
 	sysdeps_dir=ia64
Index: interpret.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/interpret.cc,v
retrieving revision 1.33
diff -u -p -r1.33 interpret.cc
--- interpret.cc	24 Jun 2002 20:38:45 -0000	1.33
+++ interpret.cc	19 Jul 2002 20:50:22 -0000
@@ -240,16 +240,16 @@ static jint get4(unsigned char* loc) {
     }									      \
   while (0)

-void _Jv_InterpMethod::run_normal (ffi_cif *,
+void _Jv_InterpMethod::run_normal (ffi_cif * cif,
 				   void* ret,
 				   ffi_raw * args,
 				   void* __this)
 {
   _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
-  _this->run (ret, args);
+  _this->run (cif, ret, args);
 }

-void _Jv_InterpMethod::run_synch_object (ffi_cif *,
+void _Jv_InterpMethod::run_synch_object (ffi_cif * cif,
 					 void* ret,
 					 ffi_raw * args,
 					 void* __this)
@@ -259,10 +259,10 @@ void _Jv_InterpMethod::run_synch_object
   jobject rcv = (jobject) args[0].ptr;
   JvSynchronize mutex (rcv);

-  _this->run (ret, args);
+  _this->run (cif, ret, args);
 }

-void _Jv_InterpMethod::run_synch_class (ffi_cif *,
+void _Jv_InterpMethod::run_synch_class (ffi_cif * cif,
 					void* ret,
 					ffi_raw * args,
 					void* __this)
@@ -272,7 +272,7 @@ void _Jv_InterpMethod::run_synch_class (
   jclass sync = _this->defining_class;
   JvSynchronize mutex (sync);

-  _this->run (ret, args);
+  _this->run (cif, ret, args);
 }

 #ifdef DIRECT_THREADED
@@ -745,7 +745,7 @@ _Jv_InterpMethod::compile (const void *
 #endif /* DIRECT_THREADED */

 void
-_Jv_InterpMethod::run (void *retp, ffi_raw *args)
+_Jv_InterpMethod::run (ffi_cif *cif, void *retp, ffi_raw *args)
 {
   using namespace java::lang::reflect;

@@ -1124,7 +1124,14 @@ _Jv_InterpMethod::run (void *retp, ffi_r
 	ffi_cif *cif = &rmeth->cif;
 	ffi_raw *raw = (ffi_raw*) sp;

-	jdouble rvalue;
+	union
+	{
+	  ffi_arg i;
+	  jobject o;
+	  jlong l;
+	  jfloat f;
+	  jdouble d;
+	} rvalue;

 #if FFI_NATIVE_RAW_API
 	/* We assume that this is only implemented if it's correct	*/
@@ -1140,11 +1147,11 @@ _Jv_InterpMethod::run (void *retp, ffi_r
 	 * so those are checked before the switch */
 	if (rtype == FFI_TYPE_POINTER)
 	  {
-	    PUSHA (*(jobject*)&rvalue);
+	    PUSHA (rvalue.o);
 	  }
 	else if (rtype == FFI_TYPE_SINT32)
 	  {
-	    PUSHI (*(jint*)&rvalue);
+	    PUSHI ((jint) rvalue.i);
 	  }
 	else if (rtype == FFI_TYPE_VOID)
 	  {
@@ -1156,35 +1163,35 @@ _Jv_InterpMethod::run (void *retp, ffi_r
 	      {
 	      case FFI_TYPE_SINT8:
 		{
-		  jbyte value = (*(jint*)&rvalue) & 0xff;
+		  jbyte value = ((jint) rvalue.i) & 0xff;
 		  PUSHI (value);
 		}
 		break;

 	      case FFI_TYPE_SINT16:
 		{
-		  jshort value = (*(jint*)&rvalue) & 0xffff;
+		  jshort value = ((jint) rvalue.i) & 0xffff;
 		  PUSHI (value);
 		}
 		break;

 	      case FFI_TYPE_UINT16:
 		{
-		  jint value = (*(jint*)&rvalue) & 0xffff;
+		  jint value = ((jint) rvalue.i) & 0xffff;
 		  PUSHI (value);
 		}
 		break;

 	      case FFI_TYPE_FLOAT:
-		PUSHF (*(jfloat*)&rvalue);
+		PUSHF (rvalue.f);
 		break;

 	      case FFI_TYPE_DOUBLE:
-		PUSHD (rvalue);
+		PUSHD (rvalue.d);
 		break;

 	      case FFI_TYPE_SINT64:
-		PUSHL (*(jlong*)&rvalue);
+		PUSHL (rvalue.l);
 		break;

 	      default:
@@ -2350,7 +2357,24 @@ _Jv_InterpMethod::run (void *retp, ffi_r
       return;

     insn_ireturn:
-      *(jint *) retp = POPI ();
+      switch (cif->rtype->type)
+	{
+	case FFI_TYPE_SINT8:
+	  *(jbyte *) retp = POPI ();
+	  break;
+
+	case FFI_TYPE_SINT16:
+	  *(jshort *) retp = POPI ();
+	  break;
+
+	case FFI_TYPE_UINT16:
+	  *(jchar *) retp = POPI ();
+	  break;
+
+	default:
+	  *(jint *) retp = POPI ();
+	  break;
+	}
       return;

     insn_return:
Index: include/java-interp.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/java-interp.h,v
retrieving revision 1.17
diff -u -p -r1.17 java-interp.h
--- include/java-interp.h	24 Jun 2002 20:38:46 -0000	1.17
+++ include/java-interp.h	19 Jul 2002 20:50:23 -0000
@@ -131,7 +131,7 @@ class _Jv_InterpMethod : public _Jv_Meth
   static void run_synch_object (ffi_cif*, void*, ffi_raw*, void*);
   static void run_synch_class (ffi_cif*, void*, ffi_raw*, void*);

-  void run (void*, ffi_raw *);
+  void run (ffi_cif*, void*, ffi_raw *);

  public:
   static void dump_object(jobject o);




More information about the Java-patches mailing list