From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JrbhG-0000xz-69 for qemu-devel@nongnu.org; Thu, 01 May 2008 12:31:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JrbhF-0000xh-43 for qemu-devel@nongnu.org; Thu, 01 May 2008 12:31:49 -0400 Received: from [199.232.76.173] (port=47793 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JrbhF-0000xe-0z for qemu-devel@nongnu.org; Thu, 01 May 2008 12:31:49 -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 1JrbhE-0008Oe-HQ for qemu-devel@nongnu.org; Thu, 01 May 2008 12:31:48 -0400 From: Paul Brook Subject: Re: [Qemu-devel] Crash due to invalid env->current_tb Date: Thu, 1 May 2008 17:31:44 +0100 References: <20080429115614.GA15524@os.inf.tu-dresden.de> <200805011704.43953.paul@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805011731.44724.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: Blue Swirl Cc: qemu-devel@nongnu.org On Thursday 01 May 2008, Blue Swirl wrote: > On 5/1/08, Paul Brook wrote: > > > > T0 = gen_func(); > > > > > > > > For 64bit target T0 is 64bits so "=a" does not work and "=A" is > > > > needed. The strange thing is that I need to throw away the upper > > > > 32bits because otherwise it won't work. gen_func is defined to > > > > return just long but T0 is unsigned long long, this seems > > > > inconsistent. The 'and' does not appear in 32bit targets so it does > > > > not harm there. > > > > > > This is because in this special case, T0 is not used as target CPU > > > temporary, but instead to return next TB address. On i386 this is 32 > > > bits, so only EAX is needed. TCG does not touch EDX, so it contains > > > garbage. This also means that moving EDX to high word of T0 and then > > > throwing the high word away may be slightly wasteful. > > > > Do we need to use T0 at all here? Can't we just use a normal local > > variable? > > I suspect T0 was used to gain extra performance, Really? I doubt it. Especially on x86 reserving a register for a fixed purpose is almost always a bad idea. It was used with dyngen because there was no way of directly passing information between cpu_loop and generated code. However now we have a proper code generator there is no need for this. > but in case of 64-bit target on 32-bit host there is this unnecessary work. > > But does cpu-exec.c need to know about T0/T1/T2 at all? I don't think so. > Can we replace exec.h include with cpu.h one? Currently we still need it to setup "env". However once we have proper TCG prologue/epilogue we should be able to pass env as an argument to gen_func, and have that do the setup for us. Paul