public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Martin Uecker <ma.uecker@gmail.com>
Cc: Martin Uecker via Libffi-discuss <libffi-discuss@sourceware.org>,
	Anthony Green <green@moxielogic.com>
Subject: Re: wide function pointer type
Date: Tue, 19 Oct 2021 11:22:57 +0200	[thread overview]
Message-ID: <87bl3lgyha.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <8d2ddbb76479ce3ad7f99acb3f0b79a6a8d1440b.camel@gmail.com> (Martin Uecker's message of "Mon, 18 Oct 2021 09:56:14 +0200")

* Martin Uecker:

> Am Montag, den 18.10.2021, 09:36 +0200 schrieb Florian Weimer:
>> * Martin Uecker via Libffi-discuss:
>> 
>> > In particular, I would be good to know whether
>> > implementing a perfectly forwarding stub for
>> > a variadic functions that loads the static
>> > is possible on all architectures. I assume so,
>> > but I am not entirely sure.
>> 
>> Are you asking if it is possible to consume an argument in a variadic
>> wrapper and forward the remaining arguments to a variadic function?  The
>> answer to that is no.
>
> Yes, I assumed this does not work. The question 
> is more whether architectures exist where the
> existing ABI states that the static chain has to be
> passed as a first argument (which would then need to be
> removed when calling a regular function).
>
> The implementation most architectures
> would use is that 1) the static chain is loaded from
> the wide pointer 2) stored in the designated register
> or stack slot and then 3) a call is performed
> using the same calling convention as used for
> regular functions.

Many ABIs do not actually specify a register for the chain pointer.  For
GCC's nested function extension, there are no ABI concerns because the
nested function definition and the thunk generation are always built
from the same translation unit.  So GCC can just pick a custom calling
convention, similar to what it does for other local, non-escaping
functions.

For obvious reasons, the proposal does not achieve interoperability with
std::function from C++, so there is no ABI concern, either.

Thanks,
Florian


  reply	other threads:[~2021-10-19  9:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-10 11:32 Martin Uecker
2021-10-17 23:35 ` Anthony Green
2021-10-18  5:33   ` Martin Uecker
2021-10-18  5:58     ` Martin Uecker
2021-10-18  7:36       ` Florian Weimer
2021-10-18  7:56         ` Martin Uecker
2021-10-19  9:22           ` Florian Weimer [this message]
2021-10-19  9:43             ` Martin Uecker
2021-10-19 10:15               ` Florian Weimer
2021-10-19 12:13                 ` Martin Uecker
2021-10-20  8:24                   ` Kaz Kylheku (libffi)
2021-10-20 18:52                     ` Martin Uecker
2021-10-20  9:10                   ` Florian Weimer
2021-10-20  9:21                     ` Martin Uecker
2021-10-20  9:27                       ` Florian Weimer
2021-10-20 17:27                     ` Kaz Kylheku (libffi)
2021-10-21  9:48                       ` Florian Weimer
2021-10-10 17:01 Kaz Kylheku (libffi)
2021-10-10 17:44 ` Martin Uecker
2021-10-10 17:49   ` Daniel Colascione
2021-10-10 18:05     ` Martin Uecker
2021-10-10 18:17       ` Daniel Colascione
2021-10-10 18:47         ` Martin Uecker
2021-10-10 18:57           ` Daniel Colascione
2021-10-10 19:24             ` Martin Uecker
2021-10-16  8:08               ` Jarkko Hietaniemi
2021-10-16  9:35                 ` Jarkko Hietaniemi
2021-10-10 18:31   ` Kaz Kylheku (libffi)

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=87bl3lgyha.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=green@moxielogic.com \
    --cc=libffi-discuss@sourceware.org \
    --cc=ma.uecker@gmail.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).