public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matthew Fortune <Matthew.Fortune@imgtec.com>
To: "java-patches@gcc.gnu.org" <java-patches@gcc.gnu.org>,
	"'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)"
	<gcc-patches@gcc.gnu.org>
Cc: "tromey@redhat.com" <tromey@redhat.com>,
	"per@bothner.com"	<per@bothner.com>,
	"aph@redhat.com" <aph@redhat.com>,
	Aurelien Jarno	<aurelien@aurel32.net>
Subject: [PATCH] Fix FFI return type for closures in the java interpreter
Date: Mon, 27 Jun 2016 20:17:00 -0000	[thread overview]
Message-ID: <6D39441BF12EF246A7ABCE6654B023537E45FD9F@HHMAIL01.hh.imgtec.org> (raw)

Hi,

I've identified a latent bug in the java interpreter that affects MIPS
n32 and n64 ABIs both little and big endian and, I presume, any 64-bit
big endian target with int as 32-bit.

A full description is in my original post:

https://gcc.gnu.org/ml/java-patches/2016-q2/msg00020.html

Patch tested on x86_64-pc-linux-gnu where the new testcase works both
before and after with no regressions. Also tested on mips64el-linux-gnu
where the test fails before and works after with no regressions.

Aurelien provided the test case and I tried to follow an existing test
to integrate it. Let me know if there is anything else I need to do.

I mentioned in my earlier post about a possible similar issue in the
lang/reflect/natVMProxy.cc code (unbox function) by code inspection. I
don't know how to trigger this code but perhaps someone can advise.

OK to commit?

Thanks,
Matthew

libjava/

	* interpret-run.cc: Use ffi_arg for FFI integer return types.

libjava/testsuite/

	* libjava.jar/arraysort.java: New file.
	* libjava.jar/arraysort.jar: New file.
	* libjava.jar/arraysort.out: New file.
	* libjava.jar/arraysort.xfail: New file.
---
 libjava/interpret-run.cc                      |   2 +-
 libjava/testsuite/libjava.jar/arraysort.jar   | Bin 0 -> 1864 bytes
 libjava/testsuite/libjava.jar/arraysort.java  |  44 ++++++++++++++++++++++++++
 libjava/testsuite/libjava.jar/arraysort.out   |  10 ++++++
 libjava/testsuite/libjava.jar/arraysort.xfail |   1 +
 5 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 libjava/testsuite/libjava.jar/arraysort.jar
 create mode 100644 libjava/testsuite/libjava.jar/arraysort.java
 create mode 100644 libjava/testsuite/libjava.jar/arraysort.out
 create mode 100644 libjava/testsuite/libjava.jar/arraysort.xfail

diff --git a/libjava/interpret-run.cc b/libjava/interpret-run.cc
index a4c2d4d..6be354e 100644
--- a/libjava/interpret-run.cc
+++ b/libjava/interpret-run.cc
@@ -1838,7 +1838,7 @@ details.  */
       return;
 
     insn_ireturn:
-      *(jint *) retp = POPI ();
+      *(ffi_arg *) retp = POPI ();
       return;
 
     insn_return:
