From patchwork Tue Dec 31 19:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 854398 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp7065029wrq; Tue, 31 Dec 2024 11:08:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWNwxRT6iPXQ4I91RgkdLTMeMtCZb2DqknzKEmoA9dG4TCciQJXTL0Hy2mc81cDh3cHP5dUTQ==@linaro.org X-Google-Smtp-Source: AGHT+IEpgTIHBfrF+Zz195mmtWJpGIhIZxmYahhg2mY1oU3F5jsOPOap03gPyBWBf6wnb9SE3ouj X-Received: by 2002:a05:6102:508d:b0:4af:e0d4:70df with SMTP id ada2fe7eead31-4b2cc49c342mr24542455137.27.1735672087512; Tue, 31 Dec 2024 11:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735672087; cv=none; d=google.com; s=arc-20240605; b=hFBltNIbGptcF3UFqGs9ro5XPEcEqvyc99cMvZhOE2L8A6Mn2J9QGBDyQ6T26ZSpnI H9GNXoq2rDdEFg0n+OQ2Wg3YjO2s7TgDlTVpf10cUi/O4XMy3tuKT5J85oJwZ0F6Wpr/ CZaYQw9FT5o/wxDW4MQV5B9TZMv5QYAXlz6rNVb1nHHTRI8jPxgWM8mJwlExmVZAxKWk b+X4WjTKHsRbM2Q1xDd/k643pHBRkJ2UC8PayR0/rCwPgzAMJz3B19trhiskqnlx08Ay Z2B/ZMair9vrwJGdHZJD9BI0QpERE5+vXcMuBP8Ng4SxMveq5znAgJ8zScq+nIdhnKer TW5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=LT79yJT21rJPtnu6Fd4xIWi2kLyEAZ71iOLyoGT2BAA=; fh=Pu80oL6pqNVhcxmoTE7CG5kT5lPd7R2XHVDIETOmhNw=; b=LW74zYShWI8QFkv14YS/J4N3Oi5EJuO/cAWsByU6Y6YCc0PywmamwjsrXZaQ0GfG1b aEPx4WMC01L0rNhFTeJNYuohd2kwot3JAt/Z85OttKohNasc2veDbepFfABk7Lyo00C9 MZhiwQMrT/Ug8ZjzIq9s44L1DBk7g9GDkMnK9ZK2OLPJigYwDlsuLKvTs4My6YVmHjKw CgjacdhWWzjkza5mb9z/7eQ3DflHW/mOO0eaBiDI5hnwXspE/bBfNHZqq/sxrcxun5OC 1FkVq9HGRxYvZ6PQG9yUmwG/8t6hiVWIjc06i9nGdrNfYlU9Rfh0J39+3kmN5Un81Ej4 SXBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NfZFKMBM; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4b2bfb9f7c7si8208772137.522.2024.12.31.11.08.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Dec 2024 11:08:07 -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=NfZFKMBM; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tShZz-0004SE-06; Tue, 31 Dec 2024 14:06:59 -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 1tShZv-0004Rd-QF for qemu-devel@nongnu.org; Tue, 31 Dec 2024 14:06:56 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tShZu-00085d-5s for qemu-devel@nongnu.org; Tue, 31 Dec 2024 14:06:55 -0500 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso9925655f8f.2 for ; Tue, 31 Dec 2024 11:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735672012; x=1736276812; darn=nongnu.org; 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=LT79yJT21rJPtnu6Fd4xIWi2kLyEAZ71iOLyoGT2BAA=; b=NfZFKMBMwjNhE2wnhoaulW14pvrSfT83w4EpMADxILOqrfyqlb+3ykg8x8KQ3WnsR3 Ml5VOK2IfTuTeaW2APyHY0dKeVlEfVCEJr7heXX9eKRKmsEarvbO2KE9zgqMOP1wCcKV Wn8NFungBAl9EebW94osIY0ctGlmruAsXK089Uh8syPO8A6fVPxRHyx+UvcTvn1mXnET bTJsOsJw0qMbuLhDAx5evuhtwGLEFKS8Hu/3pQ2LkEQcBBlqJvDYE5Sk/ZKQhfPI8lQY PpGlBSithlbzcOKn9EtXMEeSSTwhMdwgvv4Qy4ZeiH/IbMLSLI5RVwhPS4WGAxqQrN92 xBpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735672012; x=1736276812; 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=LT79yJT21rJPtnu6Fd4xIWi2kLyEAZ71iOLyoGT2BAA=; b=hcxVW9lMPLud1xUuVIjKjjHG85tjDxG5if7PqUWkn8OVgLsWjEOsXSjCfg2VrlVSJQ 1BUjjJcOA7RrZ4xM3MCrEKZE7BW/YrQl2g5qA7ohNaNQCh72a3FaPhdTlJTPyovhwMoC CaCE5SO6DsQJBLgTPOfHOvVWp73YFGZPP4r79PnQlASIdWLqA9WqGb0HM2e+qD/YjmCR aBFZDhueO6m+HB2XQwYglaCf/Ow027lu8Ns3YbqmCstNyuNgNx4plTosexodz4jGty09 DiqlMEEKdN0EO9Nrjrbnq9UrtqEXZYRaWGF7u6carBaU4D7SkAZ4IqaTtEP8zAAPBIMj gWjw== X-Gm-Message-State: AOJu0YzTDVPlALaXhAZxbGDN/T24ODzloSccqugGAZ+U9nwBOI38qbOx q+RQSdLr9UKDxFWTn6pXZiq/rNMacD8+0xOLYqBYdp4goBwnCl8gC4K78GtqxorThAcu9prkV1P C3KQ= X-Gm-Gg: ASbGnct5Ahm0Xr1JS/7RMiTrMrvwDGhLMN6laDDo1hjHLoVPMUBx1ScjcycgdeWUB3R dvAuvsGrcXjbakbivjJZ0R+A97KkI+Psn9GOJwBrVgqEsqrn0xAHFTlKdASeQslD5J7oGCXtRwK Wp30KzV9uXlxkZtpk0ZVgxeaRN+oQhrDedF48XFAfJTt56l7vvenyNaI2msBfSYVfzLtOhwmrYY t4BLKcQ6Q3P6WiBpBnrS/Xtx3X6tv7QkehozUj3sH6vsMlSPLc5sLPTiGHSyo5+8cwTC6OjSxaq 0aD3xI1qG4tefLtZFet0uUolPXDFgvo= X-Received: by 2002:adf:979c:0:b0:38a:418e:1179 with SMTP id ffacd0b85a97d-38a418e13dbmr14365648f8f.2.1735672012505; Tue, 31 Dec 2024 11:06:52 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c84722dsm33476906f8f.53.2024.12.31.11.06.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 31 Dec 2024 11:06:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Helge Deller , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v4 6/6] target/hppa: Speed up hppa_is_pa20() Date: Tue, 31 Dec 2024 20:06:20 +0100 Message-ID: <20241231190620.24442-7-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241231190620.24442-1-philmd@linaro.org> References: <20241231190620.24442-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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 From: Helge Deller Although the hppa_is_pa20() helper is costly due to string comparisons in object_dynamic_cast(), it is called quite often during memory lookups and at each start of a block of instruction translations. Speed hppa_is_pa20() up by calling object_dynamic_cast() only once at CPU creation and store the result in the is_pa20 of struct CPUArchState. Signed-off-by: Helge Deller Co-developed-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé --- target/hppa/cpu.h | 6 ++++-- target/hppa/cpu.c | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index c1d69c1a835..083d4f5a56a 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -266,6 +266,8 @@ typedef struct CPUArchState { /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; + + bool is_pa20; } CPUHPPAState; /** @@ -297,9 +299,9 @@ struct HPPACPUClass { #include "exec/cpu-all.h" -static inline bool hppa_is_pa20(CPUHPPAState *env) +static inline bool hppa_is_pa20(const CPUHPPAState *env) { - return object_dynamic_cast(OBJECT(env_cpu(env)), TYPE_HPPA64_CPU) != NULL; + return env->is_pa20; } static inline int HPPA_BTLB_ENTRIES(CPUHPPAState *env) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 7278b7ca6b5..b0bc9d35e4c 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -193,6 +193,13 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error **errp) tcg_cflags_set(cs, CF_PCREL); } +static void hppa_cpu_initfn(Object *obj) +{ + CPUHPPAState *env = cpu_env(CPU(obj)); + + env->is_pa20 = !!object_dynamic_cast(obj, TYPE_HPPA64_CPU); +} + static void hppa_cpu_reset_hold(Object *obj, ResetType type) { HPPACPUClass *scc = HPPA_CPU_GET_CLASS(obj); @@ -282,6 +289,7 @@ static const TypeInfo hppa_cpu_type_infos[] = { .parent = TYPE_CPU, .instance_size = sizeof(HPPACPU), .instance_align = __alignof(HPPACPU), + .instance_init = hppa_cpu_initfn, .abstract = false, .class_size = sizeof(HPPACPUClass), .class_init = hppa_cpu_class_init,