[Ada] Preliminary work for enlarging nodes

Arnaud Charlet charlet@adacore.com
Mon Mar 19 16:42:00 GMT 2012


This patch provides a debug switch -gnatd.N that has the effect of
enlarging entities in the compiler by one node. The addition node
is not used, but this can be used to evaluate the impact of adding
a node. No test, since no external effect.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-03-19  Robert Dewar  <dewar@adacore.com>

	* atree.adb (Allocate_Initialize_Node): Use Num_Extension_Nodes
	* atree.ads (Num_Extension_Nodes): New variable
	* debug.adb: New debug flag -gnatd.N
	* gnat1drv.adb (Adjust_Global_Switches): Adjust
	Num_Extension_Nodes if -gnatd.N set

-------------- next part --------------
Index: debug.adb
===================================================================
--- debug.adb	(revision 185526)
+++ debug.adb	(working copy)
@@ -131,7 +131,7 @@
    --  d.K  Alfa detection only mode for gnat2why
    --  d.L  Depend on back end for limited types in conditional expressions
    --  d.M
-   --  d.N
+   --  d.N  Add node to all entities
    --  d.O  Dump internal SCO tables
    --  d.P  Previous (non-optimized) handling of length comparisons
    --  d.Q
@@ -629,6 +629,10 @@
    --       case expansion, leaving it up to the back end to handle conditional
    --       expressions correctly.
 
+   --  d.N  Enlarge entities by one node (but don't attempt to use this extra
+   --       node for storage of any flags or fields). This can be used to do
+   --       experiments on the impact of increasing entity sizes.
+
    --  d.O  Dump internal SCO tables. Before outputting the SCO information to
    --       the ALI file, the internal SCO tables (SCO_Table/SCO_Unit_Table)
    --       are dumped for debugging purposes.
Index: gnat1drv.adb
===================================================================
--- gnat1drv.adb	(revision 185520)
+++ gnat1drv.adb	(working copy)
@@ -289,6 +289,12 @@
          Ttypes.Target_Strict_Alignment := True;
       end if;
 
+      --  Increase size of allocated entities if debug flag -gnatd.N is set
+
+      if Debug_Flag_Dot_NN then
+         Atree.Num_Extension_Nodes := Atree.Num_Extension_Nodes + 1;
+      end if;
+
       --  Disable static allocation of dispatch tables if -gnatd.t or if layout
       --  is enabled. The front end's layout phase currently treats types that
       --  have discriminant-dependent arrays as not being static even when a
Index: atree.adb
===================================================================
--- atree.adb	(revision 185520)
+++ atree.adb	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, 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- --
@@ -516,11 +516,11 @@
 
       if With_Extension then
          if Present (Src) and then Has_Extension (Src) then
-            for J in 1 .. 4 loop
+            for J in 1 .. Num_Extension_Nodes loop
                Nodes.Append (Nodes.Table (Src + Node_Id (J)));
             end loop;
          else
-            for J in 1 .. 4 loop
+            for J in 1 .. Num_Extension_Nodes loop
                Nodes.Append (Default_Node_Extension);
             end loop;
          end if;
Index: atree.ads
===================================================================
--- atree.ads	(revision 185520)
+++ atree.ads	(working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, 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- --
@@ -65,6 +65,17 @@
 --  syntax tree format. Subsequent processing in the front end traverses the
 --  tree, transforming it in various ways and adding semantic information.
 
+   ----------------------
+   -- Size of Entities --
+   ----------------------
+
+   --  Currently entities are composed of 5 sequentially allocated 32-byte
+   --  nodes, considered as a single record. The following definition gives
+   --  the number of extension nodes.
+
+   Num_Extension_Nodes : Int := 4;
+   --  This value is increased by one if debug flag -gnatd.N is set
+
    ----------------------------------------
    -- Definitions of Fields in Tree Node --
    ----------------------------------------


More information about the Gcc-patches mailing list