From patchwork Sat Dec 24 23:57:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 636672 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp929286pvb; Sat, 24 Dec 2022 16:01:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXu0bWk+cDTm4wJAIYX6jEeofe+tlgYqiB6bhsjvM4KHGTMtF7EvhRP5TVG9HsoS8uUoD0V2 X-Received: by 2002:ac8:6e87:0:b0:3a8:11f3:b81c with SMTP id c7-20020ac86e87000000b003a811f3b81cmr18298300qtv.53.1671926485708; Sat, 24 Dec 2022 16:01:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671926485; cv=none; d=google.com; s=arc-20160816; b=tqWhFQRl7A1Wra1pVHr8tO3xq2c7rmaLQHzyjsX2DRDhncKtaJTz5mCHPIL0lZeZfr PSEpTQ6h5BQ9sxYt3b8J7P+M+S3kGsBPH4QigyZJwwkBw7FckSrxkFyKJkPM2pnXdeKS efk1UKYzjCSo4wgFVzDs0Dgu0I5OlAltv44VMURSoJqmCYqFxmz/UxMzk3UfSf42AJxs WVsmrYc8p8G+CcOCoz6Tl8ZNtW0cGwNwBHp5129OMN/gZPt5sqX6EnRrJv9ppuxZg+jA L1ILdC3bjT2qI4HkAlVrSFeM9jq2hnXbz2MbMfxHUAQZjri2+9WSJxx+seaxyjMOJ3Up 4Big== 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=4Nqeff2807DVtWliN4Uc1oaHcrsPV+f3YmdHy8haHjQ=; b=hpHbjijC4kduljJIpqWJWd+gcoVaodSgSxyuKNUxyGT9GtZrMu617zdLDAOBpJster Hk9lJ5U/Bmlp8E3ARr3GdrNpbhXiauWsHaz6+R/JIRPGyeeXkdZvUjPqa6TU8YloMhdh ArIMD2Lu2hSN67w9fl2htX3abom2t0LctZqn3N3MJWFO7q07DmssSczfJYazfxsm82eS nZCWy+YaWnVD2yUfuFKmJ1ddjlyFRmVDpBISJCpSEem5cvpatcFCR9tsadYco0NMVUTw x+NcTwunWCbGFx7ZUkujk56F+TL0pxVUBDnK0r064BdJQwEwlTnB8++nvcci5UZ9z32J nqaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dIQnzHCR; 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 h10-20020ac8714a000000b003ab6c053963si2468219qtp.25.2022.12.24.16.01.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Dec 2022 16:01:25 -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=dIQnzHCR; 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 1p9ES9-0007Tm-8e; Sat, 24 Dec 2022 19:01:21 -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 1p9ERw-0007NU-K3 for qemu-devel@nongnu.org; Sat, 24 Dec 2022 19:01:12 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p9ERr-0000hZ-It for qemu-devel@nongnu.org; Sat, 24 Dec 2022 19:01:05 -0500 Received: by mail-pj1-x1032.google.com with SMTP id u15-20020a17090a3fcf00b002191825cf02so8005198pjm.2 for ; Sat, 24 Dec 2022 16:01:02 -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=4Nqeff2807DVtWliN4Uc1oaHcrsPV+f3YmdHy8haHjQ=; b=dIQnzHCRWDjan+wO5SHBrNxzp8J8c89TtyTP+UFY2QYMUsbtyAkpsCApUEkNrzL6F4 axoXvrakgpk27Xy4bu4YO63rMIocmUNwfolRzXth0zT+K7l6/JtkD3pbFbtd6dQtQe+i TB61S1ooEng97R/uLMvAbB+oMIjCFCJv7H4JHuhBh7Fp6RgVybn33YFArVOTI8BRnxtD 9CL6xss/GefAaG6u9994B2vMb1Et8OX5OvEd1kQqtpE4JbVLHimFZmemSl8+aQzN5W9s HKLgYEjHSAcn4OiHqGM1YdPFAZDxdq1vR9lBbEbwjli0IQ4jHePXpjLz3KY4YQRQEy1O oYyw== 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=4Nqeff2807DVtWliN4Uc1oaHcrsPV+f3YmdHy8haHjQ=; b=KhrYbzbm0kb6be7U+F7YKY1rj5OXca3H0hBVlIHUtvyVOYIxEe1fOJazYWRpY8VF08 fmfbqkbfX/BPepPFP+VQlQ8LPT4Nhjd+HhOeSVeKhLuz3kFPaZOIYkqJ32m9Dgse7DlQ eVAvSlwN5JvFXWkMEohKYrDtNLbax9LKsPNEmnc5ZRtpAzHoLf2zwo9Vtsm6Byrgd1Zh GfVqxQ8sbncdMG0TQbVw0zzx8QTndKrkdx06CjI4okojYkW+7gUAeiJ6TXalxO2cu/cc 83K09mU+IdijgwNeE82UjSDyJerVutKhH9xeSBDrIew3Fu7Lr81Pi+76p/ebzqGiLHpd 1j6g== X-Gm-Message-State: AFqh2krE3xun5tgDhrO1tt6DJGuXi1ok0sPq349nmFtLJN0mD6yzT7WY sAt+ChmhPuVRF4MOVAjaZD7oo4qDjjpmaQm8 X-Received: by 2002:a05:6a20:4f02:b0:ad:ccea:73b4 with SMTP id gi2-20020a056a204f0200b000adccea73b4mr15412288pzb.42.1671926461755; Sat, 24 Dec 2022 16:01:01 -0800 (PST) Received: from stoup.. (76-14-210-194.or.wavecable.com. [76.14.210.194]) by smtp.gmail.com with ESMTPSA id e32-20020a630f20000000b00478fd9bb6c7sm4161280pgl.75.2022.12.24.16.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Dec 2022 16:01:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, philmd@linaro.org Subject: [PATCH v5 41/43] tcg: Move ffi_cif pointer into TCGHelperInfo Date: Sat, 24 Dec 2022 15:57:18 -0800 Message-Id: <20221224235720.842093-42-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224235720.842093-1-richard.henderson@linaro.org> References: <20221224235720.842093-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1032.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 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