From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uaotp-0002u8-93 for qemu-devel@nongnu.org; Fri, 10 May 2013 11:06:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uaotl-0001V0-Ei for qemu-devel@nongnu.org; Fri, 10 May 2013 11:06:21 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:40978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uaotk-0001Up-SM for qemu-devel@nongnu.org; Fri, 10 May 2013 11:06:17 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 11 May 2013 01:03:51 +1000 From: Anthony Liguori In-Reply-To: <1368196799-19982-1-git-send-email-afaerber@suse.de> References: <1368196799-19982-1-git-send-email-afaerber@suse.de> Date: Fri, 10 May 2013 10:06:03 -0500 Message-ID: <87obcizxgk.fsf@codemonkey.ws> MIME-Version: 1.0 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: Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, "open list:PowerPC" , Alexander Graf , aurelien@aurel32.net Andreas F=C3=A4rber writes: > A transition from CPUPPCState to PowerPCCPU can be considered safe, > just like PowerPCCPU::env access in the opposite direction. > > This should slightly improve interrupt performance. > > Reported-by: Anthony Liguori > Signed-off-by: Andreas F=C3=A4rber Another option would be to leave it and do something like: diff --git a/qom/object.c b/qom/object.c index 75e6aac..cba1d88 100644 --- a/qom/object.c +++ b/qom/object.c @@ -126,8 +126,13 @@ static TypeImpl *type_register_internal(const TypeInfo= *info) =20 TypeImpl *type_register(const TypeInfo *info) { + TypeImpl *impl; + assert(info->parent); - return type_register_internal(info); + impl =3D type_register_internal(info); + g_free(impl->name); + impl->name =3D info->name; + return impl; } =20 TypeImpl *type_register_static(const TypeInfo *info) @@ -449,10 +490,16 @@ Object *object_dynamic_cast_assert(Object *obj, const= char *typename) ObjectClass *object_class_dynamic_cast(ObjectClass *class, const char *typename) { - TypeImpl *target_type =3D type_get_by_name(typename); + TypeImpl *target_type; TypeImpl *type =3D class->type; ObjectClass *ret =3D NULL; =20 + if (type->name =3D=3D typename) { + return class; + } + + target_type =3D type_get_by_name(typename); + if (!target_type) { /* target class type unknown, so fail the cast */ return NULL; Which makes casting an object to it's concrete class free. Regards, Anthony Liguori > --- > target-ppc/cpu-qom.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h > index eb03a00..f62181f 100644 > --- a/target-ppc/cpu-qom.h > +++ b/target-ppc/cpu-qom.h > @@ -91,7 +91,7 @@ typedef struct PowerPCCPU { >=20=20 > static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env) > { > - return POWERPC_CPU(container_of(env, PowerPCCPU, env)); > + return container_of(env, PowerPCCPU, env); > } >=20=20 > #define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e)) > --=20 > 1.8.1.4