diff mbox series

target/arm: Use cpu_env in cpu_untagged_addr

Message ID 20240702154911.1667418-1-richard.henderson@linaro.org (mailing list archive)
State New, archived
Headers show
Series target/arm: Use cpu_env in cpu_untagged_addr | expand

Commit Message

Richard Henderson July 2, 2024, 3:49 p.m. UTC
In a completely artifical memset benchmark object_dynamic_cast_assert
dominates the profile, even above guest address resolution and
the underlying host memset.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé July 2, 2024, 3:51 p.m. UTC | #1
On 2/7/24 17:49, Richard Henderson wrote:
> In a completely artifical memset benchmark object_dynamic_cast_assert
> dominates the profile, even above guest address resolution and
> the underlying host memset.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/arm/cpu.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Alex Bennée July 2, 2024, 3:58 p.m. UTC | #2
Richard Henderson <richard.henderson@linaro.org> writes:

> In a completely artifical memset benchmark object_dynamic_cast_assert
> dominates the profile, even above guest address resolution and
> the underlying host memset.

We seem to use ARM_CPU() quite liberally for a number of helpers so I
wonder if its worth codifying this anywhere? At least all the direct TCG
op helpers take CPUARMState *env directly.

>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/arm/cpu.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index d8eb986a04..ccfb9349a3 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -3309,8 +3309,8 @@ extern const uint64_t pred_esz_masks[5];
>   */
>  static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x)
>  {
> -    ARMCPU *cpu = ARM_CPU(cs);
> -    if (cpu->env.tagged_addr_enable) {
> +    CPUARMState *env = cpu_env(cs);
> +    if (env->tagged_addr_enable) {
>          /*
>           * TBI is enabled for userspace but not kernelspace addresses.
>           * Only clear the tag if bit 55 is clear.
Richard Henderson July 2, 2024, 4:48 p.m. UTC | #3
On 7/2/24 08:58, Alex Bennée wrote:
> Richard Henderson <richard.henderson@linaro.org> writes:
> 
>> In a completely artifical memset benchmark object_dynamic_cast_assert
>> dominates the profile, even above guest address resolution and
>> the underlying host memset.
> 
> We seem to use ARM_CPU() quite liberally for a number of helpers so I
> wonder if its worth codifying this anywhere? At least all the direct TCG
> op helpers take CPUARMState *env directly.

For things that are akin to virtual method calls, i.e. the function pointer comes from a 
table within the object or class, I think we can trust the lookup.  Therefore no dynamic 
check required on entry to those functions.

That said, cpu_env() is relatively new and we haven't made a concerted effort to use it 
everywhere that it might make sense.


r~
Peter Maydell July 4, 2024, 3:14 p.m. UTC | #4
On Tue, 2 Jul 2024 at 16:49, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> In a completely artifical memset benchmark object_dynamic_cast_assert
> dominates the profile, even above guest address resolution and
> the underlying host memset.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>



Applied to target-arm.next, thanks.

-- PMM
diff mbox series

Patch

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index d8eb986a04..ccfb9349a3 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -3309,8 +3309,8 @@  extern const uint64_t pred_esz_masks[5];
  */
 static inline target_ulong cpu_untagged_addr(CPUState *cs, target_ulong x)
 {
-    ARMCPU *cpu = ARM_CPU(cs);
-    if (cpu->env.tagged_addr_enable) {
+    CPUARMState *env = cpu_env(cs);
+    if (env->tagged_addr_enable) {
         /*
          * TBI is enabled for userspace but not kernelspace addresses.
          * Only clear the tag if bit 55 is clear.