From patchwork Tue Dec 13 21:25:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 633521 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3342475pvb; Tue, 13 Dec 2022 13:26:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf4M27uz7sLxpbE83WgD4warXA5XHEP0iIwMYzEprFS37hPPgbl1XXhdQ6Cvs00lj+e15VQW X-Received: by 2002:a05:622a:2484:b0:39c:da20:f7ae with SMTP id cn4-20020a05622a248400b0039cda20f7aemr34159083qtb.11.1670966818487; Tue, 13 Dec 2022 13:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670966818; cv=none; d=google.com; s=arc-20160816; b=Jbq6/etBIrg0G1yMpw1G+pO1RXUA6sxzdize0T/aYa7cqVasZJ3YX5U6pRBqiMhqn8 RcIUH7KMe9FFLzN5Y+kNmwNE2JGwYlMwcsOFbR/xHsW5n0NDXgOhT5f2jZj6xMw2hquZ pe66lKJZMLRKQFPlp4jwVJY28rPAMbGcRLdxSbOkgjWSRFQsWpeFlpE73/zh+c+EAflQ gHD7kmGZTXzYWNNjGKnUrSfiMJbVR0zfA96IKPIWvY5HHurJtgsY+m/3DOP/TVBR8Gi2 qbMc98sfCliEtfC8EG8V0s9jg67TsrlzbO5n/4islhIvveJ1xKPn2unE2m0Hg8jpQxwp f7pA== 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=lLc7TCHtCjQS24SRJKFEAdvkhi1PVDgdQP8gzmis4iNQXFlHP3gVajnERgeuZTTQ1i PCXxiG8GTQ5aVL8kwnPPOJSUIyRkUP8JwIzfh6lv+rAnh5MvgTMJbsdIZQcl4QN2aalF vI2Wcqtj6tl4uTQVL+utCr7G9l9YpqFWLQSAVMTVQ9eXw+F0m7WpaI2R7bb8l1eci4Rm WdbAWjSQf6pZ9l3I5WumD469UNblAW4sIW6n2c62vkc9g+0hr4LFpGFzMnTLVIijvlum LB5vNoVRDhcYvstq/jx60g5t/zkeoMnqXpsng4Bb/mBqz3j0T7NHnWIoQmA2p4jK10Nc W2bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=keSGhGgY; 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 j3-20020a05620a146300b006fca6ded313si6385624qkl.604.2022.12.13.13.26.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Dec 2022 13:26:58 -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=keSGhGgY; 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 1p5Cn1-0000ju-Qz; Tue, 13 Dec 2022 16:26: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 1p5Cmy-0000hy-36 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:12 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5Cmw-0003DK-G7 for qemu-devel@nongnu.org; Tue, 13 Dec 2022 16:26:11 -0500 Received: by mail-oi1-x231.google.com with SMTP id m204so1038543oib.6 for ; Tue, 13 Dec 2022 13:26: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=ejdHuoy1Jq/BbeHpGWM1PuHE72TqekmQLGqKh44eCOc=; b=keSGhGgYSvSljmvxnViZ+P/5XEkv4WewGZFhZ2Bc6QpUH/DGHU2C2vmtaKI9EY3K3v eQnrXVV2j2hwXRMAGFWFYlAG4TCXHnUvn6agHYtYrvbsq80EOPVXXo+F6DUFGlVA5P6F HdVmL+cXsoI5ubkhIphAZhujAM5fAHeOhmO41EG+ZcbKHAOL8DVyFA02zI3flHTFhQ/4 XcToNTvWFZts0v+truFeMK3yaFvIq0Q3CbbXh9APni2dFU4gQNJf8huyIVG5+QDqXnRJ YOEyhjuYVmdFymIwKPw7vZNmOEvkCBMsHtm07LMP3JECX8IM6cRL6UuBuXHIZQYiuKst 0Z6g== 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=cu4zUqnPDY/0ePWkDx7DOBiJC5VCmQxjJV9OCDN4VD32hu7Iw4dfnaLOOrFHYreM9l F4fmFYvmgS3ZWqb8iSlN4OVFC48S4zuldVALr+BFlBmxLwy4d5CmNJ/wQkiwiqoVBefP cgGslnGDZmbwOF4SPNZZ6iE+cT4U2/Vzk5iNU4M0pTdD1RX/L0201snYyAD+ZIY0o9Cp hvirC0GPfdo95MnaRwDAtluP0DZtpmuV/ibe9+OFFL1cpB+7mv4Q6QI7oPzgxRGurc0e cjU9PfaXEHAoQHcx2PQH5OnC6op5DQCPwBmLece0fCd8P/rNVuTHGQxQy5ovDBAwuTRh Q79Q== X-Gm-Message-State: ANoB5pkgCe5QdRfyGbyPoeLnz6mdBZR4VMcZNwZ87vLI38LoJ3Zzxaa2 gx5syJ/X5VZQJLNtqCW/ZwiZOBLKze/wb8YWvSw= X-Received: by 2002:a05:6808:1520:b0:35b:e67:40b9 with SMTP id u32-20020a056808152000b0035b0e6740b9mr11820094oiw.45.1670966769798; Tue, 13 Dec 2022 13:26:09 -0800 (PST) Received: from stoup.. ([2806:102e:18:2efc:c63:85ed:4256:8ad0]) by smtp.gmail.com with ESMTPSA id a7-20020a056808098700b0035c073aa0d8sm5006831oic.18.2022.12.13.13.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 13:26:09 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 25/27] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Tue, 13 Dec 2022 15:25:39 -0600 Message-Id: <20221213212541.1820840-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213212541.1820840-1-richard.henderson@linaro.org> References: <20221213212541.1820840-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::231; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x231.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