aboutsummaryrefslogtreecommitdiff
path: root/cpu-exec.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-01-26 12:12:22 +0100
committerMichael Tokarev <mjt@tls.msk.ru>2015-02-10 09:27:20 +0300
commit52851b7e3d816502b8ae4e8353f31fd9ee801509 (patch)
treedf8d97a8a89bc441f5304ba5b198470686a2191e /cpu-exec.c
parenta7fa2e9783ee957635d23ddab151a8be97df5b2a (diff)
cpu-exec: simplify icount code
Use MIN instead of an "if" statement. Move "tb" assignment where the value is actually used. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'cpu-exec.c')
-rw-r--r--cpu-exec.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/cpu-exec.c b/cpu-exec.c
index 4ff1b236a1..67381176da 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -499,22 +499,17 @@ int cpu_exec(CPUArchState *env)
case TB_EXIT_ICOUNT_EXPIRED:
{
/* Instruction counter expired. */
- int insns_left;
- tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
- insns_left = cpu->icount_decr.u32;
+ int insns_left = cpu->icount_decr.u32;
if (cpu->icount_extra && insns_left >= 0) {
/* Refill decrementer and continue execution. */
cpu->icount_extra += insns_left;
- if (cpu->icount_extra > 0xffff) {
- insns_left = 0xffff;
- } else {
- insns_left = cpu->icount_extra;
- }
+ insns_left = MIN(0xffff, cpu->icount_extra);
cpu->icount_extra -= insns_left;
cpu->icount_decr.u16.low = insns_left;
} else {
if (insns_left > 0) {
/* Execute remaining instructions. */
+ tb = (TranslationBlock *)(next_tb & ~TB_EXIT_MASK);
cpu_exec_nocache(env, insns_left, tb);
align_clocks(&sc, cpu);
}