From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493263933911554.6159138842165; Wed, 26 Apr 2017 20:32:13 -0700 (PDT) Received: from localhost ([::1]:58516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aA8-0001T4-IE for importer@patchew.org; Wed, 26 Apr 2017 23:32:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007x9-Oc for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001xK-H1 for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:42819) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7T-0001rc-M6; Wed, 26 Apr 2017 23:29:27 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id C6427209B7; Wed, 26 Apr 2017 23:29:26 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:26 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 825587E442; Wed, 26 Apr 2017 23:29:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=LTg I8+SQUQtgdJbjg+armFqNHmkMOGbYMur40xS1XZs=; b=m9vk/645WHxkgK3y6S4 +YDdrmj8yZwXl3Ol6L5yUiTy9n8v5W3wp+kG5rLTY2LpxzjQewtvGGwLYVvHd0Zs 2Mw0zpQ/hO9wYi3M8sVJKsjtBYh2RNs8cYkclXO0Vbq88nqTtloMTlVKpG/3ChUd zzW14mx6CcfntEYJxDroGYfE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=LTgI8+SQUQtgdJbjg+armFqNHmkMOGbYMur40xS1X Zs=; b=QHRufICwRQPV2mFDDxAzVQcXcwv0gBdUHe4HdTArGLh/J56GHQOtNO3/u 5t0mhssRs/m1Lxfvbl0hULrJAo/XibwPNlXDMWPnzvNdhu75NOZ6k+NKILf6YwuP bF3zPKxoHJmaNWTMArcY4oxrWmqTz0xXcpseBao550YoFsx6I46l9ph0M6A7sGPO X1vhKhWBCWflsTqs4CBdlPY6mfNlPLfqXoCJL4pXpRbXL5N7DQpJeTw27JLEGB2p dnDejAUQmNhJTYpoDrf9L4Zar1+VkP1Hp6Hc+hG1OgsKbt+bJ6iKA2FU98bq/Hbz DfZJLKak6LnA2R0gaqddzsXRLqH/g== X-ME-Sender: X-Sasl-enc: L71SY92giyTeW/WH0SGuHFYhaxC+XclUw08PHU7M6/o+ 1493263766 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:14 -0400 Message-Id: <1493263764-18657-2-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 01/11] exec-all: export tb_htable_lookup 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- cpu-exec.c | 6 ++---- include/exec/exec-all.h | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 63a56d0..5b181c1 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -309,10 +309,8 @@ static bool tb_cmp(const void *p, const void *d) return false; } =20 -static TranslationBlock *tb_htable_lookup(CPUState *cpu, - target_ulong pc, - target_ulong cs_base, - uint32_t flags) +TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, + target_ulong cs_base, uint32_t flags) { tb_page_addr_t phys_pc; struct tb_desc desc; diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index bcde1e6..87ae10b 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -368,6 +368,8 @@ struct TranslationBlock { void tb_free(TranslationBlock *tb); void tb_flush(CPUState *cpu); void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr); +TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc, + target_ulong cs_base, uint32_t flags); =20 #if defined(USE_DIRECT_JUMP) =20 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264081072951.6781802274558; Wed, 26 Apr 2017 20:34:41 -0700 (PDT) Received: from localhost ([::1]:58526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aCU-0003ow-H7 for importer@patchew.org; Wed, 26 Apr 2017 23:34:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007wc-Cg for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001wv-A1 for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:45103) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7T-0001re-LP; Wed, 26 Apr 2017 23:29:27 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 05AF9209BB; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id B678E24765; Wed, 26 Apr 2017 23:29:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=un0wB+6T/PyIrof M/b1FaXHI8mMnu4bb1phNbAIG6vA=; b=sdqKlh/egEis7wJh0D8MdEUvxmWJkOL HG8MZrW9vG0fLzMGYgTqfmWYG7ijUpJngaZVXcZKDD3MeCv3EG7ijR+FpfZLBVlN /4EuhDsrWPQtWpYZ7JfRwUq8D2BW+sVLtKZseCDqg9vI/SjUdQhydWlMTThisHPY UgZDfY5twW9k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=un0wB+6T/PyIrofM/b1FaXHI8mMnu4bb1phNbAIG6vA=; b=CRrL53j9 LW8P/ARNZ8OYn1fX3SHpJydRgFQbyGuh8f2N2UdarqhH10HVTf5uMl2gM5QAX9d8 75Yl0rrLxC+8rSG7eCTMVOug3hxdCydh5gfYipzVILbw9bXwPIgtI0ZodzKYzgXX uslAH3urz79OX+uMOK3XbI0lHkn4fC4NZ8yijX5GLnPqxb8C1bj8bIvYqBO8O9fG HnjKSt7uRlWxRiiGzprIT1eh4c5/Tqull4BmJb62bsPgnhvLxjei2w4klbYEaPBu /9SHJXC/DDyIUEtgiFO58u9K5e7g0Snk0J4PMHvQsYkEdpnYF65qXWGyunXg6VdH 6rdKtgUpS60z+g== X-ME-Sender: X-Sasl-enc: L71Pbt+8jzjfT+6G2CeuHFYhaxC+XclUw08PHU7M6/o+ 1493263766 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:15 -0400 Message-Id: <1493263764-18657-3-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 02/11] tcg-runtime: add lookup_tb_ptr helper 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This paves the way for upcoming work. Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- tcg-runtime.c | 24 ++++++++++++++++++++++++ tcg/tcg-runtime.h | 2 ++ tcg/tcg.h | 1 + 3 files changed, 27 insertions(+) diff --git a/tcg-runtime.c b/tcg-runtime.c index 4c60c96..8a24bdd 100644 --- a/tcg-runtime.c +++ b/tcg-runtime.c @@ -27,6 +27,7 @@ #include "exec/helper-proto.h" #include "exec/cpu_ldst.h" #include "exec/exec-all.h" +#include "exec/tb-hash.h" =20 /* 32-bit helpers */ =20 @@ -141,6 +142,29 @@ uint64_t HELPER(ctpop_i64)(uint64_t arg) return ctpop64(arg); } =20 +void *HELPER(lookup_tb_ptr)(CPUArchState *env, target_ulong addr) +{ + CPUState *cpu =3D ENV_GET_CPU(env); + TranslationBlock *tb; + target_ulong cs_base, pc; + uint32_t flags; + + tb =3D atomic_rcu_read(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(addr)= ]); + if (likely(tb)) { + cpu_get_tb_cpu_state(env, &pc, &cs_base, &flags); + if (likely(tb->pc =3D=3D addr && tb->cs_base =3D=3D cs_base && + tb->flags =3D=3D flags)) { + return tb->tc_ptr; + } + tb =3D tb_htable_lookup(cpu, pc, cs_base, flags); + if (likely(tb)) { + atomic_set(&cpu->tb_jmp_cache[tb_jmp_cache_hash_func(addr)], t= b); + return tb->tc_ptr; + } + } + return tcg_ctx.code_gen_epilogue; +} + void HELPER(exit_atomic)(CPUArchState *env) { cpu_loop_exit_atomic(ENV_GET_CPU(env), GETPC()); diff --git a/tcg/tcg-runtime.h b/tcg/tcg-runtime.h index 114ea6f..c41d38a 100644 --- a/tcg/tcg-runtime.h +++ b/tcg/tcg-runtime.h @@ -24,6 +24,8 @@ DEF_HELPER_FLAGS_1(clrsb_i64, TCG_CALL_NO_RWG_SE, i64, i6= 4) DEF_HELPER_FLAGS_1(ctpop_i32, TCG_CALL_NO_RWG_SE, i32, i32) DEF_HELPER_FLAGS_1(ctpop_i64, TCG_CALL_NO_RWG_SE, i64, i64) =20 +DEF_HELPER_FLAGS_2(lookup_tb_ptr, TCG_CALL_NO_WG_SE, ptr, env, tl) + DEF_HELPER_FLAGS_1(exit_atomic, TCG_CALL_NO_WG, noreturn, env) =20 #ifdef CONFIG_SOFTMMU diff --git a/tcg/tcg.h b/tcg/tcg.h index 6c216bb..5ec48d1 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -699,6 +699,7 @@ struct TCGContext { extension that allows arithmetic on void*. */ int code_gen_max_blocks; void *code_gen_prologue; + void *code_gen_epilogue; void *code_gen_buffer; size_t code_gen_buffer_size; void *code_gen_ptr; --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264208787916.9260656730029; Wed, 26 Apr 2017 20:36:48 -0700 (PDT) Received: from localhost ([::1]:58543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aEZ-0005dP-34 for importer@patchew.org; Wed, 26 Apr 2017 23:36:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7c-0007yC-Cv for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001xX-RZ for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49623) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7T-0001rf-LX; Wed, 26 Apr 2017 23:29:27 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 415F520881; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id EA6997E442; Wed, 26 Apr 2017 23:29:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=YWZ p5zjnyX5CD7yGmPcc3ex9GgyrgzwnFmTAntYWf7U=; b=ua/F6N7bISRNANo/A9O Y7uanIT+gTw+YClv5KFvVYjCp0bLlqIcPhazIGmNfYokY3p2KCniEhMKe9L9DpoG jv7Z3+H64h+ik2SeKXCGC8R0uLHL8JlCaVoJA0B4fdci7AaIcE015yU0nSFkNUCc JCqXjO5VtZJcCe/pLix4NArE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=YWZp5zjnyX5CD7yGmPcc3ex9GgyrgzwnFmTAntYWf 7U=; b=N4P0OBoNttuAtLhpZMaDKm4km3dbCQ2+CHNwYv3diIOkOoveEsK7Ivnly 9Uw7uYiQff6jh7XE/P+2C5BJw9XeSjwpSgSr9RbZEK8SEv+aqQF72W1yfZ8KH9Ge orz3fc2BwogJHs2fyzlQzL0PP1EUerzI9VA/g/uanmh7B9yLCdPuG5kDoP4oRHea Mnoe6frmLDTRe1HuL5tuzKZRnWn6N9pbEpixBcGjLUeUlGteFqKBNXB9lvHPaLpV H3HVTRoNnv0Uw3uPyBY3yLw3C/F+WU/vna7ezUO0KngCpJa6rNzbIP5NCkPikdez KnZd5rENFYSi1fY+iLsf9xI8q9JSQ== X-ME-Sender: X-Sasl-enc: L71IbNy5jSvOXeCQzDyuHFYhaxC+XclUw08PHU7M6/o+ 1493263766 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:16 -0400 Message-Id: <1493263764-18657-4-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 03/11] tcg: introduce goto_ptr opcode 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Tested-by: Aurelien Jarno --- tcg/aarch64/tcg-target.h | 1 + tcg/arm/tcg-target.h | 1 + tcg/i386/tcg-target.h | 1 + tcg/ia64/tcg-target.h | 1 + tcg/mips/tcg-target.h | 1 + tcg/ppc/tcg-target.h | 1 + tcg/s390/tcg-target.h | 1 + tcg/sparc/tcg-target.h | 1 + tcg/tcg-opc.h | 1 + tcg/tci/tcg-target.h | 1 + 10 files changed, 10 insertions(+) diff --git a/tcg/aarch64/tcg-target.h b/tcg/aarch64/tcg-target.h index 1a5ea23..b82eac4 100644 --- a/tcg/aarch64/tcg-target.h +++ b/tcg/aarch64/tcg-target.h @@ -77,6 +77,7 @@ typedef enum { #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_extrl_i64_i32 0 #define TCG_TARGET_HAS_extrh_i64_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #define TCG_TARGET_HAS_div_i64 1 #define TCG_TARGET_HAS_rem_i64 1 diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 09a19c6..2f3ecfd 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -123,6 +123,7 @@ extern bool use_idiv_instructions; #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_div_i32 use_idiv_instructions #define TCG_TARGET_HAS_rem_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 enum { TCG_AREG0 =3D TCG_REG_R6, diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 4275787..59d9835 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -107,6 +107,7 @@ extern bool have_popcnt; #define TCG_TARGET_HAS_muls2_i32 1 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_extrl_i64_i32 0 diff --git a/tcg/ia64/tcg-target.h b/tcg/ia64/tcg-target.h index 42aea03..901bb75 100644 --- a/tcg/ia64/tcg-target.h +++ b/tcg/ia64/tcg-target.h @@ -173,6 +173,7 @@ typedef enum { #define TCG_TARGET_HAS_mulsh_i64 0 #define TCG_TARGET_HAS_extrl_i64_i32 0 #define TCG_TARGET_HAS_extrh_i64_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #define TCG_TARGET_deposit_i32_valid(ofs, len) ((len) <=3D 16) #define TCG_TARGET_deposit_i64_valid(ofs, len) ((len) <=3D 16) diff --git a/tcg/mips/tcg-target.h b/tcg/mips/tcg-target.h index f46d64a..e3240cf 100644 --- a/tcg/mips/tcg-target.h +++ b/tcg/mips/tcg-target.h @@ -130,6 +130,7 @@ extern bool use_mips32r2_instructions; #define TCG_TARGET_HAS_muluh_i32 1 #define TCG_TARGET_HAS_mulsh_i32 1 #define TCG_TARGET_HAS_bswap32_i32 1 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_add2_i32 0 diff --git a/tcg/ppc/tcg-target.h b/tcg/ppc/tcg-target.h index abd8b3d..a9aa974 100644 --- a/tcg/ppc/tcg-target.h +++ b/tcg/ppc/tcg-target.h @@ -82,6 +82,7 @@ extern bool have_isa_3_00; #define TCG_TARGET_HAS_muls2_i32 0 #define TCG_TARGET_HAS_muluh_i32 1 #define TCG_TARGET_HAS_mulsh_i32 1 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_add2_i32 0 diff --git a/tcg/s390/tcg-target.h b/tcg/s390/tcg-target.h index cbdd2a6..6b7bcfb 100644 --- a/tcg/s390/tcg-target.h +++ b/tcg/s390/tcg-target.h @@ -92,6 +92,7 @@ extern uint64_t s390_facilities; #define TCG_TARGET_HAS_mulsh_i32 0 #define TCG_TARGET_HAS_extrl_i64_i32 0 #define TCG_TARGET_HAS_extrh_i64_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #define TCG_TARGET_HAS_div2_i64 1 #define TCG_TARGET_HAS_rot_i64 1 diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h index b8b74f9..9348ddd 100644 --- a/tcg/sparc/tcg-target.h +++ b/tcg/sparc/tcg-target.h @@ -123,6 +123,7 @@ extern bool use_vis3_instructions; #define TCG_TARGET_HAS_muls2_i32 1 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #define TCG_TARGET_HAS_extrl_i64_i32 1 #define TCG_TARGET_HAS_extrh_i64_i32 1 diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h index f06f894..956fb1e 100644 --- a/tcg/tcg-opc.h +++ b/tcg/tcg-opc.h @@ -193,6 +193,7 @@ DEF(insn_start, 0, 0, TLADDR_ARGS * TARGET_INSN_START_W= ORDS, TCG_OPF_NOT_PRESENT) DEF(exit_tb, 0, 0, 1, TCG_OPF_BB_END) DEF(goto_tb, 0, 0, 1, TCG_OPF_BB_END) +DEF(goto_ptr, 0, 1, 0, TCG_OPF_BB_END | IMPL(TCG_TARGET_HAS_goto_ptr)) =20 DEF(qemu_ld_i32, 1, TLADDR_ARGS, 1, TCG_OPF_CALL_CLOBBER | TCG_OPF_SIDE_EFFECTS) diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h index 838bf3a..0696328 100644 --- a/tcg/tci/tcg-target.h +++ b/tcg/tci/tcg-target.h @@ -85,6 +85,7 @@ #define TCG_TARGET_HAS_muls2_i32 0 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 +#define TCG_TARGET_HAS_goto_ptr 0 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_extrl_i64_i32 0 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264072661730.8012456880072; Wed, 26 Apr 2017 20:34:32 -0700 (PDT) Received: from localhost ([::1]:58524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aCN-0003kV-5y for importer@patchew.org; Wed, 26 Apr 2017 23:34:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007xA-Oo for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001xC-FS for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:37549) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7T-0001rk-Oa; Wed, 26 Apr 2017 23:29:27 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6919D209C0; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 241EF24765; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=KUeRIIvUx4M7lTD /rQOOuo4KYHGQcYsB1NyAMpPLpVk=; b=tQvAI7y1cTtmifkQ6+sYmNEqjVRz/K4 r/PKsp3h1oHuscESXH0iSD93WA++7Ab4N7OflaysOYPr9uZtU67tOMrwvt2clZCc hh9NeX63eOXT57VIsccqrGmalCFmn1+rL12jFSoeJcCmrptWrEyMjrb21BhwIleT 4JRawSrSVTSQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=KUeRIIvUx4M7lTD/rQOOuo4KYHGQcYsB1NyAMpPLpVk=; b=RiLadL1V OMwzZ2c1LsNTpvLitVSf10pgGzzvAkGjL/GI/IDIGEEURIhTLJgh341QK13G+jal 9Z5xt1Q6Uf6Rml9FpZDxCzG0gKHfR5U0/XUyrJ0U6uuCrMP8bg0EshpCD/hqj2Xa pqU8dnOdA4bpfw+Z6DadpnnImGlqkVCh95kCrGmDFF7eIfvFi1hZoh5FJvTCHruZ honJRHP+mwoeMuU4D5vCCz0d/ltDJlptlbWpeCiPOcSxeh0JKb4KD/2ODtoEgjPj ELBk6PyKUnR4ABjw7Stox0yrRqBsqMjdvYiXrbmoBk6myVgrnd2KUWaHRb2TCR5Z ziBJASKPVU8u2A== X-ME-Sender: X-Sasl-enc: hcoZr/Kr34WYwAaKwzr5SUTmyb0a4EyUjYY9o1iz/VSx 1493263767 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:17 -0400 Message-Id: <1493263764-18657-5-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 04/11] tcg: export tcg_gen_lookup_and_goto_ptr 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Instead of exporting goto_ptr directly to TCG frontends, export tcg_gen_lookup_and_goto_ptr(), which calls goto_ptr with the pointer returned by the lookup_tb_ptr() helper. This is the only use case we have for goto_ptr and lookup_tb_ptr, so having this function is very convenient. Furthermore, it trivially allows us to avoid calling the lookup helper if goto_ptr is not implemented by the backend. Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- tcg/README | 8 ++++++++ tcg/tcg-op.c | 13 +++++++++++++ tcg/tcg-op.h | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/tcg/README b/tcg/README index a9858c2..bf49e82 100644 --- a/tcg/README +++ b/tcg/README @@ -477,6 +477,14 @@ current TB was linked to this TB. Otherwise execute th= e next instructions. Only indices 0 and 1 are valid and tcg_gen_goto_tb may be is= sued at most once with each slot index per TB. =20 +* lookup_and_goto_ptr tb_addr + +Look up a TB address ('tb_addr') and jump to it if valid. If not valid, +jump to the TCG epilogue to go back to the exec loop. + +This operation is optional. If the TCG backend does not implement the +goto_ptr opcode, emitting this op is equivalent to emitting exit_tb(0). + * qemu_ld_i32/i64 t0, t1, flags, memidx * qemu_st_i32/i64 t0, t1, flags, memidx =20 diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 95a39b7..8ff1eaf 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2587,6 +2587,19 @@ void tcg_gen_goto_tb(unsigned idx) tcg_gen_op1i(INDEX_op_goto_tb, idx); } =20 +void tcg_gen_lookup_and_goto_ptr(TCGv addr) +{ + if (TCG_TARGET_HAS_goto_ptr) { + TCGv_ptr ptr =3D tcg_temp_new_ptr(); + + gen_helper_lookup_tb_ptr(ptr, tcg_ctx.tcg_env, addr); + tcg_gen_op1i(INDEX_op_goto_ptr, GET_TCGV_PTR(ptr)); + tcg_temp_free_ptr(ptr); + } else { + tcg_gen_exit_tb(0); + } +} + static inline TCGMemOp tcg_canonicalize_memop(TCGMemOp op, bool is64, bool= st) { /* Trigger the asserts within as early as possible. */ diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h index c68e300..5d3278f 100644 --- a/tcg/tcg-op.h +++ b/tcg/tcg-op.h @@ -796,6 +796,17 @@ static inline void tcg_gen_exit_tb(uintptr_t val) */ void tcg_gen_goto_tb(unsigned idx); =20 +/** + * tcg_gen_lookup_and_goto_ptr() - look up a TB and jump to it if valid + * @addr: Guest address of the target TB + * + * If the TB is not valid, jump to the epilogue. + * + * This operation is optional. If the TCG backend does not implement goto_= ptr, + * this op is equivalent to calling tcg_gen_exit_tb() with 0 as the argume= nt. + */ +void tcg_gen_lookup_and_goto_ptr(TCGv addr); + #if TARGET_LONG_BITS =3D=3D 32 #define tcg_temp_new() tcg_temp_new_i32() #define tcg_global_reg_new tcg_global_reg_new_i32 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264079715593.4285955885024; Wed, 26 Apr 2017 20:34:39 -0700 (PDT) Received: from localhost ([::1]:58525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aCU-0003oq-5s for importer@patchew.org; Wed, 26 Apr 2017 23:34:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7c-0007xa-3J for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001xh-T8 for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:40617) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001rv-3G; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 97E9520894; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 54B607E6E3; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=EIS I8m3qTNYJGjaKYqnMgdbJGaVfkobnGc2uNRWdbOg=; b=GulO4cyVGGamxxIbG7m h6eTBR5VqJOEbCQDRw2XPEF0gdOpD9dqMmekafARaIKrXQTyuh6XtzmaqdAoXwx8 tGRys+k19K/yxaMWx4wqCtUQSUcQXKHcvCJZX+sRbl3zsiAXJ2gKC97FjqqEqy/9 OLKoqiOGORjh1J3mpq4g7izc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=EISI8m3qTNYJGjaKYqnMgdbJGaVfkobnGc2uNRWdb Og=; b=kPOwcd8HAygm3bsbDIQfYBut9k0RA2MDkkNET2JV0/8rST5ncqAbV0Yi5 HWOhycAdR+UpTSvOQ8yy/HaLbDVVJ7QR3Zmc3eY4hKAr8EjJFMqI0e26NoL0J2cN kTcvxnDdwYfEog/VLjKCzPkpkhCrc0oQuCnVnSBacs42WwNRMGo+DmNcUNN2AuzJ qlI2UDgA5cvgKi//zUFz47BuznaZ6mAcTtD2JCZsTqmbFG0PyWruSsgn3ky9Bm4y hBnW+NB05usnkL+mEYcCjQ/HxPejYRqFiYecaU8c2IyuOWe+SsSAv0n0PEumQyM7 6YSsE+FyFQb9n7GH+TtcN8QKI8BEQ== X-ME-Sender: X-Sasl-enc: hcodvfmp0oCdwxKNwjH5SUTmyb0a4EyUjYY9o1iz/VSx 1493263767 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:18 -0400 Message-Id: <1493263764-18657-6-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 05/11] tcg/i386: implement goto_ptr op 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Suggested-by: Richard Henderson Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- tcg/i386/tcg-target.h | 2 +- tcg/i386/tcg-target.inc.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h index 59d9835..73a15f7 100644 --- a/tcg/i386/tcg-target.h +++ b/tcg/i386/tcg-target.h @@ -107,7 +107,7 @@ extern bool have_popcnt; #define TCG_TARGET_HAS_muls2_i32 1 #define TCG_TARGET_HAS_muluh_i32 0 #define TCG_TARGET_HAS_mulsh_i32 0 -#define TCG_TARGET_HAS_goto_ptr 0 +#define TCG_TARGET_HAS_goto_ptr 1 =20 #if TCG_TARGET_REG_BITS =3D=3D 64 #define TCG_TARGET_HAS_extrl_i64_i32 0 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index 5918008..d0bf53a 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -1906,6 +1906,10 @@ static inline void tcg_out_op(TCGContext *s, TCGOpco= de opc, } s->tb_jmp_reset_offset[a0] =3D tcg_current_code_size(s); break; + case INDEX_op_goto_ptr: + /* 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); break; @@ -2277,6 +2281,7 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcod= e opc, =20 static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) { + static const TCGTargetOpDef r =3D { .args_ct_str =3D { "r" } }; static const TCGTargetOpDef ri_r =3D { .args_ct_str =3D { "ri", "r" } = }; static const TCGTargetOpDef re_r =3D { .args_ct_str =3D { "re", "r" } = }; static const TCGTargetOpDef qi_r =3D { .args_ct_str =3D { "qi", "r" } = }; @@ -2299,6 +2304,9 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpc= ode op) =3D { .args_ct_str =3D { "L", "L", "L", "L" } }; =20 switch (op) { + case INDEX_op_goto_ptr: + return &r; + case INDEX_op_ld8u_i32: case INDEX_op_ld8u_i64: case INDEX_op_ld8s_i32: @@ -2567,6 +2575,13 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_modrm(s, OPC_GRP5, EXT5_JMPN_Ev, tcg_target_call_iarg_regs[1]); #endif =20 + /* + * 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 =3D s->code_ptr; + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_EAX, 0); + /* TB epilogue */ tb_ret_addr =3D s->code_ptr; =20 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493263918321219.73753506140656; Wed, 26 Apr 2017 20:31:58 -0700 (PDT) Received: from localhost ([::1]:58515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a9s-0001G5-V0 for importer@patchew.org; Wed, 26 Apr 2017 23:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007wd-Ci for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001x0-B6 for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:54315) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001rw-4E; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BEBFA209C5; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:27 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 80A012471A; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=bKf KCRDHbK2tndXvtx/Z37DY0jqzp1GeJcUMTXEwdic=; b=KzcZZY9f9Jp/Bb1ukyM L1F/LwR4GEPuoZQECSa9GKLOg0qVAeaXTdSFMSv56kwHNnwOlFCHfqypfPOvvSbt 0AOyZAsnNfS9qSqJHt+RCt3UYzchFDiKV3RfDIaJFugfZ/6aUY+cSPP2H48Sgzal fw8f9L07NlZR0gOebPJj9aPk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=bKfKCRDHbK2tndXvtx/Z37DY0jqzp1GeJcUMTXEwd ic=; b=BelzoM1WWKDFZ1cwj798nUbKu5Tri54DG/WBW9YHhJlLmviQDU8Wf5EJi EocFb3JK2dnVGEptyxzKYcm3Vj5v/w7E+EMQjVcmZIfFRx8o5tsfLu+pTfuuHPDr igkYX0tOANYqd++Pt7ypbI80zdU83T7BzJI4erKn0dd8BJ2hITVyZ4iIZXLlqwmz GgN4xxGKcn5KZM2mI+hNC6EPqtTSta1cstlcJDwBjNJCXKsr4v6xh9cECyqvvVqQ P9ytSl/JEROwQA+8Y4P33fmCsFsF5HJ4c73j3QyDOrO9k5CkMJyRwCNkDcImspS/ +AIsn32ARn2U+8z1zN+oDQ4tmIodQ== X-ME-Sender: X-Sasl-enc: hcoarO2v1ouWzBmbyDj5SUTmyb0a4EyUjYY9o1iz/VSx 1493263767 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:19 -0400 Message-Id: <1493263764-18657-7-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 06/11] target/arm: optimize cross-page direct jumps in softmmu 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of unconditionally exiting to the exec loop, use the lookup_and_goto_ptr helper to jump to the target if it is valid. Perf impact: see next commit's log. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- target/arm/translate.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index e32e38c..02cad96 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4085,8 +4085,12 @@ static inline void gen_goto_tb(DisasContext *s, int = n, target_ulong dest) gen_set_pc_im(s, dest); tcg_gen_exit_tb((uintptr_t)s->tb + n); } else { + TCGv addr =3D tcg_temp_new(); + gen_set_pc_im(s, dest); - tcg_gen_exit_tb(0); + tcg_gen_extu_i32_tl(addr, cpu_R[15]); + tcg_gen_lookup_and_goto_ptr(addr); + tcg_temp_free(addr); } } =20 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264329384894.052338683835; Wed, 26 Apr 2017 20:38:49 -0700 (PDT) Received: from localhost ([::1]:58551 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aGW-0007GB-26 for importer@patchew.org; Wed, 26 Apr 2017 23:38:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7c-0007y5-9j for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001xc-Ry for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:34793) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001sT-Ad; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 04F66209B4; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:28 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id AE9537E442; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=zaS FSMNOGre/S+7idWm8Q28pX9dgZQqKQWZlR7RfxQA=; b=yWdoS5MpLt2mG7jAiKk FEOrV3Zzf0H9X+R/VhzdXs7DT2tYkw0/Az6wtBwW+XdcTTUhsDocrv9Qm91VBr1N O6hXI16Omo6HfspocqcBG8iDLgK1j/2fEivz0c1nmUgoXEVjw+VPZx2sf1jsuzc9 zC19v10nck6XNCITxEseEUQE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=zaSFSMNOGre/S+7idWm8Q28pX9dgZQqKQWZlR7Rfx QA=; b=H5sBdnwQZTDsFu0S5UVUz1hkNC6jqK/7pdKyCAEVVA6VWAypv7NqHHo1e M7L5vNO3EhNTUbOjKWsVE/QUTlOrQ+TpWHsGCKbJQCUO+MmOImnWsGnaKOh8np1o hH5iFd3BrTWWmoqbHd3OWfvZInZBP27pGWQx7mQDEoF1vtULYX1Ys0SUFMTORfRA Gi9O5yKElQdsJE5XOA5bG2UzmHBZUDAD+UadSFL5ySJ9KvaB6APJ7A2dBTmxQB5w SYZSUJDFu/12H0nrUyjVWPyOrrf0PG7aYX55Teq30ca2mr01C0EdFWu28pURgxPd o22HB+vFh9Ou2RrwtT2AGRzq436CQ== X-ME-Sender: X-Sasl-enc: hcoNr++8xJqY0xaM2D75SUTmyb0a4EyUjYY9o1iz/VSx 1493263767 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:20 -0400 Message-Id: <1493263764-18657-8-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 07/11] target/arm: optimize indirect branches 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Speed up indirect branches by jumping to the target if it is valid. Softmmu measurements (see later commit for user-mode results): Note: baseline (i.e. speedup =3D=3D 1x) is QEMU v2.9.0. - Impact on Boot time | setup | ARM debian jessie boot+shutdown time | stddev | |--------+--------------------------------------+--------| | v2.9.0 | 8.84 | 0.07 | | +cross | 8.85 | 0.03 | | +jr | 8.83 | 0.06 | - NBench, arm-softmmu (debian jessie guest). Hos= t: Intel i7-4790K @ 4.00GHz 1.3x +-+-----------------------------------------------------------------= --------------------------------------------+-+ | = | | cross #= ### | 1.25x +cross+jr..........................................................#= ++#.........................................+-+ | #### #= # | | +++# # #= # | | +++ **** # #= # | 1.2x +-+...................................####............*..*..#......#= ..#.........................................+-+ | **** # * * # #= # #### | | * * # * * # #= # # # | 1.15x +-+................................*..*..#............*..*..#......#= ..#.....#..#................................+-+ | * * # * * # #= # # # | | * * # #### * * # #= # # # | | * * # # # * * # #= # # # #### | 1.1x +-+................................*..*..#......#..#..*..*..#......#= ..#.....#..#.........................#..#...+-+ | * * # # # * * # #= # # # # # | | * * # # # * * # #= # # # # # | 1.05x +-+..........................####..*..*..#......#..#..*..*..#......#= ..#.....#..#......+++............*****..#...+-+ | ***** # * * # # # * * # *****= # # # +++ | ****### * * # | | *+++* # * * # # # * * # *+++*= # **** # *****### * * # * * # | | *****### +++#### * * # * * # ***** # * * # * *= # * * # * | *++# * * # * * # | 1x +-++-+*+++*-+#++****++#++*+-+*++#+-*++*++#-+*+++*-+#++*++*++#++*+-+*= ++#+-*++*++#-+*+++*-+#++*++*++#++*+-+*++#+-++-+ | * * # * * # * * # * * # * * # * * # * *= # * * # * * # * * # * * # | | * * # * * # * * # * * # * * # * * # * *= # * * # * * # * * # * * # | 0.95x +-+---*****###--****###--*****###--****###--*****###--****###--*****= ###--****###--*****###--****###--*****###---+-+ ASSIGNMENT BITFIELD FOURFP EMULATION HUFFMAN LU DECOMPOSITIONE= URAL NNUMERIC SOSTRING SORT hmean png: http://imgur.com/eOLmZNR NB. 'cross' represents the previous commit. Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- target/arm/translate.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/target/arm/translate.c b/target/arm/translate.c index 02cad96..d46a576 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -65,6 +65,7 @@ static TCGv_i32 cpu_R[16]; TCGv_i32 cpu_CF, cpu_NF, cpu_VF, cpu_ZF; TCGv_i64 cpu_exclusive_addr; TCGv_i64 cpu_exclusive_val; +static bool gen_jr; =20 /* FIXME: These should be removed. */ static TCGv_i32 cpu_F0s, cpu_F1s; @@ -221,6 +222,7 @@ static void store_reg(DisasContext *s, int reg, TCGv_i3= 2 var) */ tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3); s->is_jmp =3D DISAS_JUMP; + gen_jr =3D true; } tcg_gen_mov_i32(cpu_R[reg], var); tcg_temp_free_i32(var); @@ -893,6 +895,7 @@ static inline void gen_bx_im(DisasContext *s, uint32_t = addr) tcg_temp_free_i32(tmp); } tcg_gen_movi_i32(cpu_R[15], addr & ~1); + gen_jr =3D true; } =20 /* Set PC and Thumb state from var. var is marked as dead. */ @@ -902,6 +905,7 @@ static inline void gen_bx(DisasContext *s, TCGv_i32 var) tcg_gen_andi_i32(cpu_R[15], var, ~1); tcg_gen_andi_i32(var, var, 1); store_cpu_field(var, thumb); + gen_jr =3D true; } =20 /* Variant of store_reg which uses branch&exchange logic when storing @@ -12034,6 +12038,20 @@ void gen_intermediate_code(CPUARMState *env, Trans= lationBlock *tb) gen_set_pc_im(dc, dc->pc); /* fall through */ case DISAS_JUMP: + /* + * gen_jr is not set on every DISAS_JUMP because for some of t= hose + * we do want to exit to the exec loop. + */ + if (gen_jr) { + TCGv addr =3D tcg_temp_new(); + + gen_jr =3D false; + tcg_gen_extu_i32_tl(addr, cpu_R[15]); + tcg_gen_lookup_and_goto_ptr(addr); + tcg_temp_free(addr); + break; + } + /* fall through */ default: /* indicate that the hash table must be used to find the next = TB */ tcg_gen_exit_tb(0); --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264098525110.26558404919035; Wed, 26 Apr 2017 20:34:58 -0700 (PDT) Received: from localhost ([::1]:58527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aCn-00043y-7Y for importer@patchew.org; Wed, 26 Apr 2017 23:34:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007wt-JI for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001x5-Bm for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:60465) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001sh-Gm; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2A36C209C6; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:28 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id D99C32471A; Wed, 26 Apr 2017 23:29:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=LfZ MDdl1ThkY/pzWQ2wbdfnjFqT6ZH5gfdZiXmk8OF4=; b=UvAsEOqnD0OopOmYhny THFvBB/8Tc1qfs2/nuAxW/ULC9iHh+HkeVeTZx9/6SGNGc9obVq8fTnQxWW9XW1t 7ZoDidJjMV2Q5ABoTW9CWAwexQt0F8Ivzx1s1dhR6kO5gABDCVH+8ADg9ekwrQy1 J0CaJfKjb67sAfoFF2y7Auuk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=LfZMDdl1ThkY/pzWQ2wbdfnjFqT6ZH5gfdZiXmk8O F4=; b=FuY2nCIkgzV5AW1ZgEQyDAhA45wJNrXy9sQO/EcZQIaW5I0xELEQjQnHU n06xTctqpOT5pKwEhr7mQZVVkq8ZcfWcrE142LOiF69yzHnjL0g7EooLsXrLrz81 lZCQp1gKhvNPjKb7Ujc0UBdRWnU0KcwAbUt2e+vKHOMkF0XSdpYCD7LV1sBlLR+Z HttljUCVnnrVq/24VOCo7YB29n35/qRYkA1H62TkXxJJr/A3JG1RwcEz+Wmvb7y6 AaELqY9tU6/JVBYxK1xaM0ANFEee+s6bMdQsFU+GyyonBExMrp22HSi8EHYGQTnc uEvKuUVbkTKLOZMj4U09tV1pPcqaQ== X-ME-Sender: X-Sasl-enc: hcoVvO6zzpCa3wWJzTb5SUTmyb0a4EyUjYY9o1iz/VSx 1493263767 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:21 -0400 Message-Id: <1493263764-18657-9-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 08/11] target/i386: introduce gen_jr helper to generate lookup_and_goto_ptr 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This helper will be used by subsequent changes. Signed-off-by: Emilio G. Cota Reviewed-by: Richard Henderson Tested-by: Aurelien Jarno --- target/i386/translate.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index 1d1372f..f0e48dc 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -141,6 +141,7 @@ typedef struct DisasContext { } DisasContext; =20 static void gen_eob(DisasContext *s); +static void gen_jr(DisasContext *s, TCGv dest); static void gen_jmp(DisasContext *s, target_ulong eip); static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num); static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d); @@ -2509,7 +2510,8 @@ static void gen_bnd_jmp(DisasContext *s) If INHIBIT, set HF_INHIBIT_IRQ_MASK if it isn't already set. If RECHECK_TF, emit a rechecking helper for #DB, ignoring the state of S->TF. This is used by the syscall/sysret insns. */ -static void gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf) +static void +do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, TCGv jr) { gen_update_cc_op(s); =20 @@ -2530,12 +2532,27 @@ static void gen_eob_worker(DisasContext *s, bool in= hibit, bool recheck_tf) tcg_gen_exit_tb(0); } else if (s->tf) { gen_helper_single_step(cpu_env); + } else if (!TCGV_IS_UNUSED(jr)) { + TCGv vaddr =3D tcg_temp_new(); + + tcg_gen_add_tl(vaddr, jr, cpu_seg_base[R_CS]); + tcg_gen_lookup_and_goto_ptr(vaddr); + tcg_temp_free(vaddr); } else { tcg_gen_exit_tb(0); } s->is_jmp =3D DISAS_TB_JUMP; } =20 +static inline void +gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf) +{ + TCGv unused; + + TCGV_UNUSED(unused); + do_gen_eob_worker(s, inhibit, recheck_tf, unused); +} + /* End of block. If INHIBIT, set HF_INHIBIT_IRQ_MASK if it isn't already set. */ static void gen_eob_inhibit_irq(DisasContext *s, bool inhibit) @@ -2549,6 +2566,12 @@ static void gen_eob(DisasContext *s) gen_eob_worker(s, false, false); } =20 +/* Jump to register */ +static void gen_jr(DisasContext *s, TCGv dest) +{ + do_gen_eob_worker(s, false, false, dest); +} + /* generate a jump to eip. No segment change must happen before as a direct call to the next block may occur */ static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num) --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149326391846575.87675537157202; Wed, 26 Apr 2017 20:31:58 -0700 (PDT) Received: from localhost ([::1]:58514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a9t-0001Fp-3H for importer@patchew.org; Wed, 26 Apr 2017 23:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7b-0007wF-1s for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7a-0001wp-5Q for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:35 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:43409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001sq-M7; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 58F07209CC; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:28 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 17B207E442; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Ta4 tw3WmYm+qHdrHWjt66JRltdhuo18lj+g0a3/yfk4=; b=wIPOqglfUB6qnL1hh97 yWKkEcQ05lVu4TTiZFhx0aOqIIGnsnGBw09xrSN1QHa9MAN5J2Lfb1f+4bJZQZne jYn5xHuw5iy9qI53HvRuVTaDsNzyW7NsJ4l5hw92RzHAdbTbx6OEyDU4saQ/RgAt g9L+aSvtVE8z70Mzh7EkOLi0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=Ta4tw3WmYm+qHdrHWjt66JRltdhuo18lj+g0a3/yf k4=; b=eQle4HC/DPqLr37UDPeaznxsYbxJ6q8WCx7DI6Y2Mlod0w18ZDwCW3OcJ IQ04m2wjjSc/17667we2Y2eJO0XZxtc75IsoiH53fOLp1OkG5oGVHIdflSwWn2z1 ucXsvN1/WGh9tUExzXFzVwcVJ8BdMvVt59Ow+iMO/REgHt6kZQE92/dQShyt7WLe 1Nb/N8U/LCVOz2Et1rU+u7P0k0BFl+6GOMRNB6zljnliE8BX1MUMF5Ss/1VlGcL7 8jrtxOX6TfTtJzWaY4W/i81gh7Fnok+0AANBHk2eRjsuKayX6MBrajxB4gA6DQ8Z qLYxU1TkytzyoD4/HtKhbjTJ9D/og== X-ME-Sender: X-Sasl-enc: UmuCv6wx/fVooVIYAlBWmrOmqCewZc5mbqcq/7BLhlkm 1493263768 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:22 -0400 Message-Id: <1493263764-18657-10-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 09/11] target/i386: optimize cross-page direct jumps in softmmu 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of unconditionally exiting to the exec loop, use the gen_jr helper to jump to the target if it is valid. Perf impact: see next commit's log. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- target/i386/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index f0e48dc..ea113fe 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -2154,9 +2154,9 @@ static inline void gen_goto_tb(DisasContext *s, int t= b_num, target_ulong eip) gen_jmp_im(eip); tcg_gen_exit_tb((uintptr_t)s->tb + tb_num); } else { - /* jump to another page: currently not optimized */ + /* jump to another page */ gen_jmp_im(eip); - gen_eob(s); + gen_jr(s, cpu_tmp0); } } =20 --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493264213267192.21138179815875; Wed, 26 Apr 2017 20:36:53 -0700 (PDT) Received: from localhost ([::1]:58544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aEe-0005f7-0P for importer@patchew.org; Wed, 26 Apr 2017 23:36:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7c-0007y9-BN for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7b-0001xo-2k for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:41561) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7U-0001sy-Ra; Wed, 26 Apr 2017 23:29:28 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 88A6A209CE; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:28 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 42A232471A; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=WRE 1oWXgD7pAGLXroSPOVQKqjm51VFq84TSKH0z1aGA=; b=VIHNvebJgZ//4GD3Gdc SGwVQ9/aD5nvAlHpILipeOBFAtVNou7aAV899LxLgXsNuXGaNVzWnfDeelf+3Rt4 fDvJp4LrKTD4YzbTeXFlTLygxFWIrBKl0uN/OxcvbLwtK/lioKyDcRA2ktw7Ssj8 KLIBXv32incg6rRKXReqw1TM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=WRE1oWXgD7pAGLXroSPOVQKqjm51VFq84TSKH0z1a GA=; b=odadxjPbNV+xXUYfZ7rFGmqJrALh/O1r7Ulp551D22GzGul6Jss3D70cZ IIkSdwtUMoTYWgSHt4c2WQGp5V5hcDQInhduyp8yjhVwrkajkkwGFvZL+Dptm5q/ uey49dWTNSK1RnU4Uo9tEokYY5bDjIi3UiaJBAxQXRvBoANJpXKCNXfep5kZxTTT L5KziLcXagWoi5+1YS9gNxLYTv6Z9kZGuceKQUbe8CHxz/Pn8gbylCStgp6hk9VE HWMl9jLHYjAz136jBAkKUm7Y3fSVtQUmiHoINb0M5JovNCVBVUp5vNG4KK5asVrk 6A6eYmiYrv3Mh3U4KnY0CkRsmoMHA== X-ME-Sender: X-Sasl-enc: UmuforQ66vBlt10NDkhWmrOmqCewZc5mbqcq/7BLhlkm 1493263768 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:23 -0400 Message-Id: <1493263764-18657-11-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 10/11] target/i386: optimize indirect branches 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Speed up indirect branches by jumping to the target if it is valid. Softmmu measurements (see later commit for user-mode numbers): Note: baseline (i.e. speedup =3D=3D 1x) is QEMU v2.9.0. - SPECint06 (test set), x86_64-softmmu (Ubuntu 16.04 guest= ). Host: Intel i7-4790K @ 4.00GHz 2.4x +-+------------------------------------------------------------------= --------------------------------------------+-+ | = | | cross = | 2.2x +cross+jr............................................................= ..............+++...........................+-+ | = | | | = +++ | | 2x +-+..................................................................= ............|..|............................+-+ | = | | | | = | | | 1.8x +-+..................................................................= ............|####...........................+-+ | = |# |# | | = **** |# | 1.6x +-+..................................................................= ..........*.|*.|#...........................+-+ | = * |* |# | | = * |* |# | 1.4x +-+..................................................................= .....+++..*.|*.|#...........................+-+ | ++++++ = #### * |*++# +++ | | +++ | | = #++# *++* # +++ | | 1.2x +-+......................###.....####....+++............|..|.........= ..****..#.*..*..#....####...|.###.....####..+-+ | +++ **** # **** # #### ***### = *++* # * * # #++# ****|# +++#++# | | ****### +++ *++* # *++* # ++# # #### *|* |# +++= * * # * * # *** # *| *|# **** # | 1x +-++-*++*++#++***###++*++*+#++*+-*++#+****++#++***++#+-*+*++#-+****##= ++*++*-+#+*++*-+#++*+*++#++*-+*+#++*++*++#-++-+ | * * # * * # * * # * * # * * # * * # *|* |# *++* #= * * # * * # * * # * * # * * # | | * * # * * # * * # * * # * * # * * # *+*++# * * #= * * # * * # * * # * * # * * # | 0.8x +-+--****###--***###--****##--****###-****###--***###--***###--****##= --****###-****###--***###--****##--****###--+-+ astar bzip2 gcc gobmk h264ref hmmlibquantum mcf om= netpperlbench sjengxalancbmk hmean png: http://imgur.com/DU36YFU NB. 'cross' represents the previous commit. Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- target/i386/translate.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index ea113fe..674ec96 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -4996,7 +4996,7 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, gen_push_v(s, cpu_T1); gen_op_jmp_v(cpu_T0); gen_bnd_jmp(s); - gen_eob(s); + gen_jr(s, cpu_T0); break; case 3: /* lcall Ev */ gen_op_ld_v(s, ot, cpu_T1, cpu_A0); @@ -5014,7 +5014,8 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, tcg_const_i32(dflag - 1), tcg_const_i32(s->pc - s->cs_base)); } - gen_eob(s); + tcg_gen_ld_tl(cpu_tmp4, cpu_env, offsetof(CPUX86State, eip)); + gen_jr(s, cpu_tmp4); break; case 4: /* jmp Ev */ if (dflag =3D=3D MO_16) { @@ -5022,7 +5023,7 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, } gen_op_jmp_v(cpu_T0); gen_bnd_jmp(s); - gen_eob(s); + gen_jr(s, cpu_T0); break; case 5: /* ljmp Ev */ gen_op_ld_v(s, ot, cpu_T1, cpu_A0); @@ -5037,7 +5038,8 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, gen_op_movl_seg_T0_vm(R_CS); gen_op_jmp_v(cpu_T1); } - gen_eob(s); + tcg_gen_ld_tl(cpu_tmp4, cpu_env, offsetof(CPUX86State, eip)); + gen_jr(s, cpu_tmp4); break; case 6: /* push Ev */ gen_push_v(s, cpu_T0); @@ -6417,7 +6419,7 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, /* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v(cpu_T0); gen_bnd_jmp(s); - gen_eob(s); + gen_jr(s, cpu_T0); break; case 0xc3: /* ret */ ot =3D gen_pop_T0(s); @@ -6425,7 +6427,7 @@ static target_ulong disas_insn(CPUX86State *env, Disa= sContext *s, /* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v(cpu_T0); gen_bnd_jmp(s); - gen_eob(s); + gen_jr(s, cpu_T0); break; case 0xca: /* lret im */ val =3D cpu_ldsw_code(env, s->pc); --=20 2.7.4 From nobody Sun May 5 19:38:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149326439580142.537838734909656; Wed, 26 Apr 2017 20:39:55 -0700 (PDT) Received: from localhost ([::1]:58558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3aHa-00087H-Cj for importer@patchew.org; Wed, 26 Apr 2017 23:39:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3a7c-0007yn-RJ for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3a7b-0001xx-4S for qemu-devel@nongnu.org; Wed, 26 Apr 2017 23:29:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:44973) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3a7V-0001tA-1x; Wed, 26 Apr 2017 23:29:29 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BC4EC209D3; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute4.internal (MEProxy); Wed, 26 Apr 2017 23:29:28 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 71F157E6E3; Wed, 26 Apr 2017 23:29:28 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=FA+ e3Xv5AjO7YH2WX0VOsBB3hIAwoqYtkldFYtYp9nk=; b=PG/4H5zKcPoG1t8Wd1G /oPt/Z06Z+xCb/s/uwx0j5UsDEsVXWFuhQsREP+A2Vj94xTjUE2zOIBW0X2QYuk+ +rv0r/GPg+awu/tU7HsdIjONHS2DoQznEoh2mY8QtC6SrRXD1LDL3zjx7k0N3b67 7mKgvzhtiTBDP2FvHYefpyLY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=FA+e3Xv5AjO7YH2WX0VOsBB3hIAwoqYtkldFYtYp9 nk=; b=p/IDPo+JRzo62iM7hSfGgMxoLkZnf8NdAojBnprgAtpgim6ojngVe9Ipi 1HLomkfticFvFDPbffK9wReRF2THQ9+SxC53na75ZltHh0pHatUKbn54rH/0ZFnY j3HRdm136LJgo8XbcSp1gEsZdRHmkwlg8T9LZrLk33Z4nh3KcSQ9BiXc3TLW6aYz 5ZxDDqHsSsbcXD9pDGf/78p+jEziX5mPclcjb7zZVvEfKvw3Ml/ggXBiAK4XIV7n qzoO5BeJb5OI1zCY//xNqCkNHz0VPjCeOjHB6aJbqBv2MBmAFmLUj03y2nSwfT0c S26e4j5PKZ01/Wf8Q4iR1NWgcx87Q== X-ME-Sender: X-Sasl-enc: UmuSv6Qp4eVgt1QMGEJWmrOmqCewZc5mbqcq/7BLhlkm 1493263768 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Wed, 26 Apr 2017 23:29:24 -0400 Message-Id: <1493263764-18657-12-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493263764-18657-1-git-send-email-cota@braap.org> References: <1493263764-18657-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.28 Subject: [Qemu-devel] [PATCH v4 11/11] tb-hash: improve tb_jmp_cache hash function in user mode 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: Peter Maydell , Eduardo Habkost , Peter Crosthwaite , Stefan Weil , Alexander Graf , alex.bennee@linaro.org, qemu-arm@nongnu.org, Pranith Kumar , Paolo Bonzini , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Optimizations to cross-page chaining and indirect branches make performance more sensitive to the hit rate of tb_jmp_cache. The constraint of reserving some bits for the page number lowers the achievable quality of the hashing function. However, user-mode does not have this requirement. Thus, with this change we use for user-mode a hashing function that is both faster and of better quality than the previous one. Measurements: Note: baseline (i.e. speedup =3D=3D 1x) is QEMU v2.9.0. - SPECint06 (test set), x86_64-linux-user. Host: = Intel i7-6700K @ 4.00GHz 2.2x +-+------------------------------------------------------------------= --------------------------------------------+-+ | = | | jr = | 2x +jr+multhash +................................................= ....+++++...................................+-+ | jr+hash = |$$$ | | = |$+$ | | = ### $ | 1.8x +-+..................................................................= ....#|#.$...................................+-+ | = ++#+# $ | | = |# # $ | 1.6x +-+..................................................................= ..***.#.$....................++$$$..........+-+ | $$$ = *+* # $ |$+$ | | ++$$$ ### $ = * * # $ +++|$ $ | | ++###+$ # # $ = * * # $ ### ****## $ | 1.4x +-+...................***+#.$.........***.#.$........................= ..*.*.#.$...........#+#$$.*++*|#.$..........+-+ | *+* # $ * * # $ = * * # $ # # $ * *+# $ | | * * # $ +++++ * * # $ = * * # $ *** # $ * * # $ ###$$ | 1.2x +-+...................*.*.#.$.***##$$.*.*.#.$........................= ..*.*.#.$.........*.*.#.$.*..*.#.$.***+#+$..+-+ | * * # $ *+* # $ * * # $ +++ = * * # $ ++###$$ * * # $ * * # $ * * # $ | | ***##$$ * * # $ * * # $ * * # $ ***##$$ ++### = * * # $ *** #+$ * * # $ * * # $ * * # $ | | *+*+#+$ ***##$$$ * * # $ * * # $ * * # $ *+* # $ ++####$$ ***+# = * * # $ * * # $ * * # $ * * # $ * * # $ | 1x +-++-*+*+#+$+*+*+#-+$+*+*-#+$+*+*+#+$+*+*+#+$+*-*+#+$+***++#+$+*+*+#$= $+*+*+#+$+*+*+#+$+*+*-#+$+*+-*+#+$+*+*+#+$-++-+ | * * # $ * * # $ * * # $ * * # $ * * # $ * * # $ * * # $ * * # = $ * * # $ * * # $ * * # $ * * # $ * * # $ | | * * # $ * * # $ * * # $ * * # $ * * # $ * * # $ * * # $ * * # = $ * * # $ * * # $ * * # $ * * # $ * * # $ | 0.8x +-+--***##$$-***##$$$-***##$$-***##$$-***##$$-***##$$-***###$$-***##$= $-***##$$-***##$$-***##$$-****##$$-***##$$--+-+ astar bzip2 gcc gobmk h264ref hmmlibquantum mcf om= netpperlbench sjengxalancbmk hmean png: http://imgur.com/4UXTrEc Here I also tried the hash function suggested by Paolo ("multhash"): return ((uint64_t) (pc * 2654435761) >> 32) & (TB_JMP_CACHE_SIZE - 1); As you can see it is just as good as the other new function ("hash"), which is what I ended up going with. - SPECint06 (train set), x86_64-linux-user. Host: = Intel i7-6700K @ 4.00GHz 2.6x +-+------------------------------------------------------------------= --------------------------------------------+-+ | = | | jr = ### | 2.4x +jr+hash.............................................................= ..............................#.#...........+-+ | = # # | | = # # | 2.2x +-+..................................................................= ..............................#.#...........+-+ | = # # | | = # # | 2x +-+..................................................................= ..............................#.#...........+-+ | = **** # | | = * * # | 1.8x +-+..................................................................= ...........................*..*.#...........+-+ | = +++ * * # | | = #### #### * * # | 1.6x +-+......................................####........................= .....#..#.****..#..........*..*.#...........+-+ | +++ #++# = **** # * * # #### * * # | | ### # # = * * # * * # # # * * # | 1.4x +-+...................****+#..........****..#........................= ..*..*..#.*..*..#....#..#..*..*.#...........+-+ | *++* # * * # = * * # * * # *** # * * # #### | | * * # #### * * # = * * # * * # * * # * * # **** # | 1.2x +-+...................*..*.#..****++#.*..*..#........................= ..*..*..#.*..*..#..*.*..#..*..*.#..*..*..#..+-+ | ****### * * # * * # * * # = * * # * * # * * # * * # * * # | | * * # ***### * * # * * # * * # ****##= * * # * * # * * # * * # * * # | 1x +-+--****###--***###--****##--****###-****###--***###--***###--****##= --****###-****###--***###--****##--****###--+-+ astar bzip2 gcc gobmk h264ref hmmlibquantum mcf om= netpperlbench sjengxalancbmk hmean png: http://imgur.com/ArCbHqo - NBench, x86_64-linux-user. Host: Intel= i7-6700K @ 4.00GHz 1.12x +-+-----------------------------------------------------------------= --------------------------------------------+-+ | = | | jr += ++ | 1.1x +jr+hash...........................................................#= ###.........................................+-+ | +++#= | # | | | #= ++# | 1.08x +-+................................+++................+++.+++..*****= ..#.........................................+-+ | | +++ | | * | *= # | | | | | | *+++*= # | 1.06x +-+................................****###.............|...|...*...*= ..#.........................+++.............+-+ | *| * |# ****### * *= # | | | *| *++# *| * |# * *= # #### | 1.04x +-+................................*++*..#............*|.*.|#..*...*= ..#........................#.|#.............+-+ | * * # *++*++# * *= # +++#++# | | * * # * * # * *= # | # # +++#### | 1.02x +-+................................*..*..#......+++...*..*..#..*...*= ..#.....................****..#..*****++#...+-+ | +++ * * # +++ | * * # * *= # +++ *| * # *+++* # | | +++ | +++ +++ ++++++ * * # *****### * * # * *= # | +++ ++++++ *++* # * * # | 1x +-++-+++++####++****###++++-+####+-*++*++#-+*+++*-+#++*++*++#++*+-+*= ++#+-+++####-+*****###++*++*++#++*+-+*++#+-++-+ | *****| # *++* |# *****| # * * # * *++# * * # * *= # **** |# * * # * * # * * # | | * | *| # * *++# * | *++# * * # * * # * * # * *= # *| *++# * * # * * # * * # | 0.98x +-+...*.|.*++#..*..*..#..*+++*..#..*..*..#..*...*..#..*..*..#..*...*= ..#..*++*..#..*...*..#..*..*..#..*...*..#...+-+ | *+++* # * * # * * # * * # * * # * * # * *= # * * # * * # * * # * * # | | * * # * * # * * # * * # * * # * * # * *= # * * # * * # * * # * * # | 0.96x +-+---*****###--****###--*****###--****###--*****###--****###--*****= ###--****###--*****###--****###--*****###---+-+ ASSIGNMENT BITFIELD FOURFP EMULATION HUFFMAN LU DECOMPOSITIONE= URAL NNUMERIC SOSTRING SORT hmean png: http://imgur.com/ZXFX0hJ - NBench, arm-linux-user. Host: Intel i7-= 4790K @ 4.00GHz 1.3x +-+-----------------------------------------------------------------= --------------------------------------------+-+ | #### = | | jr # # = +++ | 1.25x +jr+hash.....................#..#...................................= ........####................................+-+ | # # = # # | | # # = # # | 1.2x +-+..........................#..#...................................= ........#..#................................+-+ | # # = # # | | # # = # # | 1.15x +-+..........................#..#...................................= ........#..#................................+-+ | # # #= ### # # | | # # #= # # # | 1.1x +-+..........................#..#..................................#= ..#.....#..#................................+-+ | # # #= # # # +++ | | # # #### #= # # # #### | 1.05x +-+..........................#..#...............#..#.....####......#= ..#.....#..#.........................#..#...+-+ | # # # # # # #= # # # +++ # # | | +++ ***** # #### ***** # # # +++#= # **** # ****### # # | 1x +-++-+*****###++****+++++*+-+*++#+-****++#-+*+++*-+#+++++#++#++*****= ++#+-*++*++#-+*****-++++*++*++#++*****++#+-++-+ | * * # * * | * * # * * # * * # **** # * *= # * * # * *### * *++# * * # | | * * # * *### * * # * * # * * # * * # * *= # * * # * * # * * # * * # | 0.95x +-+...*...*..#..*..*.|#..*...*..#..*..*..#..*...*..#..*..*..#..*...*= ..#..*..*..#..*...*..#..*..*..#..*...*..#...+-+ | * * # * * |# * * # * * # * * # * * # * *= # * * # * * # * * # * * # | | * * # * * |# * * # * * # * * # * * # * *= # * * # * * # * * # * * # | 0.9x +-+---*****###--****###--*****###--****###--*****###--****###--*****= ###--****###--*****###--****###--*****###---+-+ ASSIGNMENT BITFIELD FOURFP EMULATION HUFFMAN LU DECOMPOSITIONE= URAL NNUMERIC SOSTRING SORT hmean png: http://imgur.com/FfD27ey Reviewed-by: Richard Henderson Signed-off-by: Emilio G. Cota Tested-by: Aurelien Jarno --- include/exec/tb-hash.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h index 2c27490..b1fe2d0 100644 --- a/include/exec/tb-hash.h +++ b/include/exec/tb-hash.h @@ -22,6 +22,8 @@ =20 #include "exec/tb-hash-xx.h" =20 +#ifdef CONFIG_SOFTMMU + /* Only the bottom TB_JMP_PAGE_BITS of the jump cache hash bits vary for addresses on the same page. The top bits are the same. This allows TLB invalidation to quickly clear a subset of the hash table. */ @@ -45,6 +47,16 @@ static inline unsigned int tb_jmp_cache_hash_func(target= _ulong pc) | (tmp & TB_JMP_ADDR_MASK)); } =20 +#else + +/* In user-mode we can get better hashing because we do not have a TLB */ +static inline unsigned int tb_jmp_cache_hash_func(target_ulong pc) +{ + return (pc ^ (pc >> TB_JMP_CACHE_BITS)) & (TB_JMP_CACHE_SIZE - 1); +} + +#endif /* CONFIG_SOFTMMU */ + static inline uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t fl= ags) { --=20 2.7.4