accel/tcg: Un-inline translator_is_same_page()
PATCH 1/1 accel/tcg: Un-inline translator_is_same_page()
Remove the single target-specific definition used in "exec/translator.h" (TARGET_PAGE_MASK) by un-inlining is_same_page().
Rename the method as translator_is_same_page() and improve its documentation.
Use it in translator_use_goto_tb().
---
Richard, I'll merge this myself once reviewed.
--- include/exec/translator.h | 15 +++++++-------- accel/tcg/translator.c | 7 ++++++- target/i386/tcg/translate.c | 6 +++--- target/riscv/translate.c | 4 ++-- target/s390x/tcg/translate.c | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-)
include/exec/translator.h +7 -8
@@ -267,16 +267,15 @@ bool translator_st(const DisasContextBase *db, void *dest,*/ size_t translator_st_len (const DisasContextBase *db); -#ifdef COMPILING_PER_TARGET -/* -* Return whether addr is on the same page as where disassembly started. +/** +* translator_is_same_page +* @db: disassembly context +* @addr: virtual address within TB +* +* Return whether @addr is on the same page as where disassembly started. * Translators can use this to enforce the rule that only single-insn * translation blocks are allowed to cross page boundaries. */ -static inline bool is_same_page (const DisasContextBase *db,vaddr addr) -{ -return ((addr ^ db->pc_first) &TARGET_PAGE_MASK ) ==0 ; -} -#endif +bool translator_is_same_page (const DisasContextBase *db,vaddr addr);#endif /* EXEC__TRANSLATOR_H */
accel/tcg/translator.c +6 -1
@@ -104,6 +104,11 @@ static void gen_tb_end(const TranslationBlock *tb, uint32_t cflags, } } +bool translator_is_same_page (const DisasContextBase *db,vaddr addr) +{ +return ((addr ^ db->pc_first) &TARGET_PAGE_MASK ) ==0 ; +} +bool translator_use_goto_tb (DisasContextBase *db,vaddr dest) {/* Suppress goto_tb if requested. */
@@ -112,7 +117,7 @@ bool translator_use_goto_tb(DisasContextBase *db, vaddr dest) }/* Check for the dest on the same page as the start of the TB. */ -return ((db->pc_first ^ dest) &TARGET_PAGE_MASK ) ==0 ; +return translator_is_same_page (db, dest); } void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
target/i386/tcg/translate.c +3 -3
@@ -1511,7 +1511,7 @@ static uint64_t advance_pc(CPUX86State *env, DisasContext *s, int num_bytes)/* This is a subsequent insn that crosses a page boundary. */ if (s->base.num_insns >1 && - !is_same_page (&s->base, s->pc + num_bytes -1 )) { + !translator_is_same_page (&s->base, s->pc + num_bytes -1 )) {siglongjmp (s->jmpbuf,2 ); }
@@ -2225,7 +2225,7 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, int diff, int tb_num)* no extra masking to apply (data16 branch in code32, see above), * then we have also proven that the addition does not wrap. */ -if (!use_goto_tb || !is_same_page (&s->base, new_pc)) { +if (!use_goto_tb || !translator_is_same_page (&s->base, new_pc)) {tcg_gen_andi_tl (cpu_eip, cpu_eip, mask); use_goto_tb = false; }
@@ -3762,7 +3762,7 @@ static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)* chance to happen. */ dc->base.is_jmp =DISAS_EOB_NEXT ; - }else if (!is_same_page (&dc->base, dc->base.pc_next)) { + }else if (!translator_is_same_page (&dc->base, dc->base.pc_next)) { dc->base.is_jmp =DISAS_TOO_MANY ; } }
target/riscv/translate.c +2 -2
@@ -1304,7 +1304,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)/* Only the first insn within a TB is allowed to cross a page boundary. */ if (ctx->base.is_jmp ==DISAS_NEXT ) { -if (ctx->itrigger || !is_same_page (&ctx->base, ctx->base.pc_next)) { +if (ctx->itrigger || !translator_is_same_page (&ctx->base, ctx->base.pc_next)) { ctx->base.is_jmp =DISAS_TOO_MANY ; }else {unsigned page_ofs = ctx->base.pc_next & ~TARGET_PAGE_MASK ;
@@ -1314,7 +1314,7 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)translator_lduw (env, &ctx->base, ctx->base.pc_next);int len =insn_len (next_insn); -if (!is_same_page (&ctx->base, ctx->base.pc_next + len -1 )) { +if (!translator_is_same_page (&ctx->base, ctx->base.pc_next + len -1 )) { ctx->base.is_jmp =DISAS_TOO_MANY ; } }
target/s390x/tcg/translate.c +2 -2
@@ -6422,8 +6422,8 @@ static void s390x_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) dc->base.is_jmp =translate_one (env, dc);if (dc->base.is_jmp ==DISAS_NEXT ) {if (dc->ex_value || - !is_same_page (dcbase, dc->base.pc_next) || - !is_same_page (dcbase,get_next_pc (env, dc, dc->base.pc_next))) { + !translator_is_same_page (dcbase, dc->base.pc_next) || + !translator_is_same_page (dcbase,get_next_pc (env, dc, dc->base.pc_next))) { dc->base.is_jmp =DISAS_TOO_MANY ; } }
Signature · 1 line
2.45.2
Quoted 10 lines · Philippe Mathieu-Daudé
Remove the single target-specific definition used in "
exec/translator.h" (TARGET_PAGE_MASK) by un-inliningis_same_page().
Rename the method astranslator_is_same_page()and improve its documentation.
Use it intranslator_use_goto_tb().Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Richard, I'll merge this myself once reviewed.
Quoted 7 lines
--- include/exec/translator.h | 15 +++++++-------- accel/tcg/translator.c | 7 ++++++- target/i386/tcg/translate.c | 6 +++--- target/riscv/translate.c | 4 ++-- target/s390x/tcg/translate.c | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-)
r~
Quoted 10 lines · Philippe Mathieu-Daudé
Remove the single target-specific definition used in "
exec/translator.h" (TARGET_PAGE_MASK) by un-inliningis_same_page().
Rename the method astranslator_is_same_page()and improve its documentation.
Use it intranslator_use_goto_tb().Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Richard, I'll merge this myself once reviewed.
Quoted 7 lines
--- include/exec/translator.h | 15 +++++++-------- accel/tcg/translator.c | 7 ++++++- target/i386/tcg/translate.c | 6 +++--- target/riscv/translate.c | 4 ++-- target/s390x/tcg/translate.c | 4 ++-- 5 files changed, 20 insertions(+), 16 deletions(-)
Patch queued.