From patchwork Fri Dec 2 05:39:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 630213 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp718815pvb; Thu, 1 Dec 2022 21:51:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf71eN5+l714XlfjlttBvxtUMVn8GMfnTXu6QAIJ8hVeuXnxH6tPX0Mas4zN5P06gugzV1A/ X-Received: by 2002:a37:92c6:0:b0:6f9:f247:8864 with SMTP id u189-20020a3792c6000000b006f9f2478864mr45391695qkd.100.1669960298368; Thu, 01 Dec 2022 21:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669960298; cv=none; d=google.com; s=arc-20160816; b=ejSx/Fe1GiEZLaFvm285yKcfsbQ0Ip1+jCAKyVOBi9u9ZyrUbJtX6YmQ/TQYz/RAkd XRmUVYijORw4B3UJRf3M9VzBW72lmYYAPRDNa1Qs5xdcA01PayXh1/lPB3qcDHE0aZWq 8yJ4MSqPqtfXrki/eJEktFri2lRyuyYAdaVo6ksFIWSnRZlIez5cFWMX3Vzp132YfSiU +lfZtvBOMdRb09y9X9tE9KJ3wEUbIsOX7Ml9mUDNySYTYmyHYB3xBTX8OOyy/PSRGj1d Y0bXE4XJUUTj9Cxjr42m/JQEOK0xcOftQYssU11pXogEpMmM1VQ/OBYpDTPvzrrcdVY7 Ihxw== 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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=x/jB/2tYw94F0Bpgx3AY0/LEOcnDrTejDex9FH0CHndiTimkns/KtnY3rSB/atyznh 3cFhwTBjm24cqMgufaYCNBR4+eYsuglpP9jRvLkVx/mQn0BdDs9HoRlTSspZ0kP+v+Uu Kl39cfoyN9EH4fyseMWzQ2IOuqsioa5ebFAc7zJG4unFzLZS7DQdRQ6YtXE9d8nAyLb3 QYbzXuE6IUhBbHUxu03XUFnZNsLbFlBiKtMFcQ9P1C1fb/7VsRgzLjohHieNUzOBTIa+ YGXsVUQuHZm5gjQvZCvbnPWa298egegY7to0WbWT4C0gCdtb8u4v8rJGs7F3zMyC1QUd 3ywA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qhI9wcHL; 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 lt16-20020a056214571000b004c4cd7de132si3075822qvb.116.2022.12.01.21.51.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Dec 2022 21:51:38 -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=qhI9wcHL; 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 1p0ymq-0002lC-Ey; Fri, 02 Dec 2022 00:40:36 -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 1p0ymo-0002kQ-Pt for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:34 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0ymn-0003Qo-5g for qemu-devel@nongnu.org; Fri, 02 Dec 2022 00:40:34 -0500 Received: by mail-pj1-x102e.google.com with SMTP id x13-20020a17090a46cd00b00218f611b6e9so4207076pjg.1 for ; Thu, 01 Dec 2022 21:40:32 -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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=qhI9wcHLRy5JpljdxBlN3wmzQ1PPS9QTfjoJvtxIkSCugoBT7g25w9E/XVA+5RuWy7 sLKT3lhvcPHrN0q0B6QY2JNPbsDKR1wsaAIPDStFDBQM5gelmI1b21n5a31iPYW6oFEB bljpNeBgfLdU5sqHdAA9VZen+/J/5ZCFfUpxM+gnPE/cyWp65A+bXj8xd+LwrfMTYAj3 icHqztKT6jmlkylMo/OeMpv0+w74KXE2fppdFlWNUSi0JGPfVnBUPhO4EY+SN1oeM1m8 Pbl1SBzsIalsGHARU9D9Adx0Pp2bjqHKCki1RROTyOGOQuwpjG8shwmjVKSX5jySL32S q9UQ== 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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=503YJ8UX4Pq/m03iF4pT983wDUe7oJXbJIeiuy+8QHO+TFxI26E/wbRYXzqgRlA0xU H7RaWF4K/7KskNZStMTw8MyJKJo+p8wtob8hxG98X5MvlDt8tRU2lvZ0ovQ5/d3LhEg5 ZZ7pT1g7fUbyqZDtcXmmD4AxMGX3AXXURiiSPvGOIPde7LqkGXWDE6y+ZAkceyiswam+ ZnadAwVQHgnI8hxM3D/QVxljZ65uQaRZwHqtrmh7NhiqMEVacn+7mvALnhwVsFKtlq9f jTJaEZNXKlBv2cd7Q8292iPATvoJ/+XqQnDMJpD0jGUEUj2SqpRWkRM9D4vrQ8hl1YPQ O9Cw== X-Gm-Message-State: ANoB5plNAQMWSiQLjG/O4Wezda9KQXuVK9A6qI2x2t/TSu7EnGe688bh i6FBwsWajVj+QjW9/gqLnBcrJu4YJ8LI7Xy9 X-Received: by 2002:a17:902:b707:b0:189:5f3c:fb25 with SMTP id d7-20020a170902b70700b001895f3cfb25mr39437695pls.123.1669959631925; Thu, 01 Dec 2022 21:40:31 -0800 (PST) Received: from stoup.. ([2602:47:d48a:1201:e3cc:2e37:17d4:f1d5]) by smtp.gmail.com with ESMTPSA id d12-20020a170903230c00b00186f0f59c85sm4637075plh.235.2022.12.01.21.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 21:40:31 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v3 32/34] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Thu, 1 Dec 2022 21:39:56 -0800 Message-Id: <20221202053958.223890-33-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221202053958.223890-1-richard.henderson@linaro.org> References: <20221202053958.223890-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102e.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] 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 3c3bb2d422..9092473cf0 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 */ @@ -4385,12 +4388,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