From patchwork Fri Dec 30 00:02:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 637836 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3180792pvb; Thu, 29 Dec 2022 16:13:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXujtftAEGD/1uHbXijyjYTHcGlrftq9opgSIK+N+tAdG3m8avFE3U9jfYcfhrq/C0ABfIpC X-Received: by 2002:a05:6214:c6c:b0:4c6:fcf7:9aea with SMTP id t12-20020a0562140c6c00b004c6fcf79aeamr53494640qvj.49.1672359192376; Thu, 29 Dec 2022 16:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672359192; cv=none; d=google.com; s=arc-20160816; b=uZR89h9h94dxCQG3xax92qCJ04OiuPndviVrWO+Ez8YIcHZywEyvoEWq0lOQYnHQCS 8BgpBT9gJW3IhMDHs0BHqjycCw3ODhdxYGFejYtvpeZAyY030s9Ru8ihvK/7hkIfrrbv gGCp964QzWukwg6e5nDcJVQE30RK+J3caNx0cJPeq4frf+15IZSSqeuedrCxUQwSemWS OKxPUcN9R4AbXwkrwzqr+CHztIZ4mKoK97l9AQRU7mVXIu9XgDaoi/aR8rnVnF+m5wVQ 9CDtm98t7d6rbUXQtxuUnGAQrehOqfboyzROl9kHGLIb2on3FEBaU0NeLzazI84fa9eu SnlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vCLzxn0q0XTdpTpZ+mEjL5EuaQDV+OhjoinCv0kOApo=; b=hQR9oITkO1SpFsttodvQb+UpjOia511n8Iwi4PmvYLW42aDs3jxWN/vIm7rRuxcK+s bKQLzbO0/ecCjnOEqOSf4ukP1WzT5K54rZwky0e6VGrD8T2E8HylaDtlWya8cz5Goj/C D+0mNbf0QRmSmvP9s+QYlon+pabjjd2qvjpkfVKjqaUql6Ne/7fYsxP3WuFQ7YT1bRDs aPrZI5x8XzsenFA9z+miTY12m4T6+Qa+psusu22lpHAFSyLQFhT8WtQpPfsVY5gVXCJd hl7Qdl9VszWWZNKVRS++OJHZ9VAlJy/LuLuS7S901TIoEdCfYlpHwR4dGXBoh2w2iDDB s9tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hsq9XH4S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iy5-20020a0562140f6500b004990359d3aasi8038887qvb.462.2022.12.29.16.13.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Dec 2022 16:13:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hsq9XH4S; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pB2ud-0006Wk-1k; Thu, 29 Dec 2022 19:06:15 -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 1pB2uU-0006Li-Ij for qemu-devel@nongnu.org; Thu, 29 Dec 2022 19:06:11 -0500 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pB2uQ-0004EF-EL for qemu-devel@nongnu.org; Thu, 29 Dec 2022 19:06:05 -0500 Received: by mail-pf1-x429.google.com with SMTP id k19so5864406pfg.11 for ; Thu, 29 Dec 2022 16:06:01 -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=vCLzxn0q0XTdpTpZ+mEjL5EuaQDV+OhjoinCv0kOApo=; b=hsq9XH4SOumvEOfb8I1y37Ee+9ZWTSvt78BVA5kJCIESP3QZVoZIm2YDnbLl26e81L VMDU/3rjMKGCRSRgzUU16wsgXnAJs31m7gw3p4cIsqbhFCnJx1QbTLffOpmvsx1fTkVu tlpOKLtabVVJxPyqxVKEfEstK7xMfozcURz9QABMzpnEMTG49EgovJnV+iQDvZ5lUzNu oKPqlGmFQRCL/cwnABP98zS9VktMv+JTKbLsHWdpi7LEh0a1tnHtyBCiR8KxoGvRuGvD bt6DIAjy4QjCzDaTVGdDMA9I4gcEO6vnpiOXcv0cfh6vdNr45WaaB7zzcSsWHi1iWypt 80HQ== 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=vCLzxn0q0XTdpTpZ+mEjL5EuaQDV+OhjoinCv0kOApo=; b=UMLneP2vf1Yz3ekhO9PDUAWpDcAcK2qEfHAH1nB3q9RNpmdE7DOe41dOZjqIq6P1Z+ slzvBM9GcBKB0eJ9dG0+IymhZVn3EFd7t5qd9UaxyU8FT7cQ+A9yxpPY1HZNpeMLs5yf eXLJH3DP/BUaILTbeIDpqqVWvh15iy67W461+EMCOEGFdG6aXKEdtTeWR8ruU4+cUHZ7 dNbaJYeJkeTaHvPdxtkPkJeSansI7R3cLx/Srskx3HgNZj7lIQhuYhi4G/tAtPDZVUne D0Y7+HUgkFhajexTS1OjV0OVqY4wF8Da79KMYhQi8Ov+WpEoDVgsPQaONx+e7qB4XBMM lWmA== X-Gm-Message-State: AFqh2koenLIIJW/53zZPe3rw1szta63sBoVAjoSTPGaFdzwEW8tlaCvs UnDL3AWNFlre+q6HansjpHuzk+suuwtbnF94 X-Received: by 2002:a05:6a00:168d:b0:577:2a9:ec82 with SMTP id k13-20020a056a00168d00b0057702a9ec82mr38207348pfc.5.1672358761045; Thu, 29 Dec 2022 16:06:01 -0800 (PST) Received: from stoup.. (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id x185-20020a6286c2000000b0056bfebfa6e4sm12586151pfd.190.2022.12.29.16.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 16:06:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 41/47] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Thu, 29 Dec 2022 16:02:15 -0800 Message-Id: <20221230000221.2764875-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221230000221.2764875-1-richard.henderson@linaro.org> References: <20221230000221.2764875-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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] Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221122180804.938-4-philmd@linaro.org> --- tcg/tcg-internal.h | 7 +++++++ tcg/tcg.c | 30 ++++++++++++++---------------- 2 files changed, 21 insertions(+), 16 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 +#ifdef CONFIG_TCG_INTERPRETER +#include +#endif + #define TCG_HIGHWATER 1024 /* @@ -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 cfc0280883..76cf26870c 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -62,10 +62,6 @@ #include "tcg/tcg-ldst.h" #include "tcg-internal.h" -#ifdef CONFIG_TCG_INTERPRETER -#include -#endif - /* Forward declarations for functions declared in tcg-target.c.inc and used here. */ static void tcg_target_init(TCGContext *s); @@ -553,8 +549,6 @@ static TCGHelperInfo all_helpers[] = { static GHashTable *helper_table; #ifdef CONFIG_TCG_INTERPRETER -static GHashTable *ffi_table; - static ffi_type *typecode_to_ffi(int argmask) { switch (argmask) { @@ -577,9 +571,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 = g_hash_table_new(NULL, NULL); + GHashTable *ffi_table = g_hash_table_new(NULL, NULL); + for (int i = 0; i < ARRAY_SIZE(all_helpers); ++i) { - uint32_t typemask = all_helpers[i].typemask; + TCGHelperInfo *info = &all_helpers[i]; + unsigned typemask = info->typemask; gpointer hash = (gpointer)(uintptr_t)typemask; struct { ffi_cif cif; @@ -587,8 +583,11 @@ static void init_ffi_layouts(void) } *ca; ffi_status status; int nargs; + ffi_cif *cif; - if (g_hash_table_lookup(ffi_table, hash)) { + cif = g_hash_table_lookup(ffi_table, hash); + if (cif) { + info->cif = cif; continue; } @@ -612,8 +611,12 @@ static void init_ffi_layouts(void) ca->cif.rtype, ca->cif.arg_types); assert(status == FFI_OK); - g_hash_table_insert(ffi_table, hash, (gpointer)&ca->cif); + cif = &ca->cif; + info->cif = cif; + g_hash_table_insert(ffi_table, hash, (gpointer)cif); } + + g_hash_table_destroy(ffi_table); } #endif /* CONFIG_TCG_INTERPRETER */ @@ -4388,12 +4391,7 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op) } #ifdef CONFIG_TCG_INTERPRETER - { - gpointer hash = (gpointer)(uintptr_t)info->typemask; - ffi_cif *cif = g_hash_table_lookup(ffi_table, hash); - assert(cif != 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