Patchwork [3/4] change while to if

login
register
mail settings
Submitter Paolo Bonzini
Date Jan. 15, 2010, 8:42 a.m.
Message ID <1263544930-18620-4-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/42955/
State New
Headers show

Comments

Paolo Bonzini - Jan. 15, 2010, 8:42 a.m.
The while loop will be executed exactly 0 or 1 times, depending on
env->exit_request.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 cpu-exec.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

Patch

diff --git a/cpu-exec.c b/cpu-exec.c
index d974141..f00151f 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -596,17 +596,13 @@  int cpu_exec(CPUState *env1)
                     tb_add_jump((TranslationBlock *)(next_tb & ~3), next_tb & 3, tb);
                 }
                 spin_unlock(&tb_lock);
-                env->current_tb = tb;
-                assert (env->current_tb);
 
                 /* cpu_interrupt might be called while translating the
                    TB, but before it is linked into a potentially
                    infinite loop and becomes env->current_tb. Avoid
                    starting execution if there is a pending interrupt. */
-                if (unlikely (env->exit_request))
-                    env->current_tb = NULL;
-
-                while (env->current_tb) {
+                if (!unlikely (env->exit_request)) {
+                    env->current_tb = tb;
                     tc_ptr = tb->tc_ptr;
                 /* execute the generated code */
 #if defined(__sparc__) && !defined(CONFIG_SOLARIS)
@@ -643,8 +639,8 @@  int cpu_exec(CPUState *env1)
                             cpu_loop_exit();
                         }
                     }
-                    assert (env->current_tb == NULL);
                 }
+                assert (env->current_tb == NULL);
                 /* reset soft MMU for next block (it can currently
                    only be set by a memory fault) */
             } /* for(;;) */