From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96366 invoked by alias); 28 Jun 2016 15:30:22 -0000 Mailing-List: contact java-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-patches-owner@gcc.gnu.org Received: (qmail 96318 invoked by uid 89); 28 Jun 2016 15:30:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2359 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Jun 2016 15:30:01 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 851CB96F48B14; Tue, 28 Jun 2016 16:29:54 +0100 (IST) Received: from HHMAIL01.hh.imgtec.org ([fe80::710b:f219:72bc:e0b3]) by hhmail02.hh.imgtec.org ([fe80::5400:d33e:81a4:f775%25]) with mapi id 14.03.0294.000; Tue, 28 Jun 2016 16:29:58 +0100 From: Matthew Fortune To: Tom Tromey CC: "java-patches@gcc.gnu.org" , "'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)" , "per@bothner.com" , "aph@redhat.com" , Aurelien Jarno Subject: RE: [PATCH] Fix FFI return type for closures in the java interpreter Date: Tue, 28 Jun 2016 15:30:00 -0000 Message-ID: <6D39441BF12EF246A7ABCE6654B023537E46241B@HHMAIL01.hh.imgtec.org> References: <6D39441BF12EF246A7ABCE6654B023537E45FD9F@HHMAIL01.hh.imgtec.org> <87shvyib1n.fsf@tromey.com> <8760stviqj.fsf@tromey.com> In-Reply-To: <8760stviqj.fsf@tromey.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2016-q2/txt/msg00027.txt.bz2 Tom Tromey writes: > >>>>> "Matthew" =3D=3D Matthew Fortune write= s: > Matthew> I've identified a latent bug in the java interpreter that affect= s MIPS > Matthew> n32 and n64 ABIs both little and big endian and, I presume, any = 64-bit > Matthew> big endian target with int as 32-bit. > [...] >=20 > Matthew> libjava/ > Matthew> * interpret-run.cc: Use ffi_arg for FFI integer return types. > Matthew> libjava/testsuite/ > Matthew> * libjava.jar/arraysort.java: New file. > Matthew> * libjava.jar/arraysort.jar: New file. > Matthew> * libjava.jar/arraysort.out: New file. > Matthew> * libjava.jar/arraysort.xfail: New file. >=20 > Tom> This is ok. >=20 > It occurred to me that this might not be correct on platforms using the > Java raw API; which I think is just x86. >=20 > I'm actually not sure -- I don't remember (if I ever knew) if the raw > API has the same return-value promotion rules as the ordinary API. >=20 > Could you check? I think a -m32 build ought to show it. Maybe your > x86-64 build already did this? I'm not sure this will matter if the only arch is x86 as ffi_arg will be 32-bit anyway there. There would need to be a 64bit arch using the raw api. I don't really understand what the raw api is, the references to it in the code seemed cryptic. I can do a -m32 test anyway, I only did x86_64 as I don't think that 32-bit architectures will be affected at all. > Matthew> I mentioned in my earlier post about a possible similar issue in= the > Matthew> lang/reflect/natVMProxy.cc code (unbox function) by code inspect= ion. I > Matthew> don't know how to trigger this code but perhaps someone can advi= se. > > It's a bit complicated, and it's been a while since I looked at any of > this, but I think what you want to do is make an InvocationHandler that > handles some method returning "int" (maybe hashCode would work), then > make a Proxy class that wraps it. Then, make an instance of the proxy > class and call the method. Thanks for the pointers, a bit of googling got me to the right code. I can confirm that my guess was right and the same bug exists in the natVMProxy.cc code. It will break for all big endian targets when using types smaller than a word. I have only proved the bug exists so far but not tried a fix. Thanks, Matthew