Received: from eggs.gnu.org ([2001:4830:134:3::10]:41034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWS05-0003w5-4f for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:04:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWS01-0006Ej-Lz for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:04:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWS01-0006E7-9n for qemu-devel@nongnu.org; Thu, 18 Feb 2016 12:04:17 -0500 From: Markus Armbruster References: <1455778109-6278-1-git-send-email-eblake@redhat.com> <1455778109-6278-7-git-send-email-eblake@redhat.com> <87io1mdsrj.fsf@blackfin.pond.sub.org> <56C5D8AC.60302@redhat.com> Date: Thu, 18 Feb 2016 18:04:14 +0100 In-Reply-To: <56C5D8AC.60302@redhat.com> (Eric Blake's message of "Thu, 18 Feb 2016 07:43:56 -0700") Message-ID: <87k2m27xwx.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v11 06/15] qapi: Visit variants in visit_type_FOO_fields() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, Michael Roth Eric Blake writes: > On 02/18/2016 06:58 AM, Markus Armbruster wrote: >> Eric Blake writes: >> >>> We initially created the static visit_type_FOO_fields() helper >>> function for reuse of code - we have cases where the initial >>> setup for a visit has different allocation (depending on whether >>> the fields represent a stand-alone type or are embedded as part >>> of a larger type), but where the actual field visits are >>> identical once a pointer is available. >>> >>> Up until the previous patch, visit_type_FOO_fields() was only >>> used for structs (no variants), so it was covering every field >>> for each type where it was emitted. >>> >>> Meanwhile, the code for visiting unions looks like: > > Maybe reword this to: > > Meanwhile, the previous patch updated the code for visiting unions to > look like: I don't mind. >>> The resulting diff to the generated code is a bit hard to read, >> >> Mostly because a few visit_type_T_fields() get generated in a different >> place. If I move them back manually for a diff, the patch's effect >> becomes clear enough: the switch to visit the variants and the >> visit_start_union() guarding it moves from visit_type_T() to >> visit_type_T_fields(). That's what the commit message promises. > > I debated about splitting out a separate patch so that the motion of > visit_type_T_fields() is separate from the variant visiting, but it > wasn't worth the effort. I'm glad you managed to see through the churn > in the generated code. > > >>> -def gen_visit_struct_fields(name, base, members): >>> +def gen_visit_struct_fields(name, base, members, variants=None): >> >> Two callers: >> >> * gen_visit_union(): the new code here comes from there, except it's now >> completely guarded by if variants. Effect: generated code motion. >> >> * gen_visit_struct(): passes no variants, guard false, thus no change. >> >> I think the patch becomes slightly clearer if you make the variants >> parameter mandatory. It'll probably become mandatory anyway when we >> unify gen_visit_struct() and gen_visit_union(). > > You beat me to it - yes, I realized that after sending the series. We > can either squash in the fix here to make variants mandatory (and > gen_visit_struct() pass an explicit None, which disappears in the next > patch), or squash in a fix to 7/15 to delete the '=None'. Either way, > I'm fine if you tackle that, if no other major findings turn up. Can do.