qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/hppa: Speed up hppa_is_pa20()


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] target/hppa: Speed up hppa_is_pa20()
Date: Sun, 29 Dec 2024 18:24:01 +0100
User-agent: Mozilla Thunderbird

On 28/12/24 22:08, Helge Deller wrote:
Although the hppa_is_pa20() helper is costly due to string comparisms in

"comparisms" -> "comparison"?

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>

v2:
- moved init to hppa_cpu_initfn() and is_pa20 to end of CPUArchState struct
   (feedback by Richard)

diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c
index b908cf65c6..05de952a87 100644
--- a/target/hppa/cpu.c
+++ b/target/hppa/cpu.c
@@ -199,6 +199,7 @@ static void hppa_cpu_initfn(Object *obj)
      CPUHPPAState *env = &cpu->env;
cs->exception_index = -1;
+    env->is_pa20 = object_dynamic_cast(obj, TYPE_HPPA64_CPU);

Personally I find explicit casts to boolean clearer:

       env->is_pa20 = !!object_dynamic_cast(obj, TYPE_HPPA64_CPU);

      cpu_hppa_loaded_fr0(env);
      cpu_hppa_put_psw(env, PSW_W);
  }

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]