From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 72300 invoked by alias); 19 Dec 2018 21:28:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 72288 invoked by uid 89); 19 Dec 2018 21:28:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-AM5-obe.outbound.protection.outlook.com Received: from mail-eopbgr30069.outbound.protection.outlook.com (HELO EUR03-AM5-obe.outbound.protection.outlook.com) (40.107.3.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Dec 2018 21:28:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Ex1/bKL32FuxDKwAXFcuh/P/X8e+xJaCPokV7VR734=; b=USPscQVk+exfDZ8gkJcihSAjj/IAEKmpTg4XXJX99OJjakd1UkUbcSR9YHYY6iI88x/NjFMSUnMWphUBv4RygUWMVFMTs5R4sqnyvz9y1Jt15GR/XWMUWJ7Z13HAqJyaQ09+mpsRJiR1z1trS6SRxqz9Fz7SeR/A/4giM/0T/4E= Received: from DB5PR08MB1030.eurprd08.prod.outlook.com (10.166.14.15) by DB5PR08MB1158.eurprd08.prod.outlook.com (10.166.174.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 21:28:45 +0000 Received: from DB5PR08MB1030.eurprd08.prod.outlook.com ([fe80::d59d:34fb:3c03:241d]) by DB5PR08MB1030.eurprd08.prod.outlook.com ([fe80::d59d:34fb:3c03:241d%3]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 21:28:45 +0000 From: Wilco Dijkstra To: "Uecker, Martin" , Jakub Jelinek CC: nd , "paulkoning@comcast.net" , "law@redhat.com" , Szabolcs Nagy , "msebor@gmail.com" , "gcc-patches@gcc.gnu.org" , "ebotcazou@adacore.com" , "joseph@codesourcery.com" Subject: Re: [PATCH v4][C][ADA] use function descriptors instead of trampolines in C Date: Wed, 19 Dec 2018 21:28:00 -0000 Message-ID: References: <1545070952.3328.5.camel@med.uni-goettingen.de> <5896AE4C-D296-4FAF-A809-7BACA532BBF5@comcast.net> <20181218153209.GP23305@tucnak> <81804969-da3b-80b8-98d2-beb31cd19541@redhat.com> <20181218162440.GQ23305@tucnak> <1545150562.7930.4.camel@med.uni-goettingen.de> <1545150827.16327.1.camel@med.uni-goettingen.de> <20181218164212.GR23305@tucnak> <1545249228.21146.9.camel@med.uni-goettingen.de>,<20181219200801.GG23305@tucnak> In-Reply-To: <20181219200801.GG23305@tucnak> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2018-12/txt/msg01417.txt.bz2 Hi, Jakub Jelinek wrote: > On Wed, Dec 19, 2018 at 07:53:48PM +0000, Uecker, Martin wrote: >> What do you think about making the trampoline a single call >> instruction and have a large memory region which is the same >> page mapped many times? This sounds like a good idea, but given a function descriptor is 8-16 bytes it doesn't need to be 1 instruction. You can even go for larger sizes since all it affects is minimum alignment of function descriptors. >> The trampoline handler would pop the instruction pointer and use >> this as an index into the real stack to read the static chain and >> function pointer. > > While you save a few bytes per trampoline that way, it is heavily call-ret > stack unfriendly, so it will not be very fast. A repeated page adjacent to the stack is a good idea since it avoids adding runtime support to push/pop nested function addresses. That would be inefficient and likely very tricky for setjmp and exception handling (or leak memory). Since it can use several instructions we could load the static chain regist= er with the PC for example. On ISAs that don't support PC-relative addressing you could do a call/ret sequence to get the PC and then tailcall the helper to keep the return stack intact. If computing the difference between the stack and trampoline region takes just a few instructions (eg. thread local storage) then it could even be in= lined. Wilco=20 =20=20=20=20