Commit e6e35b1ea3395d8c2e750fc515b00cf24c86d892

Authored by aliguori
1 parent e568902a

qemu: refactor tcg cpu execution loop (Marcelo Tosatti)

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7246 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 29 additions and 24 deletions
@@ -3951,6 +3951,30 @@ static int qemu_cpu_exec(CPUState *env) @@ -3951,6 +3951,30 @@ static int qemu_cpu_exec(CPUState *env)
3951 return ret; 3951 return ret;
3952 } 3952 }
3953 3953
  3954 +static void tcg_cpu_exec(void)
  3955 +{
  3956 + int ret;
  3957 +
  3958 + if (next_cpu == NULL)
  3959 + next_cpu = first_cpu;
  3960 + for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {
  3961 + CPUState *env = cur_cpu = next_cpu;
  3962 +
  3963 + if (!vm_running)
  3964 + break;
  3965 + if (timer_alarm_pending) {
  3966 + timer_alarm_pending = 0;
  3967 + break;
  3968 + }
  3969 + ret = qemu_cpu_exec(env);
  3970 + if (ret == EXCP_DEBUG) {
  3971 + gdb_set_stop_cpu(env);
  3972 + debug_requested = 1;
  3973 + break;
  3974 + }
  3975 + }
  3976 +}
  3977 +
3954 static int cpu_has_work(CPUState *env) 3978 static int cpu_has_work(CPUState *env)
3955 { 3979 {
3956 if (!env->halted) 3980 if (!env->halted)
@@ -4034,31 +4058,13 @@ static int vm_can_run(void) @@ -4034,31 +4058,13 @@ static int vm_can_run(void)
4034 4058
4035 static void main_loop(void) 4059 static void main_loop(void)
4036 { 4060 {
4037 - int ret = 0;  
4038 -#ifdef CONFIG_PROFILER  
4039 - int64_t ti;  
4040 -#endif  
4041 -  
4042 for (;;) { 4061 for (;;) {
4043 - do {  
4044 - if (next_cpu == NULL)  
4045 - next_cpu = first_cpu;  
4046 - for (; next_cpu != NULL; next_cpu = next_cpu->next_cpu) {  
4047 - CPUState *env = cur_cpu = next_cpu;  
4048 4062
4049 - if (!vm_running)  
4050 - break;  
4051 - if (timer_alarm_pending) {  
4052 - timer_alarm_pending = 0;  
4053 - break;  
4054 - }  
4055 - ret = qemu_cpu_exec(env);  
4056 - if (ret == EXCP_DEBUG) {  
4057 - gdb_set_stop_cpu(env);  
4058 - debug_requested = 1;  
4059 - break;  
4060 - }  
4061 - } 4063 + do {
  4064 +#ifdef CONFIG_PROFILER
  4065 + int64_t ti;
  4066 +#endif
  4067 + tcg_cpu_exec();
4062 #ifdef CONFIG_PROFILER 4068 #ifdef CONFIG_PROFILER
4063 ti = profile_getclock(); 4069 ti = profile_getclock();
4064 #endif 4070 #endif
@@ -4068,7 +4074,6 @@ static void main_loop(void) @@ -4068,7 +4074,6 @@ static void main_loop(void)
4068 #endif 4074 #endif
4069 } while (vm_can_run()); 4075 } while (vm_can_run());
4070 4076
4071 -  
4072 if (qemu_debug_requested()) 4077 if (qemu_debug_requested())
4073 vm_stop(EXCP_DEBUG); 4078 vm_stop(EXCP_DEBUG);
4074 if (qemu_shutdown_requested()) { 4079 if (qemu_shutdown_requested()) {