translate-all: Change tb_flush() env argument to cpu

All of the core-code usages of this API have the cpu pointer handy so
pass it in. There are only 3 architecture specific usages (2 of which
are commented out) which can just use ENV_GET_CPU() locally to get the
cpu pointer. The reduces core code usage of the CPU env, which brings
us closer to common-obj'ing these core files.

Backports commit bbd77c180d7ff1b04a7661bb878939b2e1d23798 from qemu
This commit is contained in:
Peter Crosthwaite 2018-02-14 13:56:00 -05:00 committed by Lioncash
parent 79c95aa18b
commit 8200453545
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
5 changed files with 6 additions and 8 deletions

View file

@ -282,7 +282,7 @@ int cpu_exec(struct uc_struct *uc, CPUArchState *env) // qq
// Unicorn: flush JIT cache to because emulation might stop in
// the middle of translation, thus generate incomplete code.
// TODO: optimize this for better performance
tb_flush(env);
tb_flush(cpu);
/* fail safe : never use current_cpu outside cpu_exec() */
uc->current_cpu = NULL;

View file

@ -631,8 +631,7 @@ void cpu_single_step(CPUState *cpu, int enabled)
cpu->singlestep_enabled = enabled;
/* must flush all the translated code to avoid inconsistencies */
/* XXX: only flush what is necessary */
env = cpu->env_ptr;
tb_flush(env);
tb_flush(cpu);
}
#endif
}

View file

@ -184,7 +184,7 @@ struct TBContext {
};
void tb_free(struct uc_struct *uc, TranslationBlock *tb);
void tb_flush(CPUArchState *env);
void tb_flush(CPUState *cpu);
void tb_phys_invalidate(struct uc_struct *uc,
TranslationBlock *tb, tb_page_addr_t page_addr);

View file

@ -7566,7 +7566,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
gen_debug(s, pc_start - s->cs_base);
#else
/* start debug */
tb_flush(env);
tb_flush(CPU(x86_env_get_cpu(env)));
qemu_set_log(CPU_LOG_INT | CPU_LOG_TB_IN_ASM);
#endif
break;

View file

@ -836,9 +836,8 @@ static void page_flush_tb(struct uc_struct *uc)
/* flush all the translation blocks */
/* XXX: tb_flush is currently not thread safe */
void tb_flush(CPUArchState *env1)
void tb_flush(CPUState *cpu)
{
CPUState *cpu = ENV_GET_CPU(env1);
struct uc_struct* uc = cpu->uc;
TCGContext *tcg_ctx = uc->tcg_ctx;
@ -1103,7 +1102,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
tb = tb_alloc(env->uc, pc);
if (!tb) {
/* flush must be done */
tb_flush(env);
tb_flush(cpu);
/* cannot fail at this point */
tb = tb_alloc(env->uc, pc);
/* Don't forget to invalidate previous TB info. */