From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zphs2-0003DD-RF for qemu-devel@nongnu.org; Fri, 23 Oct 2015 15:19:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zphry-0006yO-Ql for qemu-devel@nongnu.org; Fri, 23 Oct 2015 15:19:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zphry-0006yH-Ji for qemu-devel@nongnu.org; Fri, 23 Oct 2015 15:19:18 -0400 References: <1445576998-2921-1-git-send-email-eblake@redhat.com> <1445576998-2921-11-git-send-email-eblake@redhat.com> <87oafp8kjl.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <562A882F.4080407@redhat.com> Date: Fri, 23 Oct 2015 13:19:11 -0600 MIME-Version: 1.0 In-Reply-To: <87oafp8kjl.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Wau1sGnHL28rOkp62rnTK4usogvjwjRS8" Subject: Re: [Qemu-devel] [PATCH v10 10/25] qapi: Unbox base members List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Luiz Capitulino , Gerd Hoffmann , qemu-devel@nongnu.org, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Wau1sGnHL28rOkp62rnTK4usogvjwjRS8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/23/2015 01:14 PM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> 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 SpiceChan= nel *obj) >> | { >> |- return (SpiceBasicInfo *)obj->base; >> |+ return (SpiceBasicInfo *)obj; >> | } >=20 > 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. If I limit patch 9 to just unions, then there would be no clients using the upcast wrappers in patch 9. The only users of upcasts that benefit from the result of gen_upcast() are the struct users in ui/*.c, that were touched in patch 9, and then where _this_ change in the generated code in patch 10 lets ui/ code remain unchanged (the way the upcast happens changed, but it was nicely hidden behind the nice wrapper interface). >=20 >> >> and this in qapi-visit.c: >> >> | static void visit_type_SpiceChannel_fields(Visitor *v, SpiceChannel = **obj, Error **errp) >> | { >> | Error *err =3D NULL; >> | >> |- visit_type_implicit_SpiceBasicInfo(v, &(*obj)->base, &err); >> |+ visit_type_SpiceBasiInfo_fields(v, (SpiceBasicInfo **)obj, &err)= ; >=20 > s/BasiI/BasicI/ I should have used the mouse to copy-paste instead of typing late at night :) --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Wau1sGnHL28rOkp62rnTK4usogvjwjRS8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWKogvAAoJEKeha0olJ0NqQI4H/RLMqijbh1PULBCRtawh8FSD 1ysF49ZGdDN0yhvVyH8hnt9RAjmGA6BpBuaBpKR5bJRF7/KOORPV9RsydrtARUwf XejEvYvYcvTNVUtuXq/lzAiJt1xF9FnIjc7y1kd5PaF/nhn597+Caa6pOcnZU5Y0 SJfTprhmqYoNF74FX/4yGBGhYZfODAyAzXlkwgztXNqjBRaKMln+WX+Kqyqc9Zto KDM+ykpUfSCtOTslWyGRi8IFfF/E/oVRevOHk4Qm+U3th9INfdiXhLSIq1kmgE/L ScSwapVVZfZF0S299pLGpnCY1M4irqgcSCeKc0ENPPNndMaTtvImR3GmihjACHE= =uDny -----END PGP SIGNATURE----- --Wau1sGnHL28rOkp62rnTK4usogvjwjRS8--