qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v10 10/25] qapi: Unbox base members


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v10 10/25] qapi: Unbox base members
Date: Fri, 23 Oct 2015 14:45:41 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 10/23/2015 01:19 PM, Eric Blake wrote:
> On 10/23/2015 01:14 PM, Markus Armbruster wrote:
>> Eric Blake <address@hidden> writes:
>>
>>> Rather than storing a base class as a pointer to a box, just
>>> store the fields of that base class in the same order, so that
>>> a child struct can be directly cast to its parent.  This gives
>>> less malloc overhead, less pointer dereferencing, and even less
>>> generated code.  Compare to the earlier commit 1e6c1616a "qapi:
>>> Generate a nicer struct for flat unions" (although that patch
>>> had fewer places to change, as less of qemu was directly using
>>> qapi structs for flat unions).  It also drops a hack that was
>>> needed for type-safe casting to the base class of a struct.
>>>
>>> Changes to the generated code look like this in qapi-types.h:
>>>
> 
>>>
>>> as well as:
>>>
>>> | static inline SpiceBasicInfo *qapi_SpiceChannel_base(const SpiceChannel 
>>> *obj)
>>> | {
>>> |-    return (SpiceBasicInfo *)obj->base;
>>> |+    return (SpiceBasicInfo *)obj;
>>> | }
>>
>> No more, PATCH 09 hides this change.  If you limit that one to just
>> unions, it'll be visible again here, but it'll look different.
> 
> No, this change is new to v10, because of patch 09.  In v9, we did not
> have gen_upcast(); in v10, patch 9's version of gen_upcast() had to
> special-case struct to output 'obj->base', and patch 10 gets rid of the
> special case to output 'obj' always.

Serves me right for reading this response before the 9/25 response. I
see what you mean now, and will be floating hunks differently on the v11
respin.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]