From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUfop-00076D-Qs for qemu-devel@nongnu.org; Mon, 31 Mar 2014 13:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WUfok-0003XO-89 for qemu-devel@nongnu.org; Mon, 31 Mar 2014 13:16:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:45342 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WUfok-0003X5-2P for qemu-devel@nongnu.org; Mon, 31 Mar 2014 13:16:14 -0400 Message-ID: <5339A2DD.3020608@suse.de> Date: Mon, 31 Mar 2014 19:16:13 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1396021744-29942-1-git-send-email-afaerber@suse.de> <5335AD0A.8060705@suse.de> In-Reply-To: <5335AD0A.8060705@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Laurent Desnogues , Paolo Bonzini , QEMU Developers Am 28.03.2014 18:10, schrieb Andreas F=C3=A4rber: > Am 28.03.2014 16:52, schrieb Peter Maydell: >> On 28 March 2014 15:49, Andreas F=C3=A4rber wrote: >>> diff --git a/include/qom/cpu.h b/include/qom/cpu.h >>> index f99885a..0aa1bdc 100644 >>> --- a/include/qom/cpu.h >>> +++ b/include/qom/cpu.h >>> @@ -53,7 +53,7 @@ typedef uint64_t vaddr; >>> >>> #define TYPE_CPU "cpu" >>> >>> -#define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU) >=20 > /* Avoid unnecessary penalties in hot paths by using an unchecked cast.= */ ? Based on a suggestion from Peter on IRC extending this to: diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 0aa1bdc..df977c8 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -53,7 +53,12 @@ typedef uint64_t vaddr; #define TYPE_CPU "cpu" +/* Since this macro is used a lot in hot code paths and in conjunction w= ith + * FooCPU *foo_env_get_cpu(), we deviate from usual QOM practice by usin= g + * an unchecked cast. + */ #define CPU(obj) ((CPUState *)(obj)) + #define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU) #define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU) Thanks, applied to qom-cpu: https://github.com/afaerber/qemu-cpu/commits/qom-cpu Pull coming up shortly. Regards, 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