From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id C83863856DF1 for ; Sat, 28 May 2022 13:40:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C83863856DF1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=moxielogic.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=moxielogic.com Received: by mail-ej1-x62f.google.com with SMTP id wh22so13357471ejb.7 for ; Sat, 28 May 2022 06:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxielogic-com.20210112.gappssmtp.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=ya8xAX9sL1BDUSVikV3z5zf5Shte0QCkJepelUoy8FE=; b=d/n0EcTDtYWionC6jCIUq6Qp9Lqw869Oo4Y+KRt402hOTMe/SiCQy9O8Eii7K1byjo 1tJHPnFK/DVhHUPcBJyKRyfL9Rd/X70GXq9X6dWRl29HDch0eG+kEgapeKMwvy0nAXAU 2pTVzCDs1EvTiY12f8Nag/DN8r82c2Y+xzMbPeFgmdsJCClMbrAQcJm+qtiH2PWJ60CW MxiXiBlZBJVxsd3+vXTzsAJBA4cUQIOQHbuEyXOyulc6dXNpVUXUnntcTGF/PZNKVvgp mcE7OT7sollOLJ7Dhmw954GLjNiu7GSuqiZ5/MgeYU9eSDua9Ii3s9NgYzrKzAghzD6E oq0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ya8xAX9sL1BDUSVikV3z5zf5Shte0QCkJepelUoy8FE=; b=RCFAN2F1KbPY+vur8fcWwOy7i57OGDfgWg91fJ7I6is93rNGrKtwqiNtWwpn8ZQjVb HB0FW1xL3Voxaifso62hebLVC9HpxAjlKuVe1YNiYSdePQGfZvRUqjr5vm8oiTfE79ZO z4w1elsZQ+Umowq/CxzoU9QzT40J7eibRfYVlXqqZVidc4RsHPLwItTt6FelQcUYrMkZ uYi0FklrRuqgPbPW/VCvaH/EDabRtQmzLjyoR/SsNQkLidt+l564I6CJymfpJWXDL3e+ 6IYzfaa33Js0vAU6ty//fWoa1n3w/nAqKNNmm4ZF/TewycAMDNcgiwtZL8yf3L8JPAKK TYqw== X-Gm-Message-State: AOAM5317zd+td0xr3eVRZQbmgMq6lqcSy2XGOUh0HAQlFgZ3u1kTLEKP cKc4YYI/UfKJbE/9lkDy/UGLNuLMh79SBbaN52T5KnFA7y1ntQ== X-Google-Smtp-Source: ABdhPJxwvna2hjORe7z46blGPn6S1lbx6WpK+P3Z+nuF6IcAlkF82DuwN1U1T450xGSvdpRrAkWpfrdYQyU/WvmCF4I= X-Received: by 2002:a17:907:1c81:b0:6ff:335d:a0f7 with SMTP id nb1-20020a1709071c8100b006ff335da0f7mr7412687ejc.182.1653745226188; Sat, 28 May 2022 06:40:26 -0700 (PDT) MIME-Version: 1.0 From: Anthony Green Date: Sat, 28 May 2022 09:40:15 -0400 Message-ID: Subject: Change in libffi behaviour -- large struct args To: libffi-discuss Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libffi-discuss@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libffi-discuss mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 May 2022 13:40:29 -0000 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