From patchwork Thu Jul 6 00:23:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9827365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1567760361 for ; Thu, 6 Jul 2017 00:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F80A285B3 for ; Thu, 6 Jul 2017 00:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0461E285B9; Thu, 6 Jul 2017 00:29:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7619E285B3 for ; Thu, 6 Jul 2017 00:29:53 +0000 (UTC) Received: from localhost ([::1]:48645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSug4-00035l-LN for patchwork-qemu-devel@patchwork.kernel.org; Wed, 05 Jul 2017 20:29:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dSuaq-0007Pj-BM for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dSuap-0002Mb-A5 for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:28 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:33869) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dSuap-0002MW-5m for qemu-devel@nongnu.org; Wed, 05 Jul 2017 20:24:27 -0400 Received: by mail-qt0-x244.google.com with SMTP id m54so645233qtb.1 for ; Wed, 05 Jul 2017 17:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=KdxOpIn7expYDVmuToYLNLB06Cj4xS3Ky//rBKQoVBo=; b=YAzz8NGDapL62Y2so3A/iRR+eVzFBi4h3d/HAtML20YftYk55Z/rJDjBH0wqDUDnr3 HD+S2GHBRPFaGBCgwOMZeT9gHrAhjfQKDhssMVXgNpq7CCp38TUQwAepd+n9PjlC+NOx /mPyjp0eFtNtNuXAZkubWTbxVqcdPvzSx2DwWvqDrmMyAHpb4SOlqlLM7LYg8pTc6Bmm FHy1s197sRs0jABt/dJDxzmYxVkO9E0Yo+8CWvgGPi8GOMBB0Y48gAcK12moiMOwEt6J enSdKqHGkToXe7TpYW/piLeR3gDZolaSA3WKHHDgL9boT5lpBCSTtW7WDWVgCI8JWHzG PiZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=KdxOpIn7expYDVmuToYLNLB06Cj4xS3Ky//rBKQoVBo=; b=EmX2y7beRuubsKn178capJmZPsjKC/DPZWxNoXzs1doU30DlBpchzMdLTWk1FSHOnU SvGh512hPBP9377tVquucTIFloDnmXJD20GXIg11jOspFN5P3kr1RiZsv1U0yB/OSmW6 s9hDBEEn8SFXgT0Tu7+kkzt9GsyVXGPn4fp/2FeZcO0bd/49PZWHo97rPPSFEGj1ErdM pVXL33PaAvBtdjw/RNJ+Q47F2FhRU5VO5JED0rxNpyGYCJ3tUAra/3MxavqXvPXtFecI 7vR95IuTVcCu+rnAOjkobcfklk3HSt0lFNeFcfM2YF3ZbutD3fGtnO30AJdEXAtbm2EC aniA== X-Gm-Message-State: AKS2vOySWMegupPEqO7hOF9HkaFLNNY95XU9jiwLGXHqUFR+iobtroBR 96QReAJZ7JI3PGtrsPg= X-Received: by 10.200.48.38 with SMTP id f35mr56928196qte.88.1499300666553; Wed, 05 Jul 2017 17:24:26 -0700 (PDT) Received: from bigtime.twiddle.net.com (rrcs-66-91-136-156.west.biz.rr.com. [66.91.136.156]) by smtp.gmail.com with ESMTPSA id u85sm371825qku.42.2017.07.05.17.24.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jul 2017 17:24:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 5 Jul 2017 14:23:52 -1000 Message-Id: <20170706002401.10507-3-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170706002401.10507-1-rth@twiddle.net> References: <20170706002401.10507-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH 02/11] target/sh4: Consolidate end-of-TB tests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bruno@clisp.org, aurelien@aurel32.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We can fold 3 different tests within the decode loop into a more accurate computation of max_insns to start. Signed-off-by: Richard Henderson Reviewed-by: Aurelien Jarno --- target/sh4/translate.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 6b247fa..e1661e9 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -1856,7 +1856,6 @@ void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb) ctx.features = env->features; ctx.has_movcal = (ctx.tbflags & TB_FLAG_PENDING_MOVCA); - num_insns = 0; max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; @@ -1864,9 +1863,23 @@ void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb) if (max_insns > TCG_MAX_INSNS) { max_insns = TCG_MAX_INSNS; } + /* Since the ISA is fixed-width, we can bound by the number + of instructions remaining on the page. */ + num_insns = (TARGET_PAGE_SIZE - (ctx.pc & (TARGET_PAGE_SIZE - 1))) / 2; + if (max_insns > num_insns) { + max_insns = num_insns; + } + /* Single stepping means just that. */ + if (ctx.singlestep_enabled || singlestep) { + max_insns = 1; + } gen_tb_start(tb); - while (ctx.bstate == BS_NONE && !tcg_op_buf_full()) { + num_insns = 0; + + while (ctx.bstate == BS_NONE + && num_insns < max_insns + && !tcg_op_buf_full()) { tcg_gen_insn_start(ctx.pc, ctx.envflags); num_insns++; @@ -1890,18 +1903,10 @@ void gen_intermediate_code(CPUSH4State * env, struct TranslationBlock *tb) ctx.opcode = cpu_lduw_code(env, ctx.pc); decode_opc(&ctx); ctx.pc += 2; - if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) - break; - if (cs->singlestep_enabled) { - break; - } - if (num_insns >= max_insns) - break; - if (singlestep) - break; } - if (tb->cflags & CF_LAST_IO) + if (tb->cflags & CF_LAST_IO) { gen_io_end(); + } if (cs->singlestep_enabled) { gen_save_cpu_state(&ctx, true); gen_helper_debug(cpu_env);