qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Laurent Desnogues <laurent.desnogues@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU()
Date: Mon, 31 Mar 2014 19:16:13 +0200	[thread overview]
Message-ID: <5339A2DD.3020608@suse.de> (raw)
In-Reply-To: <5335AD0A.8060705@suse.de>

Am 28.03.2014 18:10, schrieb Andreas Färber:
> Am 28.03.2014 16:52, schrieb Peter Maydell:
>> On 28 March 2014 15:49, Andreas Färber <afaerber@suse.de> 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)
> 
> /* 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 with
+ * FooCPU *foo_env_get_cpu(), we deviate from usual QOM practice by using
+ * 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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

      reply	other threads:[~2014-03-31 17:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-28 15:49 [Qemu-devel] [PATCH qom-cpu for-2.0] cpu: Avoid QOM casts for CPU() Andreas Färber
2014-03-28 15:52 ` Peter Maydell
2014-03-28 17:10   ` Andreas Färber
2014-03-31 17:16     ` Andreas Färber [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5339A2DD.3020608@suse.de \
    --to=afaerber@suse.de \
    --cc=laurent.desnogues@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).