From patchwork Fri Sep 9 12:44:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Fortune X-Patchwork-Id: 668010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sVxkJ15vfz9sBg for ; Fri, 9 Sep 2016 22:45:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=pdBRJC1O; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=siR Oe6OsYviOXuNfzklECa3o81z9Gxad1ijhnx8Q7KRfo2UP2Z/5gQtyIm2+qPYv6V9 VXKwvWjwJBiIihl0yd5QRwmtTcO7Uo6+p+cNPgM/hcbtKaKFigujeaUSFvj+yFdv 4HlslCE/rxgRSUCD2qseYix0ggpwthPEFZoh/QyQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=724gzxhUp sNVWzkPzcfYHEPRK8U=; b=pdBRJC1OMkEfo7HkIik1JK1Kh+AS3noRS+/TpOWu0 lkZ+mRjZmt4AiFZWH/A9Wvx9wEQpe02bjuuzKBi8J5RRL6duWZ3N+34VoBoyUeLy gAs3jTBtQ2mbW36yB/oqagd7vtlo+2FAj0C8igbuORgdVnYqeaFDxnuKUUFe97Zn KE= Received: (qmail 42633 invoked by alias); 9 Sep 2016 12:45:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 42596 invoked by uid 89); 9 Sep 2016 12:45:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=cif, death 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; Fri, 09 Sep 2016 12:44:50 +0000 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 2C038B2839B87; Fri, 9 Sep 2016 13:44:34 +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; Fri, 9 Sep 2016 13:44:36 +0100 From: Matthew Fortune To: "'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org)" , "java-patches@gcc.gnu.org" CC: Tom Tromey Subject: [PATCH] PR java/71917 Date: Fri, 9 Sep 2016 12:44:36 +0000 Message-ID: <6D39441BF12EF246A7ABCE6654B023537E4F12B3@HHMAIL01.hh.imgtec.org> MIME-Version: 1.0 X-IsSubscribed: yes 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: