tcg: Pass last_tb by value to tb_find_fast()

This is a small clean up. tb_find_fast() is a final consumer of this
variable so no need to pass it by reference. 'last_tb' is always updated
by subsequent cpu_loop_exec_tb() in cpu_exec().

This change also simplifies calling cpu_exec_nocache() in
cpu_handle_exception().

Backports commit 4b7e69509df2fcbfdab8c62c294dbfcfdab8a6e1 from qemu
This commit is contained in:
Sergey Fedorov 2018-02-25 23:23:14 -05:00 committed by Lioncash
parent cc45b82472
commit 371101a184
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -180,7 +180,7 @@ found:
} }
static inline TranslationBlock *tb_find_fast(CPUState *cpu, static inline TranslationBlock *tb_find_fast(CPUState *cpu,
TranslationBlock **last_tb, TranslationBlock *last_tb,
int tb_exit) int tb_exit)
{ {
CPUArchState *env = (CPUArchState *)cpu->env_ptr; CPUArchState *env = (CPUArchState *)cpu->env_ptr;
@ -203,7 +203,7 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,
/* Ensure that no TB jump will be modified as the /* Ensure that no TB jump will be modified as the
* translation buffer has been flushed. * translation buffer has been flushed.
*/ */
*last_tb = NULL; last_tb = NULL;
cpu->tb_flushed = false; cpu->tb_flushed = false;
} }
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
@ -212,12 +212,12 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu,
* spanning two pages because the mapping for the second page can change. * spanning two pages because the mapping for the second page can change.
*/ */
if (tb->page_addr[1] != -1) { if (tb->page_addr[1] != -1) {
*last_tb = NULL; last_tb = NULL;
} }
#endif #endif
/* See if we can patch the calling TB. */ /* See if we can patch the calling TB. */
if (*last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { if (last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
tb_add_jump(*last_tb, tb_exit, tb); tb_add_jump(last_tb, tb_exit, tb);
} }
// Unicorn: commented out // Unicorn: commented out
//tb_unlock(); //tb_unlock();
@ -444,7 +444,7 @@ int cpu_exec(struct uc_struct *uc, CPUState *cpu)
cpu->tb_flushed = false; /* reset before first TB lookup */ cpu->tb_flushed = false; /* reset before first TB lookup */
for(;;) { for(;;) {
cpu_handle_interrupt(cpu, &last_tb); cpu_handle_interrupt(cpu, &last_tb);
tb = tb_find_fast(cpu, &last_tb, tb_exit); tb = tb_find_fast(cpu, last_tb, tb_exit);
if (!tb) { // invalid TB due to invalid code? if (!tb) { // invalid TB due to invalid code?
uc->invalid_error = UC_ERR_FETCH_UNMAPPED; uc->invalid_error = UC_ERR_FETCH_UNMAPPED;
ret = EXCP_HLT; ret = EXCP_HLT;