This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[intercu] Move the DIE hash table into dwarf2_cu


If we're going to keep DIEs from multiple compilation units around, we need
their hash tables too.  I chose to move the hash table into the comp unit,
instead of putting all DIEs in the same hash table, so that we can release
cached DIEs more efficiently.  Right now this is a big size boost to the
dwarf2_cu structure, even during partial symbol reading; later I will
investigate using a dynamic htab_t instead.

Committed to the intercu branch.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-02-23  Daniel Jacobowitz  <drow@mvista.com>

	* dwarf2read.c (REF_HASH_SIZE): Move above struct dwarf2_cu.
	(struct dwarf2_cu): Add die_ref_table.
	(die_ref_table): Delete static variable.
	(store_in_ref_table): Take a comp unit argument and use its
	die_ref_table.
	(dwarf2_empty_hash_tables): Likewise.
	(read_comp_unit): Update call to dwarf2_empty_hash_tables.
	(read_die_and_children): Update call to store_in_ref_table.
	(follow_die_ref): Use the comp unit's die_ref_table.

Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.135.2.23
diff -u -p -r1.135.2.23 dwarf2read.c
--- dwarf2read.c	23 Feb 2004 16:34:26 -0000	1.135.2.23
+++ dwarf2read.c	23 Feb 2004 16:56:35 -0000
@@ -224,6 +224,11 @@ struct comp_unit_head
     int base_known;
   };
 
+/* Fixed size for the DIE hash table.  */
+#ifndef REF_HASH_SIZE
+#define REF_HASH_SIZE 1021
+#endif
+
 /* Internal state when decoding a particular compilation unit.  */
 struct dwarf2_cu
 {
@@ -281,6 +286,9 @@ struct dwarf2_cu
 
   /* How many compilation units ago was this CU last referenced?  */
   int last_used;
+
+  /* A hash table of die offsets for following references.  */
+  struct die_info *die_ref_table[REF_HASH_SIZE];
 };
 
 static const struct objfile_data *dwarf2_cu_tree;
@@ -446,13 +454,6 @@ struct partial_die_info
 #define ATTR_ALLOC_CHUNK 4
 #endif
 
-/* A hash table of die offsets for following references.  */
-#ifndef REF_HASH_SIZE
-#define REF_HASH_SIZE 1021
-#endif
-
-static struct die_info *die_ref_table[REF_HASH_SIZE];
-
 /* Obstack for allocating temporary storage used during symbol reading.  */
 static struct obstack dwarf2_tmp_obstack;
 
@@ -947,9 +948,10 @@ static void dump_die (struct die_info *)
 
 static void dump_die_list (struct die_info *);
 
-static void store_in_ref_table (unsigned int, struct die_info *);
+static void store_in_ref_table (unsigned int, struct die_info *,
+				struct dwarf2_cu *);
 
-static void dwarf2_empty_hash_tables (void);
+static void dwarf2_empty_hash_tables (struct dwarf2_cu *);
 
 static unsigned int dwarf2_get_ref_die_offset (struct attribute *,
 					       struct dwarf2_cu *);
@@ -4526,7 +4528,7 @@ read_comp_unit (char *info_ptr, bfd *abf
 {
   /* Reset die reference table; we are
      building new ones now.  */
-  dwarf2_empty_hash_tables ();
+  dwarf2_empty_hash_tables (cu);
 
   return read_die_and_children (info_ptr, abfd, cu, &info_ptr, NULL);
 }
@@ -4548,7 +4550,7 @@ read_die_and_children (char *info_ptr, b
   int has_children;
 
   cur_ptr = read_full_die (&die, abfd, info_ptr, cu, &has_children);
-  store_in_ref_table (die->offset, die);
+  store_in_ref_table (die->offset, die, cu);
 
   if (has_children)
     {
@@ -8044,22 +8046,23 @@ dump_die_list (struct die_info *die)
 }
 
 static void
-store_in_ref_table (unsigned int offset, struct die_info *die)
+store_in_ref_table (unsigned int offset, struct die_info *die,
+		    struct dwarf2_cu *cu)
 {
   int h;
   struct die_info *old;
 
   h = (offset % REF_HASH_SIZE);
-  old = die_ref_table[h];
+  old = cu->die_ref_table[h];
   die->next_ref = old;
-  die_ref_table[h] = die;
+  cu->die_ref_table[h] = die;
 }
 
 
 static void
-dwarf2_empty_hash_tables (void)
+dwarf2_empty_hash_tables (struct dwarf2_cu *cu)
 {
-  memset (die_ref_table, 0, sizeof (die_ref_table));
+  memset (cu->die_ref_table, 0, sizeof (cu->die_ref_table));
 }
 
 static unsigned int
@@ -8118,16 +8121,14 @@ follow_die_ref (struct attribute *attr, 
   int h;
 
   offset = dwarf2_get_ref_die_offset (attr, cu);
+  *spec_cu = cu;
 
   h = (offset % REF_HASH_SIZE);
-  die = die_ref_table[h];
+  die = (*spec_cu)->die_ref_table[h];
   while (die)
     {
       if (die->offset == offset)
-	{
-	  *spec_cu = cu;
-	  return die;
-	}
+	return die;
       die = die->next_ref;
     }
   return NULL;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]