diff --git a/libjava/testsuite/libjava.jar/arraysort.jar b/libjava/testsuite/libjava.jar/arraysort.jar
new file mode 100644
index 0000000000000000000000000000000000000000..ee051e45a836f99563e3e15ce748795d01e87e4e
GIT binary patch
literal 1864
zcmWIWW@h1H00Eo28y;W=l;C8LVeoYgan$wnbJGtE;bdT59F`k?28c^5xEUB(K+3>G
z0MG~#AcuqDY3&V<s1}nIrHl*=T}%uNf<Pk@i;5B}i}Q<0R1Ec!a}tY-!AAWH%?;m%
zX;f*Dum2$jfm(0wsh>hc|A-l0JQ1!kM^U9M!>OsNp&~w^S#_!D?W9NbpB}La^B>!6
zf679aMLA>g&6#s+KR<h$W5562J;soUmj#kK3N?RDe(mvo$tuTG1GhgD!*%lbwYTq`
z_@Y`$iRYz)^+%u8mr9QD#}u8P$TM+Q=Ipp;$CKjkB(5wo7O)aI^60{bV-vDwZ`(1m
zr`oBk^1KjFl)c9C7drR<WnTTbB$GdT^-L%4_C{Xb*ZY^8^?Q87WtO7V^EXyJGwma|
z*DlT5+<i67xX!%ot%Z<>(F@shrQeTEeQ8w}Z?^h=dPVkenOk>e|0rMi-+iCS#$T&;
zxb+?@$^5Q+eCgY*AKuMvY}5IuFJ*KjdYf*_<wxtZW1e^{b`o1w9&#e%%9ie+5}$b!
z`NiWG?hkNSy5$wePtO$x4e#dioe#RF-ZAA=@RE7rKRg^3Ns70eJ+pCn%a@IvN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K(GPB#zn~+t5&`wfh}kDf8@iTQWG`8GK|%<P}hH
z`7P2pDFImWr2w%Aa&hVF=;!I?8XThM>jp15TQQ3}(bI-p4F)_62ligDPYK!J$}aBC
zdhnoU0l(Bj1x*#fkKbQa6&M#;dFZZDnPpUd;mEDsjvT$;F4)^|+1QpOq7?Bd(VXkx
z4E=i-_XQq260Ng$wqc=!U&vbq*AEwUp3N=S5AbGWl4HhIyh{LG4FUoTZyiB2Qen>u
zDeN%{dXRCrih7uF3=B&eoq@(-DfofLf(m{D#-f%$$i^}Q%O$w6u=0qop_owxF%(!!
f0o|(4isW^ah{F{MtZbm*VgbTXpb>Y0`WYAikEqBO

literal 0
HcmV?d00001

diff --git a/libjava/testsuite/libjava.jar/arraysort.java b/libjava/testsuite/libjava.jar/arraysort.java
new file mode 100644
index 0000000..56c181d
--- /dev/null
+++ b/libjava/testsuite/libjava.jar/arraysort.java
@@ -0,0 +1,44 @@
+import java.util.Arrays;
+import java.util.Comparator;
+
+public class arraysort
+{
+  private static final Comparator<String> STRING_COMPARATOR = new Comparator<String>()
+  {
+    public int compare(String str1, String str2)
+    {
+      return str1.compareTo(str2);
+    }
+  };
+
+  static void dumpArray(String[] strings)
+  {
+    int i;
+
+    for (i = 0 ; i < strings.length ; i++)
+    {
+      System.out.println("[" + i + "] " + strings[i]);
+    }
+  }
+
+  public static void main(String[] args)
+  {
+    String[] strings;
+
+    strings = new String[4];
+
+    strings[0] = "a";
+    strings[1] = "c";
+    strings[2] = "b";
+    strings[3] = "d";
+
+    System.out.println("Array of string, before:");
+    dumpArray(strings);
+
+    Arrays.sort(strings, STRING_COMPARATOR);
+
+    System.out.println("Array of string, after:");
+    dumpArray(strings);
+  }
+}
+
diff --git a/libjava/testsuite/libjava.jar/arraysort.out b/libjava/testsuite/libjava.jar/arraysort.out
new file mode 100644
index 0000000..938ce9f
--- /dev/null
+++ b/libjava/testsuite/libjava.jar/arraysort.out
@@ -0,0 +1,10 @@
+Array of string, before:
+[0] a
+[1] c
+[2] b
+[3] d
+Array of string, after:
+[0] a
+[1] b
+[2] c
+[3] d
diff --git a/libjava/testsuite/libjava.jar/arraysort.xfail b/libjava/testsuite/libjava.jar/arraysort.xfail
new file mode 100644
index 0000000..2bbbe56
--- /dev/null
+++ b/libjava/testsuite/libjava.jar/arraysort.xfail
@@ -0,0 +1 @@
+main=arraysort
-- 
2.4.1

             reply	other threads:[~2016-06-27 20:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 20:17 Matthew Fortune [this message]
2016-06-27 21:20 ` Tom Tromey
2016-06-28  8:08   ` Tom Tromey
2016-06-28 15:30     ` Matthew Fortune
2016-06-28 21:22       ` Tom Tromey
2016-07-12 10:20         ` Matthew Fortune
2016-07-12 16:32           ` Tom Tromey
2016-07-13 21:36             ` Matthew Fortune

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6D39441BF12EF246A7ABCE6654B023537E45FD9F@HHMAIL01.hh.imgtec.org \
    --to=matthew.fortune@imgtec.com \
    --cc=aph@redhat.com \
    --cc=aurelien@aurel32.net \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=java-patches@gcc.gnu.org \
    --cc=per@bothner.com \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).