[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 5/5] target/hppa: Speed up hppa_is_pa20()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v3 5/5] target/hppa: Speed up hppa_is_pa20() |
Date: |
Mon, 30 Dec 2024 16:25:19 +0100 |
From: Helge Deller <deller@gmx.de>
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 <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
[PMD: Have hppa_is_pa20() take a const argument]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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);
}
--
2.47.1
- [PATCH v3 0/5] hppa CPU reset and speedup, Philippe Mathieu-Daudé, 2024/12/30
- [PATCH v3 1/5] target/hppa: Convert hppa_cpu_init() to ResetHold handler, Philippe Mathieu-Daudé, 2024/12/30
- [PATCH v3 2/5] hw/hppa: Reset vCPUs calling resettable_reset(), Philippe Mathieu-Daudé, 2024/12/30
- [PATCH v3 3/5] target/hppa: Only set PSW 'M' bit on reset, Philippe Mathieu-Daudé, 2024/12/30
- [PATCH v3 4/5] target/hppa: Set PC on vCPU reset, Philippe Mathieu-Daudé, 2024/12/30
- [PATCH v3 5/5] target/hppa: Speed up hppa_is_pa20(),
Philippe Mathieu-Daudé <=
- Re: [PATCH v3 0/5] hppa CPU reset and speedup, Helge Deller, 2024/12/30
- Re: [PATCH v3 0/5] hppa CPU reset and speedup, Philippe Mathieu-Daudé, 2024/12/30