[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/49] target/hppa: Speed up hppa_is_pa20()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 41/49] target/hppa: Speed up hppa_is_pa20() |
Date: |
Sun, 12 Jan 2025 23:17:17 +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>
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>
---
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,
--
2.47.1
- [PULL 35/49] tests/qtest/boot-serial-test: Correct HPPA machine name, (continued)
- [PULL 35/49] tests/qtest/boot-serial-test: Correct HPPA machine name, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 33/49] hw/i2c/imx_i2c: Convert DPRINTF() to trace events, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 32/49] hw/char/imx_serial: Turn some DPRINTF() statements into trace events, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 34/49] hw/gpio/imx_gpio: Turn DPRINTF() into trace events, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 36/49] tests: Add functional tests for HPPA machines, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 30/49] tests/qtest/libqos: Reuse TYPE_IMX_I2C define, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 37/49] target/hppa: Convert hppa_cpu_init() to ResetHold handler, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 38/49] hw/hppa: Reset vCPUs calling resettable_reset(), Philippe Mathieu-Daudé, 2025/01/12
- [PULL 39/49] target/hppa: Only set PSW 'M' bit on reset, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 40/49] target/hppa: Set PC on vCPU reset, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 41/49] target/hppa: Speed up hppa_is_pa20(),
Philippe Mathieu-Daudé <=
- [PULL 42/49] hw/loongarch/virt: Checkpatch cleanup, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 43/49] backends/cryptodev-vhost-user: Fix local_error leaks, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 44/49] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 45/49] hw/tricore/triboard: Remove unnecessary use of &first_cpu, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 46/49] MAINTAINERS: remove myself from sbsa-ref, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 47/49] MAINTAINERS: Add me as the maintainer for ivshmem-flat, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 48/49] MAINTAINERS: Update path to coreaudio.m, Philippe Mathieu-Daudé, 2025/01/12
- [PULL 49/49] Add a b4 configuration file, Philippe Mathieu-Daudé, 2025/01/12
- Re: [PULL 00/49] Misc HW patches for 2025-01-12, Philippe Mathieu-Daudé, 2025/01/13