From patchwork Tue May 2 08:55:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 757474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wHFVr0mpFz9ryb for ; Tue, 2 May 2017 18:55:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="tXODwzbe"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=d29Y5mxMdCTbotiJxpUgDFvb8UrOq5n0qfD4pR7qd9cDIuScyO QoU25VjQZo/BX86Blsf69xW6pDdEx35Q5AVvBZYohVG1KUvGYpj/P4b2HgEe/qbm 5TrDfFK+bJm50tYKxyQeAoFuwXRj1R2/XS1tkrMqvGZEPOG7nj47lshks= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=TC/Io5rebrXzkSsdq3u+dXo43ho=; b=tXODwzbe7faaJPbNMUYR ewWeJFTXP59dRWIE8t0F06JFHfX2IDc7OJ5+ORuPjTAV/UMOSFC/4/8OiDafY9X8 9LQ/Mh1UwCXTUc01MwHOFkAaU1uK6QkqnILdWPZhEML6OHhhP0YmRxTYE/qx4MFB pE/RkCuLTMNweVQ4Zqtbqig= Received: (qmail 32609 invoked by alias); 2 May 2017 08:55:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32583 invoked by uid 89); 2 May 2017 08:55:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.1 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_SHORT autolearn=ham version=3.3.2 spammy=19992017, 1999-2017, Fully, States X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 May 2017 08:55:16 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id BD7989ED0; Tue, 2 May 2017 04:55:17 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 97AzI4G0uYry; Tue, 2 May 2017 04:55:17 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 9E5909EDA; Tue, 2 May 2017 04:55:17 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4192) id 9B7CA4FF; Tue, 2 May 2017 04:55:17 -0400 (EDT) Date: Tue, 2 May 2017 04:55:17 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Move variable-length components to last position in record types Message-ID: <20170502085517.GA135063@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) This optimizes the layout of some record types declared in the runtime, but only in the private part of the spec or in the body, hence no API changes. There is also a similar to the Xr_Tabls support package. Tested on x86_64-pc-linux-gnu, committed on trunk 2017-05-02 Eric Botcazou * g-forstr.ads (Data): Move Format component last. * g-forstr.adb ("+"): Adjust for above change. * g-rewdat.ads (Buffer): Move Buffer, Current, Pattern and Value last. * g-sechas.ads (Context): Move Key last. * g-socket.ads (Service_Entry_Type): Move Aliases last. * s-fileio.adb (Temp_File_Record): Move Name last. * s-regexp.adb (Regexp_Value): Move Case_Sensitive last. * xr_tabls.ads (Project_File): Move Src_Dir and Obj_Dir last. Index: xr_tabls.ads =================================================================== --- xr_tabls.ads (revision 247461) +++ xr_tabls.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1998-2014, Free Software Foundation, Inc. -- +-- Copyright (C) 1998-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -292,12 +292,11 @@ private type Project_File (Src_Dir_Length, Obj_Dir_Length : Natural) is record - Src_Dir : String (1 .. Src_Dir_Length); - Src_Dir_Index : Integer; - - Obj_Dir : String (1 .. Obj_Dir_Length); + Src_Dir_Index : Integer; Obj_Dir_Index : Integer; Last_Obj_Dir_Start : Natural; + Src_Dir : String (1 .. Src_Dir_Length); + Obj_Dir : String (1 .. Obj_Dir_Length); end record; type Project_File_Ptr is access all Project_File; @@ -364,7 +363,6 @@ type Declaration_Record (Symbol_Length : Natural) is record Key : Cst_String_Access; - Symbol : String (1 .. Symbol_Length); Decl : Reference; Is_Parameter : Boolean := False; -- True if entity is subprog param Decl_Type : Character; @@ -374,6 +372,7 @@ Match : Boolean := False; Par_Symbol : Declaration_Reference := null; Next : Declaration_Reference := null; + Symbol : String (1 .. Symbol_Length); end record; -- The lists of referenced (Body_Ref, Ref_Ref and Modif_Ref) are -- kept unsorted until the results needs to be printed. This saves Index: g-sechas.ads =================================================================== --- g-sechas.ads (revision 247461) +++ g-sechas.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2009-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 2009-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -208,14 +208,14 @@ -- KL is 0 for a normal hash context, > 0 for HMAC type Context (KL : Key_Length := 0) is record - Key : Stream_Element_Array (1 .. KL); - -- HMAC key - H_State : Hash_State.State (0 .. State_Words - 1) := Initial_State; -- Function-specific state M_State : Message_State (Block_Length); -- Function-independent state (block buffer) + + Key : Stream_Element_Array (1 .. KL); + -- HMAC key end record; Initial_Context : constant Context (KL => 0) := (others => <>); Index: g-rewdat.ads =================================================================== --- g-rewdat.ads (revision 247461) +++ g-rewdat.ads (working copy) @@ -5,7 +5,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2014, Free Software Foundation, Inc. -- +-- Copyright (C) 2014-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -128,6 +128,12 @@ type Buffer (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is limited record + Pos_C : Stream_Element_Offset; -- last valid element in Current + Pos_B : Stream_Element_Offset; -- last valid element in Buffer + + Next : Buffer_Ref; + -- A link to another rewriter if any + Buffer : Stream_Element_Array (1 .. Size); -- Fully prepared/rewritten data waiting to be output @@ -141,12 +147,6 @@ Value : Stream_Element_Array (1 .. Size_Value); -- The value the pattern is replaced by - - Pos_C : Stream_Element_Offset; -- last valid element in Current - Pos_B : Stream_Element_Offset; -- last valid element in Buffer - - Next : Buffer_Ref; - -- A link to another rewriter if any end record; end GNAT.Rewrite_Data; Index: s-regexp.adb =================================================================== --- s-regexp.adb (revision 247461) +++ s-regexp.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1999-2016, AdaCore -- +-- Copyright (C) 1999-2017, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -68,9 +68,9 @@ Num_States : State_Index) is record Map : Mapping; + Case_Sensitive : Boolean; States : Regexp_Array (1 .. Num_States, 0 .. Alphabet_Size); Is_Final : Boolean_Array (1 .. Num_States); - Case_Sensitive : Boolean; end record; -- Deterministic finite-state machine Index: g-socket.ads =================================================================== --- g-socket.ads (revision 247461) +++ g-socket.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001-2016, AdaCore -- +-- Copyright (C) 2001-2017, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -1268,9 +1268,9 @@ type Service_Entry_Type (Aliases_Length : Natural) is record Official : Name_Type; - Aliases : Name_Array (1 .. Aliases_Length); Port : Port_Type; Protocol : Name_Type; + Aliases : Name_Array (1 .. Aliases_Length); end record; type Request_Flag_Type is mod 2 ** 8; Index: g-forstr.adb =================================================================== --- g-forstr.adb (revision 247461) +++ g-forstr.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2014-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 2014-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -130,8 +130,8 @@ begin return Formatted_String' (Finalization.Controlled with - D => new Data'(Format'Length, 1, Format, 1, - Null_Unbounded_String, 0, 0, (0, 0))); + D => new Data'(Format'Length, 1, 1, + Null_Unbounded_String, 0, 0, (0, 0), Format)); end "+"; --------- Index: g-forstr.ads =================================================================== --- g-forstr.ads (revision 247461) +++ g-forstr.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2014-2016, Free Software Foundation, Inc. -- +-- Copyright (C) 2014-2017, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -287,12 +287,12 @@ type Data (Size : Natural) is record Ref_Count : Natural := 1; - Format : String (1 .. Size); -- the format string Index : Positive := 1; -- format index for next value Result : Unbounded_String; -- current value Current : Natural; -- the current format number Stored_Value : Natural := 0; -- number of stored values in Stack Stack : I_Vars; + Format : String (1 .. Size); -- the format string end record; type Data_Access is access Data; Index: s-fileio.adb =================================================================== --- s-fileio.adb (revision 247465) +++ s-fileio.adb (working copy) @@ -63,8 +63,8 @@ type Temp_File_Record is record File : AFCB_Ptr; + Next : aliased Temp_File_Record_Ptr; Name : String (1 .. max_path_len + 1); - Next : aliased Temp_File_Record_Ptr; end record; -- One of these is allocated for each temporary file created