From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18073 invoked by alias); 19 Dec 2014 16:15:10 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 18017 invoked by uid 89); 19 Dec 2014 16:15:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: e38.co.us.ibm.com Received: from e38.co.us.ibm.com (HELO e38.co.us.ibm.com) (32.97.110.159) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 19 Dec 2014 16:15:08 +0000 Received: from /spool/local by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 Dec 2014 09:15:06 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 Dec 2014 09:15:04 -0700 Received: from b03cxnp08028.gho.boulder.ibm.com (b03cxnp08028.gho.boulder.ibm.com [9.17.130.20]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 32EA019D8039 for ; Fri, 19 Dec 2014 09:03:43 -0700 (MST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBJGFQZG40042660 for ; Fri, 19 Dec 2014 09:15:26 -0700 Received: from d03av02.boulder.ibm.com (localhost [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBJGF1M0014060 for ; Fri, 19 Dec 2014 09:15:02 -0700 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d03av02.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id sBJGEwd3013748; Fri, 19 Dec 2014 09:14:59 -0700 Message-Id: <201412191614.sBJGEwd3013748@d03av02.boulder.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 19 Dec 2014 17:14:58 +0100 Subject: Re: [PATCH 0/4] s390 improvements To: rth@redhat.com (Richard Henderson) Date: Fri, 19 Dec 2014 16:15:00 -0000 From: "Ulrich Weigand" Cc: rth@twiddle.net (Richard Henderson), libffi-discuss@sourceware.org, Ulrich.Weigand@de.ibm.com, vogt@linux.vnet.ibm.com, krebbel@linux.vnet.ibm.com In-Reply-To: <5494452C.6010003@redhat.com> from "Richard Henderson" at Dec 19, 2014 09:33:00 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121916-0029-0000-0000-00000685CECB X-SW-Source: 2014/txt/msg00275.txt.bz2 Richard Henderson wrote: > The stack frame we install is created with alloca, and so we know for a fact > that ffi_call_int must be using a frame pointer to hold its own frame. Since > we do not adjust %r15 on the way out of ffi_call_SYSV, we leave the stack frame > chain intact. If there were another function for ffi_call_int to call after > ffi_call_SYSV (but there's not), the outgoing 160 byte save area would be present. Well, even in a function using a frame pointer, we still occasionally rely on %r15. One obvious case would be calling a function that needs an argument save area, after ffi_call_SYSV returned. (Or if we had another alloca etc.) Now, we can probably exclude all those cases by simply not using certain source-level features in ffi_call_int; that at least needs to be clearly documented in comments there. There is still the theoretical possibilty of a compiler introducing dependencies on %r15 that aren't obvious from the source. (One example: some ancient gcc 2.95 compilers would actually use the backchain value to restore %r15 on function return in some cases. These would now get the wrong value, since ffi_call_SYSV has installed a different backchain.) In the end, it's probably OK for low-level code like libffi to make certain assumptions on the behavior of the toolchain. I'm not quite sure whether this actually gets us any significant benefit in this case. Does it really matter whether ffi_prep_args is called from ffi_call_int vs. ffi_call_SYSV? > It's true that the load of %r15 is now a nop. It hadn't been at one point in > my development; ffi_prep_args had had more than 5 parameters, and so there was > extra stack allocated. I suppose if ffi_prep_args were inlined, one could be > certain of this (since there will be no function calls) and document it as such. If we do use such tricks, this version may actually be preferable. Bye, Ulrich -- Dr. Ulrich Weigand GNU/Linux compilers and toolchain Ulrich.Weigand@de.ibm.com