提交 a42cf3f3 编写于 作者: P Paolo Bonzini

cpu-exec: avoid repeated sigsetjmp on interrupts

The sigsetjmp only needs to be prepared once for the whole execution
of cpu_exec.  This patch takes care of the "== 0" side, using a
nested loop so that cpu_handle_interrupt goes straight back to
cpu_handle_exception without doing another sigsetjmp.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 209b71b6
...@@ -627,14 +627,11 @@ int cpu_exec(CPUState *cpu) ...@@ -627,14 +627,11 @@ int cpu_exec(CPUState *cpu)
for(;;) { for(;;) {
/* prepare setjmp context for exception handling */ /* prepare setjmp context for exception handling */
if (sigsetjmp(cpu->jmp_env, 0) == 0) { if (sigsetjmp(cpu->jmp_env, 0) == 0) {
/* if an exception is pending, we execute it here */
while (!cpu_handle_exception(cpu, &ret)) {
TranslationBlock *last_tb = NULL; TranslationBlock *last_tb = NULL;
int tb_exit = 0; int tb_exit = 0;
/* if an exception is pending, we execute it here */
if (cpu_handle_exception(cpu, &ret)) {
break;
}
while (!cpu_handle_interrupt(cpu, &last_tb)) { while (!cpu_handle_interrupt(cpu, &last_tb)) {
TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit);
cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc);
...@@ -642,6 +639,9 @@ int cpu_exec(CPUState *cpu) ...@@ -642,6 +639,9 @@ int cpu_exec(CPUState *cpu)
if the guest is in advance */ if the guest is in advance */
align_clocks(&sc, cpu); align_clocks(&sc, cpu);
} }
}
break;
} else { } else {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
/* Some compilers wrongly smash all local variables after /* Some compilers wrongly smash all local variables after
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册