From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
To: "Uecker, Martin" <Martin.Uecker@med.uni-goettingen.de>,
"msebor@gmail.com" <msebor@gmail.com>,
"law@redhat.com" <law@redhat.com>,
"joseph@codesourcery.com" <joseph@codesourcery.com>
Cc: nd <nd@arm.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"ebotcazou@adacore.com" <ebotcazou@adacore.com>,
Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Subject: Re: [PATCH v4][C][ADA] use function descriptors instead of trampolines in C
Date: Mon, 17 Dec 2018 19:24:00 -0000 [thread overview]
Message-ID: <da4263fd-9b70-7bd8-f662-e12a335dc4a7@arm.com> (raw)
In-Reply-To: <1545070952.3328.5.camel@med.uni-goettingen.de>
On 17/12/2018 18:22, Uecker, Martin wrote:
> Am Montag, den 17.12.2018, 15:25 +0000 schrieb Szabolcs Nagy:
>> On 16/12/2018 22:45, Uecker, Martin wrote:
>>> Am Sonntag, den 16.12.2018, 09:13 -0700 schrieb Jeff Law:
>>>> Ultimately using function descriptors is an ABI breaking choice and we
>>>> might declare that function descriptors imply higher function
>>>> alignments.
>>>
>>> Increasing the alignment is not an ABI breaking change.
>>
>> increasing alignment _requirement_ is an abi breaking change.
>
> You are right. The idea was to increase the minimum alignment
> to always be compatible with code compiled with
> "-fno-trampolines" but without actually requiring the
> alignment for other code as long as "-fno-trampolines"
> is not given.
>
>
>> and it's not clear who would benefit from the new abi:
>>
>> - it affects everything that does indirect calls (if alignment
>> requirement is increased then in addition everything that has
>> functions whose address may be taken), so it can easily affect
>> existing handwritten asm and it definitely requires the rebuild
>> of the c runtime to support this abi (i think it even requires
>> asm changes there if you allow a thread or makecontext start
>> function to be a nested function).
>>
>> - it makes indirect calls more expensive everywhere, even if
>> nested functions are not used.
>
> Yes, transition to "-fno-trampolines" by default would be a
> major undertaking and the cost for
> indirect calls might not
> be acceptable. I was not proposing this.
>
>> i think to fix the executable stack problem in practice, the
>> new nested function mechanism should only require the rebuild
>> of code that actually contains nested functions and thus have
>> no abi or performance impact on code that never uses them.
>
> My use case is to activate '-fno-trampolines' for some
> project which use nested functions internally. This works
> just fine with existing code because 1) no pointers to nested
> functions escape 2) the default alignment on the existing
> code is high enough.
>
> This is a practical fix, but only when you are careful and
> activate on a case by case. Of course, it is not a full solution
> to the general problem.
i see.
i think that's not a common use-case.
i'd expect nested function pointers to often escape
(as callbacks to extern library function calls).
>> i believe this can be achieved by some restrictions on nested
>> function usage in a way that covers most practical use-cases:
>> e.g. only allowing one active parent function call frame per
>> thread, no recursive calls to it, the nested function must be
>> invoked in the same thread as the parent using the same stack,
>> etc. (then the new mechanism can be used safely if nested
>> functions are known to follow the restrictions, the compiler
>> may even emit code to check the constraints at runtime.)
>
> So a thread_local static variable for storing the static
> chain?
something like that, but the more i think about it the
harder it seems: the call site of the nested function
may not be under control of the nested function writer,
in particular the nested function may be called on a
different thread, and extern library apis are unlikely
to provide guarantees about this, so in general if a
nested function escapes into an extern library then
this cannot be relied on, which limits my original
idea again to cases where there is no escape (which i
think is not that useful).
next prev parent reply other threads:[~2018-12-17 19:24 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-11 16:41 [RFC] [PATCH][C][ADA] " Uecker, Martin
2018-08-18 16:33 ` Uecker, Martin
2018-08-20 14:07 ` [PATCH v2][C][ADA] " Uecker, Martin
2018-08-20 22:35 ` Joseph Myers
2018-08-21 6:17 ` Uecker, Martin
2018-08-21 21:34 ` Joseph Myers
2018-08-22 6:09 ` Uecker, Martin
2018-08-22 15:49 ` Joseph Myers
2018-11-04 20:49 ` [PATCH v3][C][ADA] " Uecker, Martin
2018-12-03 10:29 ` Uecker, Martin
2018-12-03 21:56 ` Jeff Law
2018-12-12 18:12 ` [PATCH v4][C][ADA] " Uecker, Martin
2018-12-13 23:35 ` Jeff Law
2018-12-14 10:05 ` Uecker, Martin
2018-12-14 23:36 ` Jeff Law
2018-12-15 1:20 ` Martin Sebor
2018-12-16 13:46 ` Uecker, Martin
2018-12-16 16:13 ` Jeff Law
2018-12-16 22:46 ` Uecker, Martin
2018-12-17 15:26 ` Szabolcs Nagy
2018-12-17 18:22 ` Uecker, Martin
2018-12-17 19:24 ` Szabolcs Nagy [this message]
2018-12-18 15:23 ` Paul Koning
2018-12-18 15:32 ` Jakub Jelinek
2018-12-18 16:03 ` Jeff Law
2018-12-18 16:25 ` Jakub Jelinek
2018-12-18 16:29 ` Uecker, Martin
2018-12-18 16:33 ` Uecker, Martin
2018-12-18 16:42 ` Jakub Jelinek
2018-12-19 19:53 ` Uecker, Martin
2018-12-19 20:08 ` Jakub Jelinek
2018-12-19 21:28 ` Wilco Dijkstra
2018-12-21 21:41 ` Hans-Peter Nilsson
2018-12-21 22:07 ` Uecker, Martin
2018-12-20 13:29 ` Wilco Dijkstra
2018-12-18 16:27 ` Uecker, Martin
2018-12-17 17:29 ` Jeff Law
2018-12-17 18:07 ` Uecker, Martin
2018-12-17 18:41 ` Andreas Schwab
2018-12-21 8:03 ` [PATCH v5][C][ADA] " Uecker, Martin
2019-01-13 21:19 ` [PING] " Uecker, Martin
2019-01-14 20:16 ` Jeff Law
2019-06-24 21:35 ` [PATCH v6][C][ADA] " Uecker, Martin
2019-08-09 23:42 ` Jeff Law
2019-08-10 10:16 ` Uecker, Martin
2018-12-19 19:11 ` [PATCH v4][C][ADA] " Uecker, Martin
2018-12-17 17:31 ` Martin Sebor
2018-12-17 18:09 ` Uecker, Martin
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=da4263fd-9b70-7bd8-f662-e12a335dc4a7@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=Martin.Uecker@med.uni-goettingen.de \
--cc=Wilco.Dijkstra@arm.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=law@redhat.com \
--cc=msebor@gmail.com \
--cc=nd@arm.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).