From nobody Mon Feb 9 11:32:54 2026 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 149876832063951.81046506911059; Thu, 29 Jun 2017 13:32:00 -0700 (PDT) Received: from localhost ([::1]:41152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQg6X-0008IE-6a for importer@patchew.org; Thu, 29 Jun 2017 16:31:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQg4q-0007E1-AR for qemu-devel@nongnu.org; Thu, 29 Jun 2017 16:30:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQg4n-0000zJ-44 for qemu-devel@nongnu.org; Thu, 29 Jun 2017 16:30:12 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:43225) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQg4m-0000xL-Qn for qemu-devel@nongnu.org; Thu, 29 Jun 2017 16:30:09 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id AF20F20CA4; Thu, 29 Jun 2017 16:30:06 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Thu, 29 Jun 2017 16:30:06 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 6EB3E240B0; Thu, 29 Jun 2017 16:30:06 -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=xUf COB2y1SQVSSl/f6CJIXKkDNIk276JHq+lSTqILRc=; b=ZWsGreQEnNqO4W1LuS+ FvLU0HZ80ucB3dTD5pcY+DaJdwbDPIYv4dXuj7TG2678Y2AYcvV0TeSpRKddWXmS qm8wUOd2TAs9RoRs/dTLW3L95S6uLwmKWyNi197dKCmGB6JxAVXoj1H0EPKVxz4M EscFtQOTO1eC+7BH4KzLhaG4= 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=xUfCOB2y1SQVSSl/f6CJIXKkDNIk276JHq+lSTqIL Rc=; b=OaU76kt96Yt12lbjeB25UIQ/zb7WC/nd/1NhLjAi9ai3MVZprzeE2Guz8 TaACe0X+//3iinLeWGIYvuW+fjTwS1Et8+odmMmb1vA/a6jrO2Ik3rZNXxBWsanW 4edyoMqxzkpdCNvELBuD0cphhFIMIneJck6uFuK3RAYKt5tESt8x86cNaiyTPJFG Y+/votRJdNMc/+TAiDvOZ7XZ8pnxAwDatjqNDPhAHuj07EtU2YdASBA69Gv7RYgj QZC8j5g1xgwSuTu29RNjGSvfyZLHgmI9L27ArfAkWnQ1Is7fvbbYJzPtrLv7ZsZk UYD5Rz/NsOTkWMELqfbj9UH4ee1SA== X-ME-Sender: X-Sasl-enc: 2RNc3kOaO/CwGclvbWOIrGLFGOBuUm3Ct3+Outx4Cw+d 1498768206 From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 29 Jun 2017 16:28:24 -0400 Message-Id: <1498768109-4092-3-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498768109-4092-1-git-send-email-cota@braap.org> References: <1498768109-4092-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.29 Subject: [Qemu-devel] [RFC 2/7] translate-all: add out_size field to TranslationBlock 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: 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 paves the way for upcoming work: we need tb->out_size for tb_find_pc to work with a binary search tree. Note that due to the cacheline padding we are using, for hosts with 64-byte cache lines this will not waste any additional memory. Using a s16 would be ideal, since that would plug an existing hole in the struct, but I see no guarantee that a TB won't overflow it. Signed-off-by: Emilio G. Cota --- include/exec/exec-all.h | 1 + accel/tcg/translate-all.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 35a75f1..df12338 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -363,6 +363,7 @@ struct TranslationBlock { */ uintptr_t jmp_list_next[2]; uintptr_t jmp_list_first; + int32_t out_size; /* size of host code for this block */ }; =20 void tb_free(TranslationBlock *tb); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index f6ad46b..da91482 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1260,7 +1260,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, tb_page_addr_t phys_pc, phys_page2; target_ulong virt_page2; tcg_insn_unit *gen_code_buf; - int gen_code_size, search_size; + int search_size; #ifdef CONFIG_PROFILER int64_t ti; #endif @@ -1327,11 +1327,11 @@ TranslationBlock *tb_gen_code(CPUState *cpu, the tcg optimization currently hidden inside tcg_gen_code. All that should be required is to flush the TBs, allocate a new TB, re-initialize it per above, and re-do the actual code generation. = */ - gen_code_size =3D tcg_gen_code(&tcg_ctx, tb); - if (unlikely(gen_code_size < 0)) { + tb->out_size =3D tcg_gen_code(&tcg_ctx, tb); + if (unlikely(tb->out_size < 0)) { goto buffer_overflow; } - search_size =3D encode_search(tb, (void *)gen_code_buf + gen_code_size= ); + search_size =3D encode_search(tb, (void *)gen_code_buf + tb->out_size); if (unlikely(search_size < 0)) { goto buffer_overflow; } @@ -1339,7 +1339,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #ifdef CONFIG_PROFILER tcg_ctx.code_time +=3D profile_getclock(); tcg_ctx.code_in_len +=3D tb->size; - tcg_ctx.code_out_len +=3D gen_code_size; + tcg_ctx.code_out_len +=3D tb->out_size; tcg_ctx.search_out_len +=3D search_size; #endif =20 @@ -1347,8 +1347,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM) && qemu_log_in_addr_range(tb->pc)) { qemu_log_lock(); - qemu_log("OUT: [size=3D%d]\n", gen_code_size); - log_disas(tb->tc_ptr, gen_code_size); + qemu_log("OUT: [size=3D%d]\n", tb->out_size); + log_disas(tb->tc_ptr, tb->out_size); qemu_log("\n"); qemu_log_flush(); qemu_log_unlock(); @@ -1356,7 +1356,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, #endif =20 tcg_ctx.code_gen_ptr =3D (void *) - ROUND_UP((uintptr_t)gen_code_buf + gen_code_size + search_size, + ROUND_UP((uintptr_t)gen_code_buf + tb->out_size + search_size, CODE_GEN_ALIGN); =20 /* init jump list */ --=20 2.7.4