From patchwork Mon Dec 30 15:25:19 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: 854246 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp6488580wrq; Mon, 30 Dec 2024 07:26:42 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUzUe8QdlNjLIACkXA3bT6KxND1zFHsXIHypJSSuh5W3I+5Tdh37PDiR5ayYrev13o3eKiLLA==@linaro.org X-Google-Smtp-Source: AGHT+IHwlELKlcaCTqZoQdc2BJqsdt7D0QOCYZbuDNMRfUjkEdw1l1cuOkzJTskdvUNn83ZSowMN X-Received: by 2002:a05:620a:2608:b0:7b6:da21:751c with SMTP id af79cd13be357-7b9ba6fd997mr5062148285a.11.1735572402526; Mon, 30 Dec 2024 07:26:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735572402; cv=none; d=google.com; s=arc-20240605; b=fv0PuvCdranfm3L2219tlG/Xv1+2lDkaR4mEK8BV+gZp3ihH8utRWtx/VrtjbUW4FT /K3dzNHM4TR8RRNCA49Nk4KbR8L/GzAXzyhF+YttgDcCDHOst2L3xAT1bn+wa29dOKDh nhSDBZeHxcUQDw6qTjSAB1IP9uW5hXmxdNpjosZdZ2GkhTu7Zvs4DQYMtS6YAhH0S4PB yxwO8Hacxde2k7Qf2VRj1XgF67QUomh46vE1bxA0/upAzg0/zMWJySzQ7N0HoZZLCwz3 /1qCM3gH9Oga6bZCAoVHMZDoj90pil17Qh7Cb+/AkYrz5BjrBTAokGGraHclCP9py99S Pj/g== 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=+fA5or/bmCnhWrsP/slJI6ViiWLeMfeymomX0gA+oig=; fh=Pu80oL6pqNVhcxmoTE7CG5kT5lPd7R2XHVDIETOmhNw=; b=IEdRnsd0WidRc4Y5Ufj6aEJXScPG9/UccUb6+lv2SgagNEyJoTAWlxfS9Bn8pcDsR+ dRnXqdXlAaf77wcz5w7qPS0Hi8emLIuDQ0EsZ150A0RAahlmgSTP5e+jM4tbCSlfDm6z QEstzZJqdtgpdI3Yy9OYm3T8f4PF8MyZ+tO3CHfRJQzPjybgWEmHdygBO6kwgG15p9tt mkeCdD7G7IC3xWGuDtsVXvD5NPQXcuetVq99LfzDRWdGAQwiXsyNUDFYv6cisQEKEB/h Wa4eHclebQLYsvWFbZptHAEvksb/DgQs8KlvoSrKGyprwGrdro9Thk8Y1eKpDf8AC5+z G8gA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dbEnYA88; 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 af79cd13be357-7b9ac478a6esi2771402685a.234.2024.12.30.07.26.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Dec 2024 07:26:42 -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=dbEnYA88; 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 1tSHeP-0002gU-Iq; Mon, 30 Dec 2024 10:25:49 -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 1tSHeO-0002gE-Ac for qemu-devel@nongnu.org; Mon, 30 Dec 2024 10:25:48 -0500 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tSHeM-0001mJ-Pj for qemu-devel@nongnu.org; Mon, 30 Dec 2024 10:25:48 -0500 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-385de9f789cso7008127f8f.2 for ; Mon, 30 Dec 2024 07:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735572345; x=1736177145; 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=+fA5or/bmCnhWrsP/slJI6ViiWLeMfeymomX0gA+oig=; b=dbEnYA88SwY4gIOEfiYaPos89A7Ai5fYE8RRpIoxOlWrKXRUCC9BXKeFb6N9Ym3EkM /39NrVWHqDYmb1xsmN16wX2OEl3RH30A/lw2xrIlb3K+fmwydY7NAD7Lm4pj/L7tWpPc aNmDgxHUpTZkDMbmuz6pItXJ4a10xNdWuLYyGKO41hSGCYZEmM4/+DqRRwfLj9h6rSbX oMxEmZ6C3+MkT39vpn98Wq0wYpKXm2QeGXQe8+QZL2JDolVbJnKn127YQv41JOfSWVC8 4aoVdJxEz7wrYQBBlMjz/ScbKP8J//TmgeR8dIYMXRB0EAryTALQ6kykxBu0m2XlSvRr sFnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735572345; x=1736177145; 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=+fA5or/bmCnhWrsP/slJI6ViiWLeMfeymomX0gA+oig=; b=KUUQ6ktTIW0eHCoQAjuikHdmCCEhW+x5ydkdD0xnJatZXhESy0awnHrtJvIxXuorA4 c4kCHHRwrMvdAXcocktFpqQnwAc3WUDIHkEdrtLeUlJQ/gXEymrXd6k7U+/F5jG6gT5i U0NqV2oTDoPE7ZBTaMj1w209EpU8QOY1IZz10p+S27MI+rYxy2x9uVIyr3DnoxMNzmK/ 5NpXcHU6JNI3EgrEfEHw7sXWy6WuhgQCO2Z+Ce2c048qZRjMy6lPzPyLAsQdwQKhfI8k hULQQBjLs8CHOKrUZuRKarsEPiViUWNQd/ioVcaCU8v81P5xdK4ht001NZTUxUYiM6qy hLCA== X-Gm-Message-State: AOJu0YxbXlqYLKsroSnGmCThx2CO9cyJumzwmf6AS+iVbQIKwHhazEad uBoudpniSW8bFVw5lnkZRE1FCpNFANsDTmZJr9hx/NhrHfYTDzX/Uo1dBydKoZllo+MpxioRkUV l X-Gm-Gg: ASbGnctm/2yzV9EeZAfvYnq+z4jL+kzoySYGO+t2jV+HP9qeZQmHBW0JIwReGBAmCiQ KfOGwfO75QoIkEofF0wcRN+DOuIi0oqGL5WR90ScWt1s1qK12maVLenfe+PpnJFAfr3S/5YPC1g QdmQfnrHSL2c+qsUHjTXsRGmxR4jESK0xaZVyc8KJLoiEla6lg5d5SXvboYF/h1D8kKKFw+WUuW RH7+e0jLe9JMbtX+1iempYFkDrrILH9mIzsqzLf0MTbKZy5WffzCCzPEVjeK2+ambavsCL5dEZB W9jvCerYmRG7o1J4OV49iyGVmHn/DAY= X-Received: by 2002:a5d:47af:0:b0:385:f10a:335 with SMTP id ffacd0b85a97d-38a221face5mr28963025f8f.21.1735572344829; Mon, 30 Dec 2024 07:25:44 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43656b119b6sm395923675e9.22.2024.12.30.07.25.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Dec 2024 07:25:44 -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 v3 5/5] target/hppa: Speed up hppa_is_pa20() Date: Mon, 30 Dec 2024 16:25:19 +0100 Message-ID: <20241230152519.86291-6-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241230152519.86291-1-philmd@linaro.org> References: <20241230152519.86291-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=philmd@linaro.org; helo=mail-wr1-x432.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 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson [PMD: Have hppa_is_pa20() take a const argument] Signed-off-by: Philippe Mathieu-Daudé --- target/hppa/cpu.h | 6 ++++-- target/hppa/cpu.c | 2 ++ 2 files changed, 6 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..6e5434a8e99 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -209,6 +209,8 @@ static void hppa_cpu_reset_hold(Object *obj, ResetType type) memset(env, 0, offsetof(CPUHPPAState, end_reset_fields)); + env->is_pa20 = !!object_dynamic_cast(obj, TYPE_HPPA64_CPU); + cpu_hppa_loaded_fr0(env); cpu_hppa_put_psw(env, PSW_M); }