From patchwork Thu Mar 28 15:32:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 232075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BF3592C00C2 for ; Fri, 29 Mar 2013 02:39:03 +1100 (EST) Received: from localhost ([::1]:38269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULEur-0006wH-Vh for incoming@patchwork.ozlabs.org; Thu, 28 Mar 2013 11:39:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULEpq-0001bh-A6 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 11:33:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULEpn-0003da-B6 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 11:33:50 -0400 Received: from mail-pd0-f172.google.com ([209.85.192.172]:53763) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULEpn-0003dU-20 for qemu-devel@nongnu.org; Thu, 28 Mar 2013 11:33:47 -0400 Received: by mail-pd0-f172.google.com with SMTP id w10so4166900pde.3 for ; Thu, 28 Mar 2013 08:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=uXz4akqXr9MqIiN+8aOr+zEWvklD+/x45aA0ozNYe24=; b=r+AMIBPGjH3rtLzwIBzxcziqOgsDypDavyzbanXlMYLmyFDUGvqEqsh6UFNzYPU7ng rvLWxbHr68SBKVgK7ov6hXkMoPJ7lCBU0LAUTNcqy+Sb6l1+e1pnDxXFxadMAwPQvAmC O11Dw+YUZ0dbAWgsbgygHvozZhXSgtnkiv5ohEGcmzFBPnpmrpoqY9RtEIx0QqMYFIkJ o3I2gewMoupvstYy94zg+52IZ2c2yuvNjGT4QmMxYzQhrTgV2aj0jMYDBWAZZzaDCyEw ramPjp0yg+eRkA9T5iTPFyiZ0RXjvZRsqHuSoxQrncIO+cjJlZ594wlGQMhFvNOylWIU HG6Q== X-Received: by 10.66.197.197 with SMTP id iw5mr36699063pac.89.1364484826448; Thu, 28 Mar 2013 08:33:46 -0700 (PDT) Received: from fremont.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPS id kb3sm25939542pbc.21.2013.03.28.08.33.40 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 28 Mar 2013 08:33:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 28 Mar 2013 08:32:55 -0700 Message-Id: <1364484781-15561-15-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1364484781-15561-1-git-send-email-rth@twiddle.net> References: <1364484781-15561-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.192.172 Cc: Peter Maydell , Aurelien Jarno Subject: [Qemu-devel] [PATCH v3 14/20] tcg-arm: Cleanup goto_tb handling 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 Eliminate 2 disabled code blocks. Choose the load-to-pc method of jumping so that we can eliminate the 16M code_gen_buffer limitation. Remove a test in the indirect jump method that is always true. Signed-off-by: Richard Henderson --- include/exec/exec-all.h | 23 +++-------------------- tcg/arm/tcg-target.c | 26 ++++++-------------------- translate-all.c | 2 -- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index e856191..190effa 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -233,26 +233,9 @@ static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) #elif defined(__arm__) static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) { -#if !QEMU_GNUC_PREREQ(4, 1) - register unsigned long _beg __asm ("a1"); - register unsigned long _end __asm ("a2"); - register unsigned long _flg __asm ("a3"); -#endif - - /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */ - *(uint32_t *)jmp_addr = - (*(uint32_t *)jmp_addr & ~0xffffff) - | (((addr - (jmp_addr + 8)) >> 2) & 0xffffff); - -#if QEMU_GNUC_PREREQ(4, 1) - __builtin___clear_cache((char *) jmp_addr, (char *) jmp_addr + 4); -#else - /* flush icache */ - _beg = jmp_addr; - _end = jmp_addr + 4; - _flg = 0; - __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg)); -#endif + /* We're using "ldr pc, [pc,#-4]", so we can just store the raw + address, without caring for flushing the icache. */ + *(uint32_t *)jmp_addr = addr; } #elif defined(__sparc__) void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 7bcba19..6de5e90 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -1595,30 +1595,16 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_goto_tb: if (s->tb_jmp_offset) { - /* Direct jump method */ -#if defined(USE_DIRECT_JUMP) - s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; - tcg_out_b_noaddr(s, COND_AL); -#else + /* "Direct" jump method. Rather than limit the code gen buffer + to 16M, load the destination from the next word. */ tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4); s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf; - tcg_out32(s, 0); -#endif + s->code_ptr += 4; } else { - /* Indirect jump method */ -#if 1 - c = (int) (s->tb_next + args[0]) - ((int) s->code_ptr + 8); - if (c > 0xfff || c < -0xfff) { - tcg_out_movi32(s, COND_AL, TCG_REG_R0, - (tcg_target_long) (s->tb_next + args[0])); - tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0); - } else - tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, c); -#else - tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0); + /* Indirect jump method. */ + tcg_out_movi32(s, COND_AL, TCG_REG_R0, + (tcg_target_long) (s->tb_next + args[0])); tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0); - tcg_out32(s, (tcg_target_long) (s->tb_next + args[0])); -#endif } s->tb_next_offset[args[0]] = s->code_ptr - s->code_buf; break; diff --git a/translate-all.c b/translate-all.c index a98c646..3ca839f 100644 --- a/translate-all.c +++ b/translate-all.c @@ -460,8 +460,6 @@ static inline PageDesc *page_find(tb_page_addr_t index) # define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) #elif defined(__sparc__) # define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) -#elif defined(__arm__) -# define MAX_CODE_GEN_BUFFER_SIZE (16u * 1024 * 1024) #elif defined(__s390x__) /* We have a +- 4GB range on the branches; leave some slop. */ # define MAX_CODE_GEN_BUFFER_SIZE (3ul * 1024 * 1024 * 1024)