public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR java/71917
@ 2016-09-09 12:45 Matthew Fortune
  2016-09-09 13:31 ` Andrew Haley
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Fortune @ 2016-09-09 12:45 UTC (permalink / raw)
  To: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org),
	java-patches
  Cc: Tom Tromey

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-09 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09 12:45 [PATCH] PR java/71917 Matthew Fortune
2016-09-09 13:31 ` Andrew Haley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).