From patchwork Thu Aug 29 22:05:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 270981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DDF912C00A9 for ; Fri, 30 Aug 2013 08:28:14 +1000 (EST) Received: from localhost ([::1]:46079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFAOP-0002Rs-76 for incoming@patchwork.ozlabs.org; Thu, 29 Aug 2013 18:08:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFAMY-0008Oy-6c for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:06:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFAMR-00015Q-Ah for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:06:46 -0400 Received: from mail-qa0-x236.google.com ([2607:f8b0:400d:c00::236]:50266) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFAMR-00015M-6C for qemu-devel@nongnu.org; Thu, 29 Aug 2013 18:06:39 -0400 Received: by mail-qa0-f54.google.com with SMTP id cm18so764962qab.20 for ; Thu, 29 Aug 2013 15:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=E+c3JTF1naLSi7xlUil4TayXTH+vrCV2vCPVlqKJbwE=; b=fP5VLU5xeUjjOvwyYMjLxGGjAyp83CSkIAz2OJaInub+4lhC4NraOD0FnLiOP6LXUB kMcYgWb3vN3GDZgFSUTW1dtemAAkoXMnIklYeT5QG4c0IIZTwZTrF0G+FTjykPi0QCi5 NZT5+KtAaJVjsm3dV0p/xPXNwShKtk2oC7NxcK2QnoUS6yyiAa4dPOKaCytptZ+gOtXV AkCf3/AJ3Z6L0uWvnAaWpGgdYeQuOqzud6n6kPd6DFEFBPuFfI3DvEZkS7k8NRsNgoFc d36H1erJwVGnc7cb2HLO2MfxqccWtnINymYANBdyeEQ70uZ73BzRk2/5Qwqc3IzRQthe Jxlw== X-Received: by 10.224.160.130 with SMTP id n2mr7804475qax.68.1377813998821; Thu, 29 Aug 2013 15:06:38 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id y2sm45439144qen.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 29 Aug 2013 15:06:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 29 Aug 2013 15:05:56 -0700 Message-Id: <1377813961-12208-3-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1377813961-12208-1-git-send-email-rth@twiddle.net> References: <1377813961-12208-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c00::236 Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH v2 2/7] tcg-i386: Don't perform GETPC adjustment in TCG code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since we now perform it inside the helper, no need to do it here. This also lets us perform a tail-call from the store slow path to the helper. Signed-off-by: Richard Henderson Reviewed-by: Aurelien Jarno --- tcg/i386/tcg-target.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c index 12a7ca3..84f17fe 100644 --- a/tcg/i386/tcg-target.c +++ b/tcg/i386/tcg-target.c @@ -1470,12 +1470,6 @@ static void add_qemu_ldst_label(TCGContext *s, } } -/* See the GETPC definition in include/exec/exec-all.h. */ -static inline uintptr_t do_getpc(uint8_t *raddr) -{ - return (uintptr_t)raddr - 1; -} - /* * Generate code for the slow path for a load at the end of block */ @@ -1509,14 +1503,14 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, l->mem_index); ofs += 4; - tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, do_getpc(l->raddr)); + tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, (uintptr_t)l->raddr); } else { tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); /* The second argument is already loaded with addrlo. */ tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2], l->mem_index); tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[3], - do_getpc(l->raddr)); + (uintptr_t)l->raddr); } tcg_out_calli(s, (tcg_target_long)qemu_ld_helpers[s_bits]); @@ -1571,6 +1565,7 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) int opc = l->opc; int s_bits = opc & 3; uint8_t **label_ptr = &l->label_ptr[0]; + TCGReg retaddr; /* resolve label address */ *(uint32_t *)label_ptr[0] = (uint32_t)(s->code_ptr - label_ptr[0] - 4); @@ -1603,10 +1598,10 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, l->mem_index); ofs += 4; - tcg_out_sti(s, TCG_TYPE_I32, TCG_REG_ESP, ofs, do_getpc(l->raddr)); + retaddr = TCG_REG_EAX; + tcg_out_movi(s, TCG_TYPE_I32, retaddr, (uintptr_t)l->raddr); + tcg_out_st(s, TCG_TYPE_I32, retaddr, TCG_REG_ESP, ofs); } else { - uintptr_t pc; - tcg_out_mov(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[0], TCG_AREG0); /* The second argument is already loaded with addrlo. */ tcg_out_mov(s, (opc == 3 ? TCG_TYPE_I64 : TCG_TYPE_I32), @@ -1614,20 +1609,19 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[3], l->mem_index); - pc = do_getpc(l->raddr); if (ARRAY_SIZE(tcg_target_call_iarg_regs) > 4) { - tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_iarg_regs[4], pc); - } else if (pc == (int32_t)pc) { - tcg_out_sti(s, TCG_TYPE_PTR, TCG_REG_ESP, 0, pc); + retaddr = tcg_target_call_iarg_regs[4]; + tcg_out_movi(s, TCG_TYPE_PTR, retaddr, (uintptr_t)l->raddr); } else { - tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_RAX, pc); - tcg_out_st(s, TCG_TYPE_PTR, TCG_REG_RAX, TCG_REG_ESP, 0); + retaddr = TCG_REG_RAX; + tcg_out_movi(s, TCG_TYPE_PTR, retaddr, (uintptr_t)l->raddr); + tcg_out_st(s, TCG_TYPE_PTR, retaddr, TCG_REG_ESP, 0); } } - tcg_out_calli(s, (tcg_target_long)qemu_st_helpers[s_bits]); - - tcg_out_jmp(s, (tcg_target_long)l->raddr); + /* "Tail call" to the helper, with the return address back inline. */ + tcg_out_push(s, retaddr); + tcg_out_jmp(s, (tcg_target_long)qemu_st_helpers[s_bits]); } /*