mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 23:35:33 +00:00
cpu-exec: lookup/generate TB outside exclusive region during step_atomic
Now that all code generation has been converted to check CF_PARALLEL, we can generate !CF_PARALLEL code without having yet set !parallel_cpus -- and therefore without having to be in the exclusive region during cpu_exec_step_atomic. While at it, merge cpu_exec_step into cpu_exec_step_atomic. Backports commit ac03ee5331612e44beb393df2b578c951d27dc0d from qemu
This commit is contained in:
parent
c1e26c4e35
commit
b1b069e8ad
|
@ -466,27 +466,32 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpu_exec_step(struct uc_struct *uc, CPUState *cpu)
|
void cpu_exec_step_atomic(struct uc_struct *uc, CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
|
CPUArchState *env = (CPUArchState *)cpu->env_ptr;
|
||||||
TranslationBlock *tb;
|
TranslationBlock *tb;
|
||||||
target_ulong cs_base, pc;
|
target_ulong cs_base, pc;
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t cflags = 1 | CF_IGNORE_ICOUNT;
|
uint32_t cflags = 1 | CF_IGNORE_ICOUNT;
|
||||||
|
uint32_t cf_mask = cflags & CF_HASH_MASK;
|
||||||
|
|
||||||
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
|
cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags);
|
||||||
|
|
||||||
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
|
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
|
||||||
tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags,
|
tb = tb_lookup__cpu_state(cpu, &pc, &cs_base, &flags, cf_mask);
|
||||||
cflags & CF_HASH_MASK);
|
|
||||||
if (tb == NULL) {
|
if (tb == NULL) {
|
||||||
mmap_lock();
|
mmap_lock();
|
||||||
|
tb = tb_htable_lookup(cpu, pc, cs_base, flags, cf_mask);
|
||||||
|
if (likely(tb == NULL)) {
|
||||||
tb = tb_gen_code(cpu, pc, cs_base, flags, cflags);
|
tb = tb_gen_code(cpu, pc, cs_base, flags, cflags);
|
||||||
|
}
|
||||||
mmap_unlock();
|
mmap_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uc->parallel_cpus = false;
|
||||||
/* execute the generated code */
|
/* execute the generated code */
|
||||||
cpu_tb_exec(cpu, tb);
|
cpu_tb_exec(cpu, tb);
|
||||||
|
uc->parallel_cpus = true;
|
||||||
} else {
|
} else {
|
||||||
/* We may have exited due to another problem here, so we need
|
/* We may have exited due to another problem here, so we need
|
||||||
* to reset any tb_locks we may have taken but didn't release.
|
* to reset any tb_locks we may have taken but didn't release.
|
||||||
|
@ -502,20 +507,6 @@ static void cpu_exec_step(struct uc_struct *uc, CPUState *cpu)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_exec_step_atomic(struct uc_struct *uc, CPUState *cpu)
|
|
||||||
{
|
|
||||||
// Unicorn: commented out
|
|
||||||
//start_exclusive();
|
|
||||||
|
|
||||||
/* Since we got here, we know that parallel_cpus must be true. */
|
|
||||||
uc->parallel_cpus = false;
|
|
||||||
cpu_exec_step(uc, cpu);
|
|
||||||
uc->parallel_cpus = true;
|
|
||||||
|
|
||||||
// Unicorn: commented out
|
|
||||||
//end_exclusive();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* main execution loop */
|
/* main execution loop */
|
||||||
|
|
||||||
int cpu_exec(struct uc_struct *uc, CPUState *cpu)
|
int cpu_exec(struct uc_struct *uc, CPUState *cpu)
|
||||||
|
|
Loading…
Reference in a new issue