[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 07/13] tcg/i386: implement goto_ptr op
From: |
Richard Henderson |
Subject: |
Re: [Qemu-devel] [PATCH v2 07/13] tcg/i386: implement goto_ptr op |
Date: |
Tue, 25 Apr 2017 13:24:00 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 |
On 04/25/2017 09:53 AM, Emilio G. Cota wrote:
+ case INDEX_op_goto_ptr:
+ /* save target address into new register */
+ tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_EDX, a0);
+ /* set return value to 0 */
+ tgen_arithr(s, ARITH_XOR, TCG_REG_EAX, TCG_REG_EAX);
+ /* jmp to the target address (could be epilogue) */
+ tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, TCG_REG_EDX);
+ break;
I've just thought of an improvement to be made here -- move the xor after the
jump (and therefore just before the "normal" epilogue) like so.
r~
diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index f6fb03e..f636557 100644
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -1907,12 +1907,8 @@ static inline void tcg_out_op
s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s);
break;
case INDEX_op_goto_ptr:
- /* save target address into new register */
- tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_EDX, a0);
- /* set return value to 0 */
- tgen_arithr(s, ARITH_XOR, TCG_REG_EAX, TCG_REG_EAX);
- /* jmp to the target address (could be epilogue) */
- tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, TCG_REG_EDX);
+ /* jmp to the given host address (could be epilogue) */
+ tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, a0);
break;
case INDEX_op_br:
tcg_out_jxx(s, JCC_JMP, arg_label(a0), 0);
@@ -2579,10 +2575,13 @@ static void tcg_target_qemu_prologue
tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, tcg_target_call_iarg_regs[1]);
#endif
- /* TB epilogue */
- tb_ret_addr = s->code_ptr;
+ /* Return path for goto_ptr. Set return value to 0, a-la exit_tb,
+ and fall through to the rest of the epilogue. */
s->code_gen_epilogue = s->code_ptr;
+ tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0);
+ /* TB epilogue */
+ tb_ret_addr = s->code_ptr;
tcg_out_addi(s, TCG_REG_CALL_STACK, stack_addend);
for (i = ARRAY_SIZE(tcg_target_callee_save_regs) - 1; i >= 0; i--) {
- [Qemu-devel] [PATCH v2 00/13] TCG optimizations for 2.10, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 03/13] tcg: enforce 64-byte alignment of TCGContext, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 01/13] exec-all: add tb_from_jmp_cache, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 07/13] tcg/i386: implement goto_ptr op, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 02/13] exec-all: inline tb_from_jmp_cache, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 08/13] target/arm: optimize cross-page block chaining in softmmu, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 11/13] target/i386: optimize cross-page direct jumps in softmmu, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 05/13] tcg-runtime: add lookup_tb_ptr helper, Emilio G. Cota, 2017/04/25
- [Qemu-devel] [PATCH v2 10/13] target/i386: introduce gen_jr() helper to jump to register, Emilio G. Cota, 2017/04/25