From patchwork Wed Nov 9 07:02:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622924 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp89543pvb; Tue, 8 Nov 2022 23:03:14 -0800 (PST) X-Google-Smtp-Source: AMsMyM75f/RtZoAHkoSjsJ+pvdTU44iOFmbafGoPdKa7jrZL7MxTMogiW7Je2kLLz0MDbwMbi+ej X-Received: by 2002:ac8:6a18:0:b0:3a5:49fb:2365 with SMTP id t24-20020ac86a18000000b003a549fb2365mr28444677qtr.587.1667977394603; Tue, 08 Nov 2022 23:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667977394; cv=none; d=google.com; s=arc-20160816; b=Vdme5omz5CmA52WO4dxtIdu68/NL2b5DYxD++ypZN2H8u/f5zryaSAHS2BqeCbmAAX IWzxwgRSQCRBsl0/kgSrPt+cKb9YJ5i670dT1hvDmgKX5LhZ91df0PxWB98MvLmCkHHd 4LiNhk0ZwzAUNAB04cE3lC+qN+xS3h4SNfMq/3/Ki0GOE620jqTJaFFaNjXJL7K94Hq0 WRM+Gxhw2+UPSm5rF8Uyu4+Mo7t9SRKqIvlYEaNujRrLZkVTyc8bnuiwhNOqKXSX59Sm y11owX8LTG5SXhIWHMNcXWbAj7N5CgcSCaSW3jwSSwJ9ohpvIhgxtkDMdQUrI1HXEeit OWig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FPCwCw8NIdnDIzeLfwT3RMHDD1OYAbg9lFHMIclkLr0=; b=K5iTOs/x6HwV59LdYhOStGkYGqk0KdYo+U9w+HL4hXgMb+SxO0A2xDGGlytwbDfekQ l2Lp4FG0uMPUO1mXIZsqwu3IUrITqFouaUZdEYo7OZZTipmmm+oAbdbM4c+HNsLTg58O 47QZWBtNozwrBxqqKD8KV/Rjmbxb4ReHY+qY5htnqF5zQPJpsydT+d9j4cTvgNDlQw/E +lo6FiR094GOX/BRLDc2+Eu1N9nILat7QF4AMdoKNNbYMi3pTyvRcudlyw6NxMh0aRW6 D6nREhwsfFm2jxKqwtDgGv6ybGfz1W2S+KQxYDlyUD7jRpc1GP1/40WCnz/IZH8YIRT8 KlSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S0IX/GQz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i23-20020ac860d7000000b003a52649329asi7856759qtm.286.2022.11.08.23.03.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Nov 2022 23:03:14 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S0IX/GQz"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osf6c-0006ez-D7; Wed, 09 Nov 2022 02:02:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osf6a-0006cS-PE for qemu-devel@nongnu.org; Wed, 09 Nov 2022 02:02:36 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osf6Y-0002Ee-Re for qemu-devel@nongnu.org; Wed, 09 Nov 2022 02:02:36 -0500 Received: by mail-pj1-x1034.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so991102pjs.4 for ; Tue, 08 Nov 2022 23:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FPCwCw8NIdnDIzeLfwT3RMHDD1OYAbg9lFHMIclkLr0=; b=S0IX/GQz57Ov1GzWNEM1mP4DgoxQx2b/+8j0COusPABm9qwM7d56ZXpKI7cYjCuPRt L6p+MKguGJ2IBUiWtsO1TXfxuH24MrRrKnDyF0Wacs5h9P+N6yazZjuJlw7lUSqRTh+B MtxduwFMygtY1WqSFjYgaepVNCqfHEVb4UHvjadTru1MHlD5usUXFM8puyptI96z6Eoh 786BHYnRFXSmbj3cfq1UgWDKbgBODEnEYciY9qy1Bc7bZjckr9nhGuVV+jtJfaZe5EUN WqWpF+jTSJhMAjNNieH2XeygSu0vaoVvUv6Lq+FGu+8jzu3y3UG+ExNh/aHF26JY1+j8 h4Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FPCwCw8NIdnDIzeLfwT3RMHDD1OYAbg9lFHMIclkLr0=; b=kw49iNU0rsrYHcW/pbK5UyPURQc/lz/DQlpmCpXF0NM95VxlKPEYm/VPgLCdop7uiS 4qsM/wWWG23/G1Gr6JrUibNtafJKpdBibmnAUgFNGuubrEO2KPOUKXsMi3O5kO0xJb3U Hy1fnpQmF4fKsb0JO38X9JwQ/ZeU7SwO704Oi+hHlhc0tS4I4qy+ukDqcTUaqPBEvhrW eQb6DK7SIVYziuTofooHXKNL4pYKnU0GObqwXj0uhmib5Edfaua4jM9whjBhJaecGqZC f0eYcI0WTQdZ/iErwHs05ZLGOlv1Dw8dc1JpL2HTZm/HXPjUETAsl32oAtJdjIYtMCUR dYjQ== X-Gm-Message-State: ACrzQf3JsMitP0T6r8RjXR+YMI5k5v1abHnk1NXt+rgVU859BlfoeXk+ TijDzszV6QV8ibkhoR3VrlxlHJpA1fidbVH1 X-Received: by 2002:a17:90a:b011:b0:213:473e:6fe1 with SMTP id x17-20020a17090ab01100b00213473e6fe1mr61559377pjq.229.1667977352863; Tue, 08 Nov 2022 23:02:32 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-855d-0172-a1c2-6464.static.ipv6.internode.on.net. [2001:44b8:2176:c800:855d:172:a1c2:6464]) by smtp.gmail.com with ESMTPSA id u8-20020a1709026e0800b0017bb38e4588sm8158784plk.135.2022.11.08.23.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 23:02:32 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 1/2] tcg: Move TCG_TARGET_HAS_direct_jump init to tb_gen_code Date: Wed, 9 Nov 2022 18:02:23 +1100 Message-Id: <20221109070224.13073-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109070224.13073-1-richard.henderson@linaro.org> References: <20221109070224.13073-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 10 ---------- tcg/tcg.c | 12 ++++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 921944a5ab..9ee21f7f52 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -821,16 +821,6 @@ TranslationBlock *tb_gen_code(CPUState *cpu, trace_translate_block(tb, pc, tb->tc.ptr); /* generate machine code */ - tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; - tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; - tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; - if (TCG_TARGET_HAS_direct_jump) { - tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; - tcg_ctx->tb_jmp_target_addr = NULL; - } else { - tcg_ctx->tb_jmp_insn_offset = NULL; - tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; - } #ifdef CONFIG_PROFILER qatomic_set(&prof->tb_count, prof->tb_count + 1); diff --git a/tcg/tcg.c b/tcg/tcg.c index b43b6a7981..436fcf6ebd 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4228,6 +4228,18 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, target_ulong pc_start) } #endif + /* Initialize goto_tb jump offsets. */ + tb->jmp_reset_offset[0] = TB_JMP_RESET_OFFSET_INVALID; + tb->jmp_reset_offset[1] = TB_JMP_RESET_OFFSET_INVALID; + tcg_ctx->tb_jmp_reset_offset = tb->jmp_reset_offset; + if (TCG_TARGET_HAS_direct_jump) { + tcg_ctx->tb_jmp_insn_offset = tb->jmp_target_arg; + tcg_ctx->tb_jmp_target_addr = NULL; + } else { + tcg_ctx->tb_jmp_insn_offset = NULL; + tcg_ctx->tb_jmp_target_addr = tb->jmp_target_arg; + } + tcg_reg_alloc_start(s); /* From patchwork Wed Nov 9 07:02:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 622925 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp89572pvb; Tue, 8 Nov 2022 23:03:18 -0800 (PST) X-Google-Smtp-Source: AMsMyM6g0iYIxQohpYxE/UlkWZe3VZN//BRQxTi4XX+qxgCxewb/J8TxeaDDYSv0Oxe7T6SOVMMG X-Received: by 2002:ac8:7216:0:b0:3a5:3cb0:958 with SMTP id a22-20020ac87216000000b003a53cb00958mr32919714qtp.113.1667977398266; Tue, 08 Nov 2022 23:03:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667977398; cv=none; d=google.com; s=arc-20160816; b=FI81e8fVm9t4uV5cFEtymyxB+tvMQxpJjP3iyG3Wuq9kw7F79K5Vs4Vxm+Q7cbij+N PCXtHKIUcHDF8UkJAUNTRG+Irluf/gIA8FFw7ReARjiZWxJ0qryL8poet6PsnI3aemRp Ri9Znex4MkSFfJa5psYiTdp6mmoOk1dadtWAavyycQiqjmSWvi5dmkm5lLEDdF05tnh0 9ei4F9iF6foNSvsiFmkccvsVeli4yDJl6I9IXPnhuml0m8uMKbPnV7FeYcNkVB4Q7yEq gRMTVabYbz9bT1ltcT8aSm+dQVmbSB8haBUEZdA08TXk0TOX0Ugx6FallkvXSat89+L3 CfQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ThIdcirnoAwmtpHe6z2EOBTDBtvtEBFVSHhE8OUgyu8=; b=gWu81/hdUJ14vbsHQYzxIq+WHiix7wq/UEuYyC86mKTP7uMmXmN1wORWgwxgJbXKcJ ESpWh4g+mCji2Yv4H1IfjvHl3qYPd9AMZ2lheiV8uvHmNv3LLOPnLKe6WZkaVwUk5ILb +NTv1wN8Z/Cz2h4F0bzi6rBet+y9DLiAfBsfAInEPQVFm4ROlxLmKUedRadO4WXxTl8j oPdhw8eJvY09e1HC6RwsX/t0ltj9C9cbjz65yc2Pj1lPY5/ppk/JA0buxWbhp/T983hJ kQD/F2sxbJP7jlqkbR/2WuIr7hOMMIdvHRC/c1ZePuf5PVqtTFGOCmJVLoB2ctkCK5w6 oulw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ow0xfLJf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hf10-20020a0562140e8a00b004bb5ed2d568si1971596qvb.14.2022.11.08.23.03.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Nov 2022 23:03:18 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ow0xfLJf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osf6x-0006iN-PT; Wed, 09 Nov 2022 02:03:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osf6c-0006fa-Tu for qemu-devel@nongnu.org; Wed, 09 Nov 2022 02:02:40 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osf6b-0002QR-8h for qemu-devel@nongnu.org; Wed, 09 Nov 2022 02:02:38 -0500 Received: by mail-pg1-x536.google.com with SMTP id 136so11587465pga.1 for ; Tue, 08 Nov 2022 23:02:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ThIdcirnoAwmtpHe6z2EOBTDBtvtEBFVSHhE8OUgyu8=; b=Ow0xfLJfL90/9TbbZPCMtPERZ8oFIdNJVjK96Y60n2Fgbr8Z06YMjdPWEvTEngFlHx HeD7aUdQYYo3L2SS2GkQAAf1CjRo6uwW8Jmbso0Tbiy/TyfZr+q6VPIj31yal57spYpj I9CohZcKZKCqFLLMOXLKP7oi65pYD0UwTDBZ+iVxg8XKXFXmNQo95KB34P7uy7yZVVjq ghE/HVT6cYDMi7eajJJxJkNlsD2q90EXC9JhaBNfr8bd05JFWVekvp/EjtVuvJtOHRJ/ cOVDXhDlqkxoVXA7Fhd5p03zpVWG2RUxdfJoVt8phXwzaqzabz/6szziLrxmqlAj/yrj tJiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ThIdcirnoAwmtpHe6z2EOBTDBtvtEBFVSHhE8OUgyu8=; b=LltTD2KnBJ3HvP7EodfbFSvM9sM1+NDJG2grRmTlLBbdR6dvtqU3gKWLS0UX7gWynX 54NBxbs37iM+nKVFrySEU3np79k3oJQ4mNUiQ5NAElkhC+iRo6gcI3/LWrklL5JFu18D YapVxjEL1mtMaDUmIVIG6PaixE4vQn0xcgNqVnvRMQ4PXbfJcJ2oxma3wux5yivCjj9i LL5qpd5J6rWUV/aIzaj+UBHUwVKaSLHuHDRSmauLkzsmO405z3l+HSvVVAQN/bqflBU3 /vaX71rPzfGljSZCSq0dJvzKepejLPYyQzBiqxF5E/TWy918h4wHSgKai/47HwRy9dJK z5dQ== X-Gm-Message-State: ACrzQf0Xs53MJD3PV93LIhg2tVcLR0vhYbPrmXlkUmjJf+9MpR0EX8vm Yd0PbsbbToijbvcqXrNisls6ccZKqlMQ6IlgBB0= X-Received: by 2002:a05:6a00:14cf:b0:56d:88a8:32cf with SMTP id w15-20020a056a0014cf00b0056d88a832cfmr47989904pfu.27.1667977355887; Tue, 08 Nov 2022 23:02:35 -0800 (PST) Received: from stoup.lan (2001-44b8-2176-c800-855d-0172-a1c2-6464.static.ipv6.internode.on.net. [2001:44b8:2176:c800:855d:172:a1c2:6464]) by smtp.gmail.com with ESMTPSA id u8-20020a1709026e0800b0017bb38e4588sm8158784plk.135.2022.11.08.23.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 23:02:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 2/2] accel/tcg: Split out setjmp_gen_code Date: Wed, 9 Nov 2022 18:02:24 +1100 Message-Id: <20221109070224.13073-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221109070224.13073-1-richard.henderson@linaro.org> References: <20221109070224.13073-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Isolate the code protected by setjmp. Fixes: translate-all.c: In function ‘tb_gen_code’: translate-all.c:748:51: error: argument ‘cflags’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered] Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- accel/tcg/translate-all.c | 58 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9ee21f7f52..ac3ee3740c 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -742,6 +742,37 @@ void page_collection_unlock(struct page_collection *set) #endif /* !CONFIG_USER_ONLY */ +/* + * Isolate the portion of code gen which can setjmp/longjmp. + * Return the size of the generated code, or negative on error. + */ +static int setjmp_gen_code(CPUArchState *env, TranslationBlock *tb, + target_ulong pc, void *host_pc, + int *max_insns, int64_t *ti) +{ + int ret = sigsetjmp(tcg_ctx->jmp_trans, 0); + if (unlikely(ret != 0)) { + return ret; + } + + tcg_func_start(tcg_ctx); + + tcg_ctx->cpu = env_cpu(env); + gen_intermediate_code(env_cpu(env), tb, *max_insns, pc, host_pc); + assert(tb->size != 0); + tcg_ctx->cpu = NULL; + *max_insns = tb->icount; + +#ifdef CONFIG_PROFILER + qatomic_set(&tcg_ctx->prof.tb_count, tcg_ctx->prof.tb_count + 1); + qatomic_set(&tcg_ctx->prof.interm_time, + tcg_ctx->prof.interm_time + profile_getclock() - *ti); + *ti = profile_getclock(); +#endif + + return tcg_gen_code(tcg_ctx, tb, pc); +} + /* Called with mmap_lock held for user mode emulation. */ TranslationBlock *tb_gen_code(CPUState *cpu, target_ulong pc, target_ulong cs_base, @@ -754,8 +785,8 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int gen_code_size, search_size, max_insns; #ifdef CONFIG_PROFILER TCGProfile *prof = &tcg_ctx->prof; - int64_t ti; #endif + int64_t ti; void *host_pc; assert_memory_lock(); @@ -805,33 +836,10 @@ TranslationBlock *tb_gen_code(CPUState *cpu, ti = profile_getclock(); #endif - gen_code_size = sigsetjmp(tcg_ctx->jmp_trans, 0); - if (unlikely(gen_code_size != 0)) { - goto error_return; - } - - tcg_func_start(tcg_ctx); - - tcg_ctx->cpu = env_cpu(env); - gen_intermediate_code(cpu, tb, max_insns, pc, host_pc); - assert(tb->size != 0); - tcg_ctx->cpu = NULL; - max_insns = tb->icount; - trace_translate_block(tb, pc, tb->tc.ptr); - /* generate machine code */ - -#ifdef CONFIG_PROFILER - qatomic_set(&prof->tb_count, prof->tb_count + 1); - qatomic_set(&prof->interm_time, - prof->interm_time + profile_getclock() - ti); - ti = profile_getclock(); -#endif - - gen_code_size = tcg_gen_code(tcg_ctx, tb, pc); + gen_code_size = setjmp_gen_code(env, tb, pc, host_pc, &max_insns, &ti); if (unlikely(gen_code_size < 0)) { - error_return: switch (gen_code_size) { case -1: /*