From nobody Wed May 8 22:16:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669140569; cv=none; d=zohomail.com; s=zohoarc; b=OGZS64xHfnd3nMyb6ZGUErrXFKxRtXUpgHtVXJmDKeaWeG+bQncDbGGisPVRjxAxVdBIlKbgRul003jpbMxsqAH6Q/UJQPeVvucK1UKASl1mRsMBqskp5tveW4RFOD5l+E3lDy/CEO5YRntQEF/bNGZ/CFzOooXIizSrLOxeZ9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669140569; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E1VeCUUpz9q7d7i8rzMvb3SuAwtDGii4hs3EGRg2C90=; b=BzETK1tahJHJWDk8gZQ0WGvToYIhNoAXry+dp9wpNscH8hPJeKQRU379SilAefgT9vj+xFuMiNhSbuNq6h0DEmPZ8ud/ss/P5OzDzPoLwZNxA3OpGuSKdv78PcH0eP0pSChqfzG38tWbHW6fGtlyBSuVS3ApUCtE7HfVh6IeTug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669140569674267.51839538424724; Tue, 22 Nov 2022 10:09:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxXh3-0001Nn-Hr; Tue, 22 Nov 2022 13:08:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxXgt-0001Lt-PC for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:16 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxXgr-0000LV-M8 for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:15 -0500 Received: by mail-wr1-x433.google.com with SMTP id i12so22077200wrb.0 for ; Tue, 22 Nov 2022 10:08:12 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c4ed100b003c701c12a17sm25628100wmq.12.2022.11.22.10.08.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Nov 2022 10:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E1VeCUUpz9q7d7i8rzMvb3SuAwtDGii4hs3EGRg2C90=; b=DpxCEhkSIb8K5aslytJCwB3KyoVf4/acuEOtEzTzW5UPlFoiTJXhjFzEUhB5LvDyiF wQqdOU3MuMVNvSVmF+hqtLk87hsuNkQOkRRvuOVXB/6FSHXNUwTZkkB5mdZHz9RHaXii Rbh+3Y9B92H8qZQ5kKn7o4TWv3QBPw+UCWLUK8arX+0RQ35bcTDIyk/Xs7qn42EjCvhX x8cK6Klszg0njDQIPmVaiSV+STA7zlcuCPrQOA/vLR6GujGP/BssvS9qN926IF63+PPE OmT4UPFZ0jLKjHxSXQazWktYHD/yqvdhsRViKfk/u1K7DsOnTUHBSODVXXl/zuhahhmT b4JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E1VeCUUpz9q7d7i8rzMvb3SuAwtDGii4hs3EGRg2C90=; b=AD2DJbiLOcaWKFUmoNzYWEN7yMqdZ5VOK5+MVnCZarZlYCZ5UtK7MeucwxNAFA0tvD bJ1ERJ1RjOMhOoWeMuSLHamv2xgPFXv2LhivOEeB2AebrSd0W/d7krIrPVMEuEchh5EH T2D17i0bL4STVBn+GPMhQHDrwrXmo3K7w5NN8Zm04PI0pOiRuUJQRyAaytqlu6PcoqpV TpwObOZn7q7SlNzfmVPcymoc0EJBh+1ImTg2oP0CvAYOLJ4g3+M47K0XULHAOvodguvj pX17dGveKn5tXcdEBCFFQtfJzaDAOQ3TI4EUu+o9szTvsxiN3IrVX1fHy6yMlvmv91cI NLwg== X-Gm-Message-State: ANoB5pkEFsfPvVxKZc4MffOxDEmptnHYOga6pGIwSA0s6KPYN7ON8cda /H2P5MDbKqILc8w5zDP9JDbeFqWHWUYK+g== X-Google-Smtp-Source: AA0mqf71i/kj0hr98Wt2XkrxebTegLiYd+L1gSCyj+bt+gHhRtWvmLfzvMp+t+T+s7pN/Q85xtJzxg== X-Received: by 2002:adf:cd86:0:b0:236:8a6d:72a1 with SMTP id q6-20020adfcd86000000b002368a6d72a1mr14576325wrj.682.1669140491138; Tue, 22 Nov 2022 10:08:11 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] tcg: Convert typecode_to_ffi from array to function Date: Tue, 22 Nov 2022 19:08:02 +0100 Message-Id: <20221122180804.938-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122180804.938-1-philmd@linaro.org> References: <20221111074101.2069454-27-richard.henderson@linaro.org> <20221122180804.938-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1669140571383100002 In the unlikely case of invalid typecode mask, the function will abort instead of returning a NULL pointer. Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index cabc397a38..8aa6fc9a25 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -554,14 +554,24 @@ static GHashTable *helper_table; #ifdef CONFIG_TCG_INTERPRETER static GHashTable *ffi_table; =20 -static ffi_type * const typecode_to_ffi[8] =3D { - [dh_typecode_void] =3D &ffi_type_void, - [dh_typecode_i32] =3D &ffi_type_uint32, - [dh_typecode_s32] =3D &ffi_type_sint32, - [dh_typecode_i64] =3D &ffi_type_uint64, - [dh_typecode_s64] =3D &ffi_type_sint64, - [dh_typecode_ptr] =3D &ffi_type_pointer, -}; +static ffi_type *typecode_to_ffi(int argmask) +{ + switch (argmask) { + case dh_typecode_void: + return &ffi_type_void; + case dh_typecode_i32: + return &ffi_type_uint32; + case dh_typecode_s32: + return &ffi_type_sint32; + case dh_typecode_i64: + return &ffi_type_uint64; + case dh_typecode_s64: + return &ffi_type_sint64; + case dh_typecode_ptr: + return &ffi_type_pointer; + } + g_assert_not_reached(); +} #endif =20 typedef struct TCGCumulativeArgs { @@ -764,14 +774,14 @@ static void tcg_context_init(unsigned max_cpus) nargs =3D DIV_ROUND_UP(nargs, 3); =20 ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype =3D typecode_to_ffi[typemask & 7]; + ca->cif.rtype =3D typecode_to_ffi(typemask & 7); ca->cif.nargs =3D nargs; =20 if (nargs !=3D 0) { ca->cif.arg_types =3D ca->args; for (int j =3D 0; j < nargs; ++j) { int typecode =3D extract32(typemask, (j + 1) * 3, 3); - ca->args[j] =3D typecode_to_ffi[typecode]; + ca->args[j] =3D typecode_to_ffi(typecode); } } =20 --=20 2.38.1 From nobody Wed May 8 22:16:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669140570; cv=none; d=zohomail.com; s=zohoarc; b=J0CdFpu+jd3QuPOeV3YRaQslUOBE9+MYSuSF7j7ZmoNIMpb/2sYDoN4rI+nPKOfs+QmNIbDKYmvb6trMxfPGDi6Jte/Hq9/Gnf4TN8eljHLpUb5fA0MXgANFje7QgTjN6FusHHZHViXSqE2m+gPMzB4i51JyFuUiiqVvEnGBAA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669140570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dxHXsv2E4iYr9vm2mCwNgEjbUPevhHxvL9iTZPxK6ik=; b=jjbwMn0VYvYaDlaAb/ikyFerhOjOkRfyIJabXV8qq+eUF8IIbb/GD8y0BXUeyImpOfaeJk3xTSTnPlBBWGka0UTqPwxrz3vtz0DBVn18+9rXnk3NkcuMWwsWtKZ9L1Rn7om2spZpPN5cKykNVryqoa5VO8uuTUEt1wGqUl7Zd9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669140570083301.5876894944338; Tue, 22 Nov 2022 10:09:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxXh4-0001Rb-Ev; Tue, 22 Nov 2022 13:08:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxXgy-0001N3-4I for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:21 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxXgw-0000MY-Ev for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:19 -0500 Received: by mail-wm1-x329.google.com with SMTP id t4so11301593wmj.5 for ; Tue, 22 Nov 2022 10:08:18 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id q2-20020adffec2000000b00241d544c9b1sm7758916wrs.90.2022.11.22.10.08.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Nov 2022 10:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dxHXsv2E4iYr9vm2mCwNgEjbUPevhHxvL9iTZPxK6ik=; b=J36gG8+li/1U5SvhnXHxVbbqoz7dwjLfSuNtG2kwOYFhixDNle0ehgtiNXgWjZZrH+ fEF+F7Ndtz/Oa94AM8b8Ulbo3ppe+xt5TpuSm7Sgqf4pWnxyAEW+kasAKbzBmj6Mbqm/ hY326979HKVHTs+T0Ww+VUaNXAt0Xnv1nB+O4g7kv05jp50XmA2GJ1Y0LbI8St6d+Q5W dciKyXQHR4oHJis8r5PTp8HKsj1y7uUKaFCTKog5Ljz4i1Q5Ean2mJe/vwMG0me0gj5u nC5aOWoh60zNGJTwh9zra7FR9nVi5RWrlfq5tXHHY91cAJIENtXVdKb03t57JWDTxCcR gTWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dxHXsv2E4iYr9vm2mCwNgEjbUPevhHxvL9iTZPxK6ik=; b=kGRlKB341ckKh7sQvG53Gcs5WzPVn23G2BAeb06l5r+LF9ycAr3I87WZP2LaFXHEki 3XkgC5+hf/KU99QSRoeoG/K0I2Iq60NTGkRtKtxfctSrdntZxGdQno9PlyD4OhokOKFB KwPDpw2LPnCPaKtgvz35NP4DKSKtoF2Rl/Q6h0v1/Gwtq8sg6Y0mOPunB10+Rkcuwg7f 7RscfnmHhRG5TUV6q7VMa9kUcJffToK1EFZ4fMb6KQblRdvPiqHS9cy7Jad5Vhem+1H0 OVg66JNUdPMBvMPs84vxJzs2AN7HVl1G6zWTqK2B/yrJzsYvKjJ7blJ+PhEadSqMdkex nypw== X-Gm-Message-State: ANoB5pkkgxovnnjFnVqlckECMS6tL6YuVom1BOA+acFxC2sSGP0ywciC 3MqJgfMpFYrzZjPqLsY/+0EK8yA3Mr/lzg== X-Google-Smtp-Source: AA0mqf6g0v+6kq6Ozoge9Zo0LwcBTF2lHhCz1bFGoy1dO2Rrh65usbV/jIYlltPl6BL455daW+hrUw== X-Received: by 2002:a05:600c:538d:b0:3d0:47c:9fe9 with SMTP id hg13-20020a05600c538d00b003d0047c9fe9mr3568654wmb.40.1669140496460; Tue, 22 Nov 2022 10:08:16 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/3] tcg: Factor init_ffi_layouts() out of tcg_context_init() Date: Tue, 22 Nov 2022 19:08:03 +0100 Message-Id: <20221122180804.938-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122180804.938-1-philmd@linaro.org> References: <20221111074101.2069454-27-richard.henderson@linaro.org> <20221122180804.938-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1669140571407100005 Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg.c | 83 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 8aa6fc9a25..9b24b4d863 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -572,7 +572,49 @@ static ffi_type *typecode_to_ffi(int argmask) } g_assert_not_reached(); } -#endif + +static void init_ffi_layouts(void) +{ + /* g_direct_hash/equal for direct comparisons on uint32_t. */ + ffi_table =3D g_hash_table_new(NULL, NULL); + for (int i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { + uint32_t typemask =3D all_helpers[i].typemask; + gpointer hash =3D (gpointer)(uintptr_t)typemask; + struct { + ffi_cif cif; + ffi_type *args[]; + } *ca; + ffi_status status; + int nargs; + + if (g_hash_table_lookup(ffi_table, hash)) { + continue; + } + + /* Ignoring the return type, find the last non-zero field. */ + nargs =3D 32 - clz32(typemask >> 3); + nargs =3D DIV_ROUND_UP(nargs, 3); + + ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); + ca->cif.rtype =3D typecode_to_ffi(typemask & 7); + ca->cif.nargs =3D nargs; + + if (nargs !=3D 0) { + ca->cif.arg_types =3D ca->args; + for (int j =3D 0; j < nargs; ++j) { + int typecode =3D extract32(typemask, (j + 1) * 3, 3); + ca->args[j] =3D typecode_to_ffi(typecode); + } + } + + status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, + ca->cif.rtype, ca->cif.arg_types); + assert(status =3D=3D FFI_OK); + + g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); + } +} +#endif /* CONFIG_TCG_INTERPRETER */ =20 typedef struct TCGCumulativeArgs { int arg_idx; /* tcg_gen_callN args[] */ @@ -753,44 +795,7 @@ static void tcg_context_init(unsigned max_cpus) } =20 #ifdef CONFIG_TCG_INTERPRETER - /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table =3D g_hash_table_new(NULL, NULL); - for (i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { - struct { - ffi_cif cif; - ffi_type *args[]; - } *ca; - uint32_t typemask =3D all_helpers[i].typemask; - gpointer hash =3D (gpointer)(uintptr_t)typemask; - ffi_status status; - int nargs; - - if (g_hash_table_lookup(ffi_table, hash)) { - continue; - } - - /* Ignoring the return type, find the last non-zero field. */ - nargs =3D 32 - clz32(typemask >> 3); - nargs =3D DIV_ROUND_UP(nargs, 3); - - ca =3D g_malloc0(sizeof(*ca) + nargs * sizeof(ffi_type *)); - ca->cif.rtype =3D typecode_to_ffi(typemask & 7); - ca->cif.nargs =3D nargs; - - if (nargs !=3D 0) { - ca->cif.arg_types =3D ca->args; - for (int j =3D 0; j < nargs; ++j) { - int typecode =3D extract32(typemask, (j + 1) * 3, 3); - ca->args[j] =3D typecode_to_ffi(typecode); - } - } - - status =3D ffi_prep_cif(&ca->cif, FFI_DEFAULT_ABI, nargs, - ca->cif.rtype, ca->cif.arg_types); - assert(status =3D=3D FFI_OK); - - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); - } + init_ffi_layouts(); #endif =20 tcg_target_init(s); --=20 2.38.1 From nobody Wed May 8 22:16:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1669140575; cv=none; d=zohomail.com; s=zohoarc; b=ND79YYTIkhJAiFym2X6ufrFj4b27lrAtuFJP65iQMkK6tts9PZ97XoubCQlJCqwFINZ6TFwGHf5+0MSZVh+/LCsMJ5qL9dc+3WsF4zlrY1YAEB7V7h8QL/viHUv1AALhW3odv2PERX7ku3CJdcBfyJAjsXfQznqPAbmn0As6dX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669140575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q7tm1bhBcyuyPxnOlxXqA0DnnV9CFx9sxG0g/SSnkGA=; b=bJkou6mjPcnjkc4G7+d2I4feMSe/Z6q553W1EMR3ddthGWAxODncfyPtMpX5f4hNdfZjiYlFtonIvxekm2JzpS/dyqRXwu/7gz0VPKUlh/giVo6AY6/pbiyleDl5BrpS5NmSfAW99utmyEAH4l06h24PqHApT5BjM9Z0GF5W4Wk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1669140575059818.247922860981; Tue, 22 Nov 2022 10:09:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oxXh8-0001So-7K; Tue, 22 Nov 2022 13:08:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oxXh2-0001Nv-NN for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:25 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oxXh1-0000NU-2a for qemu-devel@nongnu.org; Tue, 22 Nov 2022 13:08:24 -0500 Received: by mail-wm1-x32c.google.com with SMTP id v7so11340304wmn.0 for ; Tue, 22 Nov 2022 10:08:22 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id r7-20020a05600c458700b003a3170a7af9sm18859201wmo.4.2022.11.22.10.08.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 22 Nov 2022 10:08:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q7tm1bhBcyuyPxnOlxXqA0DnnV9CFx9sxG0g/SSnkGA=; b=LJ+W+Pum0r5pudghn5r+NXFW4czYWWDGUlcygL/BdM9atcw2EY8FePsCv52yHFhRQM VGP+gq234eplFgthC5GRTdgWjHzry9luIdjJDrWB7xaheHfelnjZ5fUX/q4X0DSV80AL w7lQri4jHWHdS8mVdVU1mAIex8zNczKTjx+JmdiKI3MUJnYWV4YosJovJNbM8w+iYbqK 1pGjLiIlEvrU9uwfdwaKSbzLCWdutFE7e28mSrCuW7uBQ7gqVWPaNJi9Vjwx6RYYeDVE WkkKRN3i7tTfMtjk3+D5LvwgD66jFcWETpckdlc0OK/U7MNBfeaZhwNvVkfSWwCS5dgP kBOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q7tm1bhBcyuyPxnOlxXqA0DnnV9CFx9sxG0g/SSnkGA=; b=i2JG2xmouQDztXwla/6Suig/XmDjTskZJq0QyDL2eVSIyCKueVUfZPt5WVTzNmbxaX 0ptAiN4RIgDqScfvN7k0YJKr16yO5qqilNp0UvswrEYGDY6jPpr722STo9IuPVXdHx3k FSQ0kH9fZHB0hUeOIfx+XkA7fogHCq2xzsog0zgl3VyXvZMe1c3wxVA6VBkHy1XbyKkg R5WlkvNMYh5NmtjtUYiE3wE2H0ZPM2Y02+lfSStdBUmE6uAHh07hsCgwIxxQcFs6SPcL gBxKHu96fZ2+O1HsIg5YCGyspKyTK45N88H9tJyDAvFOOpoOJw/m6wDVzxmt9kYFfDDp Gwvg== X-Gm-Message-State: ANoB5pn77GwxXb29UmaMx+Jh4TxcOWd8sEjPz8PXQHxQHlSstHkHXmwg y0q5xyvMl0DCqZpJDnpVK6ej2y+5cCWj2A== X-Google-Smtp-Source: AA0mqf78hYl6IcfTkmBVoCxb392OuiP0zp1Oh3B+aRK6+DzocQpr4BWRNE/0YJwE8Hd50aONPeIpBQ== X-Received: by 2002:a05:600c:a41:b0:3cf:895a:b22b with SMTP id c1-20020a05600c0a4100b003cf895ab22bmr4601445wmq.81.1669140501234; Tue, 22 Nov 2022 10:08:21 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 3/3] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Tue, 22 Nov 2022 19:08:04 +0100 Message-Id: <20221122180804.938-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221122180804.938-1-philmd@linaro.org> References: <20221111074101.2069454-27-richard.henderson@linaro.org> <20221122180804.938-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1669140577176100003 From: Richard Henderson Instead of requiring a separate hash table lookup, put a pointer to the CIF into TCGHelperInfo. Signed-off-by: Richard Henderson Message-Id: <20221111074101.2069454-27-richard.henderson@linaro.org> [PMD: Split from bigger patch] Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tcg/tcg-internal.h | 7 +++++++ tcg/tcg.c | 26 ++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/tcg/tcg-internal.h b/tcg/tcg-internal.h index c7e87e193d..6e50aeba3a 100644 --- a/tcg/tcg-internal.h +++ b/tcg/tcg-internal.h @@ -25,6 +25,10 @@ #ifndef TCG_INTERNAL_H #define TCG_INTERNAL_H =20 +#ifdef CONFIG_TCG_INTERPRETER +#include +#endif + #define TCG_HIGHWATER 1024 =20 /* @@ -57,6 +61,9 @@ typedef struct TCGCallArgumentLoc { typedef struct TCGHelperInfo { void *func; const char *name; +#ifdef CONFIG_TCG_INTERPRETER + ffi_cif *cif; +#endif unsigned typemask : 32; unsigned flags : 8; unsigned nr_in : 8; diff --git a/tcg/tcg.c b/tcg/tcg.c index 9b24b4d863..d6a3036412 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -552,8 +552,6 @@ static TCGHelperInfo all_helpers[] =3D { static GHashTable *helper_table; =20 #ifdef CONFIG_TCG_INTERPRETER -static GHashTable *ffi_table; - static ffi_type *typecode_to_ffi(int argmask) { switch (argmask) { @@ -576,9 +574,11 @@ static ffi_type *typecode_to_ffi(int argmask) static void init_ffi_layouts(void) { /* g_direct_hash/equal for direct comparisons on uint32_t. */ - ffi_table =3D g_hash_table_new(NULL, NULL); + GHashTable *ffi_table =3D g_hash_table_new(NULL, NULL); + for (int i =3D 0; i < ARRAY_SIZE(all_helpers); ++i) { - uint32_t typemask =3D all_helpers[i].typemask; + TCGHelperInfo *info =3D &all_helpers[i]; + unsigned typemask =3D info->typemask; gpointer hash =3D (gpointer)(uintptr_t)typemask; struct { ffi_cif cif; @@ -586,8 +586,11 @@ static void init_ffi_layouts(void) } *ca; ffi_status status; int nargs; + ffi_cif *cif; =20 - if (g_hash_table_lookup(ffi_table, hash)) { + cif =3D g_hash_table_lookup(ffi_table, hash); + if (cif) { + info->cif =3D cif; continue; } =20 @@ -611,8 +614,12 @@ static void init_ffi_layouts(void) ca->cif.rtype, ca->cif.arg_types); assert(status =3D=3D FFI_OK); =20 - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); + cif =3D &ca->cif; + info->cif =3D cif; + g_hash_table_insert(ffi_table, hash, (gpointer)cif); } + + g_hash_table_destroy(ffi_table); } #endif /* CONFIG_TCG_INTERPRETER */ =20 @@ -4413,12 +4420,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp = *op) } =20 #ifdef CONFIG_TCG_INTERPRETER - { - gpointer hash =3D (gpointer)(uintptr_t)info->typemask; - ffi_cif *cif =3D g_hash_table_lookup(ffi_table, hash); - assert(cif !=3D NULL); - tcg_out_call(s, tcg_call_func(op), cif); - } + tcg_out_call(s, tcg_call_func(op), info->cif); #else tcg_out_call(s, tcg_call_func(op)); #endif --=20 2.38.1