diff mbox series

[11/14] accel/tcg: Use cpu_loop_exit_requested() in cpu_loop_exec_tb()

Message ID 20240427155714.53669-12-philmd@linaro.org
State New
Headers show
Series exec: Rework around CPUState user fields | expand

Commit Message

Philippe Mathieu-Daudé April 27, 2024, 3:57 p.m. UTC
Do not open-code cpu_loop_exit_requested().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/cpu-exec.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Richard Henderson April 28, 2024, 6:35 p.m. UTC | #1
On 4/27/24 08:57, Philippe Mathieu-Daudé wrote:
> Do not open-code cpu_loop_exit_requested().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   accel/tcg/cpu-exec.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
> index 225e5fbd3e..0329c6423e 100644
> --- a/accel/tcg/cpu-exec.c
> +++ b/accel/tcg/cpu-exec.c
> @@ -900,8 +900,6 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
>                                       vaddr pc, TranslationBlock **last_tb,
>                                       int *tb_exit)
>   {
> -    int32_t insns_left;
> -
>       trace_exec_tb(tb, pc);
>       tb = cpu_tb_exec(cpu, tb, tb_exit);
>       if (*tb_exit != TB_EXIT_REQUESTED) {
> @@ -910,8 +908,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
>       }
>   
>       *last_tb = NULL;
> -    insns_left = qatomic_read(&cpu->neg.icount_decr.u32);
> -    if (insns_left < 0) {
> +    if (cpu_loop_exit_requested(cpu)) {
>           /* Something asked us to stop executing chained TBs; just
>            * continue round the main loop. Whatever requested the exit
>            * will also have set something else (eg exit_request or
> @@ -925,6 +922,8 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
>       /* Instruction counter expired.  */
>       assert(icount_enabled());
>   #ifndef CONFIG_USER_ONLY
> +    int32_t insns_left;
> +

If you're going to declare in the middle of a block, you might as well delay until the 
initialization a few lines down.


r~
diff mbox series

Patch

diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 225e5fbd3e..0329c6423e 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -900,8 +900,6 @@  static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
                                     vaddr pc, TranslationBlock **last_tb,
                                     int *tb_exit)
 {
-    int32_t insns_left;
-
     trace_exec_tb(tb, pc);
     tb = cpu_tb_exec(cpu, tb, tb_exit);
     if (*tb_exit != TB_EXIT_REQUESTED) {
@@ -910,8 +908,7 @@  static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
     }
 
     *last_tb = NULL;
-    insns_left = qatomic_read(&cpu->neg.icount_decr.u32);
-    if (insns_left < 0) {
+    if (cpu_loop_exit_requested(cpu)) {
         /* Something asked us to stop executing chained TBs; just
          * continue round the main loop. Whatever requested the exit
          * will also have set something else (eg exit_request or
@@ -925,6 +922,8 @@  static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
     /* Instruction counter expired.  */
     assert(icount_enabled());
 #ifndef CONFIG_USER_ONLY
+    int32_t insns_left;
+
     /* Ensure global icount has gone forward */
     icount_update(cpu);
     /* Refill decrementer and continue execution.  */