public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: <dancol@dancol.org>
To: Anthony Green <green@moxielogic.com>,
	"libffi-discuss" <libffi-discuss@sourceware.org>
Subject: Re: Change in libffi behaviour -- large struct args
Date: Sat, 28 May 2022 11:38:01 -0400	[thread overview]
Message-ID: <1810b5137a8.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org> (raw)
In-Reply-To: <CACxje5_m_6U0UyQYeo7p6+TRtybAE7LdovUUTvP6yGH0QV6YEw@mail.gmail.com>

On May 28, 2022 09:40:34 Anthony Green <green@moxielogic.com> wrote:

> As has been discussed in various github PRs recently, I'd like to
> change libffi's behaviour regarding large struct arguments.
>
> When passing a struct by value, most (all?) ABI definitions ask that
> you try to fit structs up to a certain size into registers, and if
> they are too large, make a copy and pass them on the stack.
> Libffi's current behaviour is to fit small structs in registers, but
> then if something is too large, pass it by reference, leaving it as an
> exercise for the user to make their own copies.   Many libffi users,
> like cpython, do this special work themselves.   I don't like this
> because it exposes this ABI detail, the threshold for struct sizes, to
> the libffi caller.   Libffi should be making this copy itself.
>
> The struct_by_value_big.c test checks for this, and most ports fail
> today   Changing this behaviour won't introduce regressions for libffi
> users, and eventually they will be able to remove their special
> handling of large struct args.
>
> AG

How might this change interact with, say, C++ types tagged with 
clang::trivial_abi? Not all types are trivially memcpy-moveable, sadly.


  reply	other threads:[~2022-05-28 15:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-28 13:40 Anthony Green
2022-05-28 15:38 ` dancol [this message]
2022-05-28 15:50   ` Anthony Green
2022-05-29 14:09 ` Anthony Green
2022-05-31 15:53 ` DJ Delorie
2022-05-31 16:47   ` dancol
2022-05-31 16:55     ` Kaz Kylheku
2022-05-31 18:59   ` Anthony Green
2022-05-31 23:16     ` DJ Delorie

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=1810b5137a8.2829.cc5b3318d7e9908e2c46732289705cb0@dancol.org \
    --to=dancol@dancol.org \
    --cc=green@moxielogic.com \
    --cc=libffi-discuss@sourceware.org \
    /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).