From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaqMz-0007x0-Tr for qemu-devel@nongnu.org; Fri, 10 May 2013 12:40:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UaqMy-00085z-N1 for qemu-devel@nongnu.org; Fri, 10 May 2013 12:40:33 -0400 Message-ID: <518D22FB.30307@suse.de> Date: Fri, 10 May 2013 18:40:27 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1368196799-19982-1-git-send-email-afaerber@suse.de> <87obcizxgk.fsf@codemonkey.ws> <518D10E3.4080001@suse.de> <14CF0363-E558-4387-A401-14C940131BDB@suse.de> <518D1CDD.4060705@suse.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-1.5?] target-ppc: Drop unnecessary dynamic cast in ppc_env_get_cpu() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Anthony Liguori , Alexander Graf , qemu-devel@nongnu.org, PowerPC , pbonzini@redhat.com, aurelien@aurel32.net Am 10.05.2013 18:20, schrieb Peter Maydell: > On 10 May 2013 17:14, Andreas F=C3=A4rber wrote: >> Personally I wouldn't oppose dropping these checks for release builds = as >> proposed by Paolo in his series; for me, the value of POWERPC_CPU() is >> being closer to an OO cast than any container_of()-style expressions. >> >> But I can also see Anthony's point that we should try to optimize >> dynamic_cast rather than circumventing it. >=20 > I don't think we should be doing anything dynamically at all. > We know at compile time that we've been passed a CPUPPCState*, > and we know that we always get from that to a CPUState* > by subtracting a compile-time-constant offset. Nothing about > this is dynamic at all and anything we do at runtime beyond > that subtraction is pure overhead. No one doubts that for CPU. But if you think of AXI, I2C and the general connecter inheritance vs. aggregation discussion, it becomes much more hairy! In particular Anthony's solution to the I/O port VGA vs. ISA problem was dropping ISADevice as base type and turning ISA into an interface on a chipset object. Then you may know which interfaces are available on your device, but you still need some special non-C cast, aka dynamic_cast. So in the end we want C++ (replace with favorite native OO language) but we can't switch because not all devices are QOM'ified yet, and when QOM'ifying them we get complaints about bad QOM performance. Either we ignore performance hits and hurry up with the conversion or we address performance hits to at least some degree, otherwise we're not going to reach a satisfactory solution... Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=C3=B6rffer; HRB 16746 AG N=C3=BC= rnberg