diff options
author | Helge Deller <deller@gmx.de> | 2024-12-30 00:41:54 +0100 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-01-13 17:16:04 +0100 |
commit | 5c27cbd7b2ab825528086c0bd10029556ab88fd8 (patch) | |
tree | cd32cfdc753f3fc5b81512f4a0afb804bceff5d2 | |
parent | 46f7be06c8e568ec5d5c4aa07c81b42fc0fc863a (diff) | |
download | qemu-5c27cbd7b2ab825528086c0bd10029556ab88fd8.zip qemu-5c27cbd7b2ab825528086c0bd10029556ab88fd8.tar.gz qemu-5c27cbd7b2ab825528086c0bd10029556ab88fd8.tar.bz2 |
target/hppa: Speed up hppa_is_pa20()
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>
Co-developed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20241231190620.24442-7-philmd@linaro.org>
-rw-r--r-- | target/hppa/cpu.c | 8 | ||||
-rw-r--r-- | target/hppa/cpu.h | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 7278b7c..b0bc9d3 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, diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index c1d69c1..083d4f5 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) |