[PATCH] PR java/71917

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] PR java/71917

Matthew Fortune
Hi,

Although libjava is currently on death row, here is a patch to
(correctly) fix mips64el in the java interpreter. This restores
sparc64 BE java support based on the report[1] that reverting my
original patch fixes the bug (I have not rerun this on spark64
BE as we are back to the original code for that platform now).

I'd like to get this committed before libjava is deleted if
possible so it is in a working state for future reference.

Tested with x86_64-pc-linux-gnu and mips64el-linux-gnu

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71917#c11

Thanks,
Matthew

libffi/
        PR java/71917
        * src/java_raw_api.c (ffi_java_raw_to_rvalue): Add casts for
        little endian 64-bit ABIs to widen 32-bit types to 64-bit.

libjava/
        PR java/71917
        * interpret-run.cc: Do not use ffi_arg for FFI integer return
        types as this code uses the 'native' FFI interface.
---
 libffi/src/java_raw_api.c | 10 +++++++++-
 libjava/interpret-run.cc  |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libffi/src/java_raw_api.c b/libffi/src/java_raw_api.c
index 127123d..578bd7c 100644
--- a/libffi/src/java_raw_api.c
+++ b/libffi/src/java_raw_api.c
@@ -277,20 +277,28 @@ ffi_java_rvalue_to_raw (ffi_cif *cif, void *rvalue)
 static void
 ffi_java_raw_to_rvalue (ffi_cif *cif, void *rvalue)
 {
-#if WORDS_BIGENDIAN && FFI_SIZEOF_ARG == 8
+#if FFI_SIZEOF_ARG == 8
   switch (cif->rtype->type)
     {
     case FFI_TYPE_UINT8:
     case FFI_TYPE_UINT16:
     case FFI_TYPE_UINT32:
+# if WORDS_BIGENDIAN
       *(UINT64 *)rvalue >>= 32;
+# else
+      *(ffi_arg *)rvalue = *(UINT32 *)rvalue;
+# endif
       break;
 
     case FFI_TYPE_SINT8:
     case FFI_TYPE_SINT16:
     case FFI_TYPE_SINT32:
     case FFI_TYPE_INT:
+# if WORDS_BIGENDIAN
       *(SINT64 *)rvalue >>= 32;
+# else
+      *(ffi_arg *)rvalue = *(SINT32 *)rvalue;
+# endif
       break;
 
     case FFI_TYPE_COMPLEX:
diff --git a/libjava/interpret-run.cc b/libjava/interpret-run.cc
index 6be354e..a4c2d4d 100644
--- a/libjava/interpret-run.cc
+++ b/libjava/interpret-run.cc
@@ -1838,7 +1838,7 @@ details.  */
       return;
 
     insn_ireturn:
-      *(ffi_arg *) retp = POPI ();
+      *(jint *) retp = POPI ();
       return;
 
     insn_return:
--
2.4.1

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] PR java/71917

Andrew Haley
On 09/09/16 13:44, Matthew Fortune wrote:
> I'd like to get this committed before libjava is deleted if
> possible so it is in a working state for future reference.

Sure, OK.

Andrew.