From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ihx0W-0006Ug-8Q for qemu-devel@nongnu.org; Tue, 16 Oct 2007 20:43:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ihx0U-0006Sm-If for qemu-devel@nongnu.org; Tue, 16 Oct 2007 20:43:31 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ihx0U-0006SY-DG for qemu-devel@nongnu.org; Tue, 16 Oct 2007 20:43:30 -0400 Received: from mail.codesourcery.com ([65.74.133.4]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ihx0U-0008Jv-4A for qemu-devel@nongnu.org; Tue, 16 Oct 2007 20:43:30 -0400 From: Paul Brook Subject: Re: [Qemu-devel] RFC: Code fetch optimisation Date: Wed, 17 Oct 2007 01:43:23 +0100 References: <1192362267.9976.383.camel@rapid> <200710162300.27862.paul@codesourcery.com> <1192577909.9976.534.camel@rapid> In-Reply-To: <1192577909.9976.534.camel@rapid> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710170143.24140.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "J. Mayer" Cc: qemu-devel@nongnu.org > > I suspect the best solution is to backtrack (remove the generated ops) > > after decoding the insn if we discover we've passed a page boundary. The > > ld*_code routines can simply return garbage (e.g. zero) if the read is > > not on the first page. > > The "incorrect" returned value may be target specific to be sure it's > always an invalid opcode. It doesn't matter whether it's valid or not, and we've no way of guaranteeing that anyway. We just have to make sure we don't generate an infinitely long instruction. On a related note, I notice that we don't enforce x86 instruction length limits. > Backtracking should not be hard if we register the last cc pointer each > time we finish translating an insn. I'll think about this solution, > which really seems feasible to me. Right. You only have to worry about backtracking the state that's lives across insns and is not constant within a TB. For x86 I think this is dc->pc, dc->cc_op, gen_opc_ptr and nb_gen_labels. Plus you need to reset dc->is_jmp to zero. gen_opparam_ptr is not used after disassembly, so can be ignored. Paul